diff options
-rw-r--r-- | sway/desktop/transaction.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index fdf24bd3..145c5f92 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -22,7 +22,6 @@ struct sway_transaction { | |||
22 | list_t *instructions; // struct sway_transaction_instruction * | 22 | list_t *instructions; // struct sway_transaction_instruction * |
23 | size_t num_waiting; | 23 | size_t num_waiting; |
24 | size_t num_configures; | 24 | size_t num_configures; |
25 | uint32_t con_ids; // Bitwise XOR of view container IDs | ||
26 | struct timespec commit_time; | 25 | struct timespec commit_time; |
27 | }; | 26 | }; |
28 | 27 | ||
@@ -228,6 +227,22 @@ static void transaction_apply(struct sway_transaction *transaction) { | |||
228 | 227 | ||
229 | static void transaction_commit(struct sway_transaction *transaction); | 228 | static void transaction_commit(struct sway_transaction *transaction); |
230 | 229 | ||
230 | // Return true if both transactions operate on the same containers | ||
231 | static bool transaction_same_containers(struct sway_transaction *a, | ||
232 | struct sway_transaction *b) { | ||
233 | if (a->instructions->length != b->instructions->length) { | ||
234 | return false; | ||
235 | } | ||
236 | for (int i = 0; i < a->instructions->length; ++i) { | ||
237 | struct sway_transaction_instruction *a_inst = a->instructions->items[i]; | ||
238 | struct sway_transaction_instruction *b_inst = b->instructions->items[i]; | ||
239 | if (a_inst->container != b_inst->container) { | ||
240 | return false; | ||
241 | } | ||
242 | } | ||
243 | return true; | ||
244 | } | ||
245 | |||
231 | static void transaction_progress_queue() { | 246 | static void transaction_progress_queue() { |
232 | if (!server.transactions->length) { | 247 | if (!server.transactions->length) { |
233 | return; | 248 | return; |
@@ -252,7 +267,7 @@ static void transaction_progress_queue() { | |||
252 | while (server.transactions->length >= 2) { | 267 | while (server.transactions->length >= 2) { |
253 | struct sway_transaction *a = server.transactions->items[0]; | 268 | struct sway_transaction *a = server.transactions->items[0]; |
254 | struct sway_transaction *b = server.transactions->items[1]; | 269 | struct sway_transaction *b = server.transactions->items[1]; |
255 | if (a->con_ids == b->con_ids) { | 270 | if (transaction_same_containers(a, b)) { |
256 | list_del(server.transactions, 0); | 271 | list_del(server.transactions, 0); |
257 | transaction_destroy(a); | 272 | transaction_destroy(a); |
258 | } else { | 273 | } else { |
@@ -304,7 +319,6 @@ static void transaction_commit(struct sway_transaction *transaction) { | |||
304 | instruction->state.view_width, | 319 | instruction->state.view_width, |
305 | instruction->state.view_height); | 320 | instruction->state.view_height); |
306 | ++transaction->num_waiting; | 321 | ++transaction->num_waiting; |
307 | transaction->con_ids ^= con->id; | ||
308 | 322 | ||
309 | // From here on we are rendering a saved buffer of the view, which | 323 | // From here on we are rendering a saved buffer of the view, which |
310 | // means we can send a frame done event to make the client redraw it | 324 | // means we can send a frame done event to make the client redraw it |