diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-24 23:01:09 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-24 23:01:09 +1000 |
commit | 1549fb719ae75a498bf319db45281464e72c759e (patch) | |
tree | e5944487928a65b1af3b7dc9a44f1b14250bc0bf /sway/desktop/transaction.c | |
parent | Fix crash when running move <direction> in an empty workspace (diff) | |
download | sway-1549fb719ae75a498bf319db45281464e72c759e.tar.gz sway-1549fb719ae75a498bf319db45281464e72c759e.tar.zst sway-1549fb719ae75a498bf319db45281464e72c759e.zip |
Implement atomic layout updates for xwayland views
Diffstat (limited to 'sway/desktop/transaction.c')
-rw-r--r-- | sway/desktop/transaction.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 04142bcc..08678b5b 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -267,9 +267,7 @@ void transaction_commit(struct sway_transaction *transaction) { | |||
267 | instruction->state.view_y, | 267 | instruction->state.view_y, |
268 | instruction->state.view_width, | 268 | instruction->state.view_width, |
269 | instruction->state.view_height); | 269 | instruction->state.view_height); |
270 | if (instruction->serial) { | 270 | ++transaction->num_waiting; |
271 | ++transaction->num_waiting; | ||
272 | } | ||
273 | } | 271 | } |
274 | list_add(con->instructions, instruction); | 272 | list_add(con->instructions, instruction); |
275 | } | 273 | } |
@@ -307,20 +305,8 @@ void transaction_commit(struct sway_transaction *transaction) { | |||
307 | update_debug_tree(); | 305 | update_debug_tree(); |
308 | } | 306 | } |
309 | 307 | ||
310 | void transaction_notify_view_ready(struct sway_view *view, uint32_t serial) { | 308 | static void set_instruction_ready( |
311 | // Find the instruction | 309 | struct sway_transaction_instruction *instruction) { |
312 | struct sway_transaction_instruction *instruction = NULL; | ||
313 | for (int i = 0; i < view->swayc->instructions->length; ++i) { | ||
314 | struct sway_transaction_instruction *tmp_instruction = | ||
315 | view->swayc->instructions->items[i]; | ||
316 | if (tmp_instruction->serial == serial && !tmp_instruction->ready) { | ||
317 | instruction = tmp_instruction; | ||
318 | break; | ||
319 | } | ||
320 | } | ||
321 | if (!instruction) { | ||
322 | return; | ||
323 | } | ||
324 | instruction->ready = true; | 310 | instruction->ready = true; |
325 | 311 | ||
326 | // If all views are ready, apply the transaction. | 312 | // If all views are ready, apply the transaction. |
@@ -335,6 +321,30 @@ void transaction_notify_view_ready(struct sway_view *view, uint32_t serial) { | |||
335 | } | 321 | } |
336 | } | 322 | } |
337 | 323 | ||
324 | void transaction_notify_view_ready(struct sway_view *view, uint32_t serial) { | ||
325 | for (int i = 0; i < view->swayc->instructions->length; ++i) { | ||
326 | struct sway_transaction_instruction *instruction = | ||
327 | view->swayc->instructions->items[i]; | ||
328 | if (instruction->serial == serial && !instruction->ready) { | ||
329 | set_instruction_ready(instruction); | ||
330 | return; | ||
331 | } | ||
332 | } | ||
333 | } | ||
334 | |||
335 | void transaction_notify_view_ready_by_size(struct sway_view *view, | ||
336 | int width, int height) { | ||
337 | for (int i = 0; i < view->swayc->instructions->length; ++i) { | ||
338 | struct sway_transaction_instruction *instruction = | ||
339 | view->swayc->instructions->items[i]; | ||
340 | if (!instruction->ready && instruction->state.view_width == width && | ||
341 | instruction->state.view_height == height) { | ||
342 | set_instruction_ready(instruction); | ||
343 | return; | ||
344 | } | ||
345 | } | ||
346 | } | ||
347 | |||
338 | struct wlr_texture *transaction_get_texture(struct sway_view *view) { | 348 | struct wlr_texture *transaction_get_texture(struct sway_view *view) { |
339 | if (!view->swayc || !view->swayc->instructions->length) { | 349 | if (!view->swayc || !view->swayc->instructions->length) { |
340 | return view->surface->buffer->texture; | 350 | return view->surface->buffer->texture; |