diff options
author | 2021-02-21 18:18:35 +0100 | |
---|---|---|
committer | 2021-02-23 19:38:05 +0100 | |
commit | 35b9a41720e04bd7c74e81e0a63ee69d540f39e1 (patch) | |
tree | ad6c57aa7291ea577c1a58ec461ece8bec222648 | |
parent | Fix wl_shm_format passed to wlr_texture_from_pixels (diff) | |
download | sway-35b9a41720e04bd7c74e81e0a63ee69d540f39e1.tar.gz sway-35b9a41720e04bd7c74e81e0a63ee69d540f39e1.tar.zst sway-35b9a41720e04bd7c74e81e0a63ee69d540f39e1.zip |
transaction: Note if instructions are server requests
On server request, we need to send configure events to inform the client
of the new intended size. If the client changes size itself, sending a
configure event will only cause problems.
Use transaction_commit_dirty_client to distinguish between the two
transaction causes.
-rw-r--r-- | include/sway/desktop/transaction.h | 6 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 21 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 3 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 2 |
4 files changed, 26 insertions, 6 deletions
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h index 175489c5..af28169e 100644 --- a/include/sway/desktop/transaction.h +++ b/include/sway/desktop/transaction.h | |||
@@ -28,6 +28,12 @@ struct sway_view; | |||
28 | */ | 28 | */ |
29 | void transaction_commit_dirty(void); | 29 | void transaction_commit_dirty(void); |
30 | 30 | ||
31 | /* | ||
32 | * Same as transaction_commit_dirty, but signalling that this is a | ||
33 | * client-initiated change has already taken effect. | ||
34 | */ | ||
35 | void transaction_commit_dirty_client(void); | ||
36 | |||
31 | /** | 37 | /** |
32 | * Notify the transaction system that a view is ready for the new layout. | 38 | * Notify the transaction system that a view is ready for the new layout. |
33 | * | 39 | * |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 57311fe2..21915207 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -35,6 +35,7 @@ struct sway_transaction_instruction { | |||
35 | struct sway_container_state container_state; | 35 | struct sway_container_state container_state; |
36 | }; | 36 | }; |
37 | uint32_t serial; | 37 | uint32_t serial; |
38 | bool server_request; | ||
38 | bool waiting; | 39 | bool waiting; |
39 | }; | 40 | }; |
40 | 41 | ||
@@ -165,7 +166,7 @@ static void copy_container_state(struct sway_container *container, | |||
165 | } | 166 | } |
166 | 167 | ||
167 | static void transaction_add_node(struct sway_transaction *transaction, | 168 | static void transaction_add_node(struct sway_transaction *transaction, |
168 | struct sway_node *node) { | 169 | struct sway_node *node, bool server_request) { |
169 | struct sway_transaction_instruction *instruction = NULL; | 170 | struct sway_transaction_instruction *instruction = NULL; |
170 | 171 | ||
171 | // Check if we have an instruction for this node already, in which case we | 172 | // Check if we have an instruction for this node already, in which case we |
@@ -188,9 +189,12 @@ static void transaction_add_node(struct sway_transaction *transaction, | |||
188 | } | 189 | } |
189 | instruction->transaction = transaction; | 190 | instruction->transaction = transaction; |
190 | instruction->node = node; | 191 | instruction->node = node; |
192 | instruction->server_request = server_request; | ||
191 | 193 | ||
192 | list_add(transaction->instructions, instruction); | 194 | list_add(transaction->instructions, instruction); |
193 | node->ntxnrefs++; | 195 | node->ntxnrefs++; |
196 | } else if (server_request) { | ||
197 | instruction->server_request = true; | ||
194 | } | 198 | } |
195 | 199 | ||
196 | switch (node->type) { | 200 | switch (node->type) { |
@@ -364,6 +368,9 @@ static bool should_configure(struct sway_node *node, | |||
364 | if (node->destroying) { | 368 | if (node->destroying) { |
365 | return false; | 369 | return false; |
366 | } | 370 | } |
371 | if (!instruction->server_request) { | ||
372 | return false; | ||
373 | } | ||
367 | struct sway_container_state *cstate = &node->sway_container->current; | 374 | struct sway_container_state *cstate = &node->sway_container->current; |
368 | struct sway_container_state *istate = &instruction->container_state; | 375 | struct sway_container_state *istate = &instruction->container_state; |
369 | #if HAVE_XWAYLAND | 376 | #if HAVE_XWAYLAND |
@@ -522,7 +529,7 @@ void transaction_notify_view_ready_immediately(struct sway_view *view) { | |||
522 | } | 529 | } |
523 | } | 530 | } |
524 | 531 | ||
525 | void transaction_commit_dirty(void) { | 532 | static void _transaction_commit_dirty(bool server_request) { |
526 | if (!server.dirty_nodes->length) { | 533 | if (!server.dirty_nodes->length) { |
527 | return; | 534 | return; |
528 | } | 535 | } |
@@ -536,10 +543,18 @@ void transaction_commit_dirty(void) { | |||
536 | 543 | ||
537 | for (int i = 0; i < server.dirty_nodes->length; ++i) { | 544 | for (int i = 0; i < server.dirty_nodes->length; ++i) { |
538 | struct sway_node *node = server.dirty_nodes->items[i]; | 545 | struct sway_node *node = server.dirty_nodes->items[i]; |
539 | transaction_add_node(server.pending_transaction, node); | 546 | transaction_add_node(server.pending_transaction, node, server_request); |
540 | node->dirty = false; | 547 | node->dirty = false; |
541 | } | 548 | } |
542 | server.dirty_nodes->length = 0; | 549 | server.dirty_nodes->length = 0; |
543 | 550 | ||
544 | transaction_commit_pending(); | 551 | transaction_commit_pending(); |
545 | } | 552 | } |
553 | |||
554 | void transaction_commit_dirty(void) { | ||
555 | _transaction_commit_dirty(true); | ||
556 | } | ||
557 | |||
558 | void transaction_commit_dirty_client(void) { | ||
559 | _transaction_commit_dirty(false); | ||
560 | } | ||
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 4c13f91f..0ac2c55d 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -298,8 +298,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
298 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); | 298 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); |
299 | if (container_is_floating(view->container)) { | 299 | if (container_is_floating(view->container)) { |
300 | view_update_size(view); | 300 | view_update_size(view); |
301 | transaction_commit_dirty(); | 301 | transaction_commit_dirty_client(); |
302 | transaction_notify_view_ready_immediately(view); | ||
303 | } else { | 302 | } else { |
304 | view_center_surface(view); | 303 | view_center_surface(view); |
305 | } | 304 | } |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 3ed65083..5c3a39ea 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -413,7 +413,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
413 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); | 413 | memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); |
414 | if (container_is_floating(view->container)) { | 414 | if (container_is_floating(view->container)) { |
415 | view_update_size(view); | 415 | view_update_size(view); |
416 | transaction_commit_dirty(); | 416 | transaction_commit_dirty_client(); |
417 | } else { | 417 | } else { |
418 | view_center_surface(view); | 418 | view_center_surface(view); |
419 | } | 419 | } |