aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar Tudor Brindus <me@tbrindus.ca>2020-10-18 16:26:01 -0400
committerLibravatar Simon Ser <contact@emersion.fr>2020-10-18 22:37:42 +0200
commit8355884fbd4ea04203614172424b27c5b74018ab (patch)
treec7decf05e32202d1230924a7ddb5af6dd903016c /sway/desktop
parenttransaction: don't reconfigure X views unless integral coords changed (diff)
downloadsway-8355884fbd4ea04203614172424b27c5b74018ab.tar.gz
sway-8355884fbd4ea04203614172424b27c5b74018ab.tar.zst
sway-8355884fbd4ea04203614172424b27c5b74018ab.zip
transaction: validate X transaction completions by geometry, not size
Xwayland views are aware of their coordinates, so validating transaction completions should take into account the reported coordinates of the view. Prior to this commit they didn't, and matching dimensions would suffice to validate the transaction. Also introduced `transaction_notify_view_ready_immediately` to support the fix from d0f7e0f without jumping through hoops to figure out the geometry of an `xdg_shell` view.
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/transaction.c14
-rw-r--r--sway/desktop/xdg_shell.c3
-rw-r--r--sway/desktop/xwayland.c8
3 files changed, 17 insertions, 8 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 0d0e0635..e186bf89 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -510,17 +510,27 @@ void transaction_notify_view_ready_by_serial(struct sway_view *view,
510 } 510 }
511} 511}
512 512
513void transaction_notify_view_ready_by_size(struct sway_view *view, 513void transaction_notify_view_ready_by_geometry(struct sway_view *view,
514 int width, int height) { 514 double x, double y, int width, int height) {
515 struct sway_transaction_instruction *instruction = 515 struct sway_transaction_instruction *instruction =
516 view->container->node.instruction; 516 view->container->node.instruction;
517 if (instruction != NULL && 517 if (instruction != NULL &&
518 (int)instruction->container_state.content_x == (int)x &&
519 (int)instruction->container_state.content_y == (int)y &&
518 instruction->container_state.content_width == width && 520 instruction->container_state.content_width == width &&
519 instruction->container_state.content_height == height) { 521 instruction->container_state.content_height == height) {
520 set_instruction_ready(instruction); 522 set_instruction_ready(instruction);
521 } 523 }
522} 524}
523 525
526void transaction_notify_view_ready_immediately(struct sway_view *view) {
527 struct sway_transaction_instruction *instruction =
528 view->container->node.instruction;
529 if (instruction != NULL) {
530 set_instruction_ready(instruction);
531 }
532}
533
524void transaction_commit_dirty(void) { 534void transaction_commit_dirty(void) {
525 if (!server.dirty_nodes->length) { 535 if (!server.dirty_nodes->length) {
526 return; 536 return;
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 03f37241..4d133a12 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -302,8 +302,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
302 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); 302 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
303 desktop_damage_view(view); 303 desktop_damage_view(view);
304 transaction_commit_dirty(); 304 transaction_commit_dirty();
305 transaction_notify_view_ready_by_size(view, 305 transaction_notify_view_ready_immediately(view);
306 new_geo.width, new_geo.height);
307 } else { 306 } else {
308 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); 307 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
309 } 308 }
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index cee0ab10..186502b2 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -401,8 +401,8 @@ static void handle_commit(struct wl_listener *listener, void *data) {
401 401
402 if (view->container->node.instruction) { 402 if (view->container->node.instruction) {
403 get_geometry(view, &view->geometry); 403 get_geometry(view, &view->geometry);
404 transaction_notify_view_ready_by_size(view, 404 transaction_notify_view_ready_by_geometry(view,
405 state->width, state->height); 405 xsurface->x, xsurface->y, state->width, state->height);
406 } else { 406 } else {
407 struct wlr_box new_geo; 407 struct wlr_box new_geo;
408 get_geometry(view, &new_geo); 408 get_geometry(view, &new_geo);
@@ -418,8 +418,8 @@ static void handle_commit(struct wl_listener *listener, void *data) {
418 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); 418 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
419 desktop_damage_view(view); 419 desktop_damage_view(view);
420 transaction_commit_dirty(); 420 transaction_commit_dirty();
421 transaction_notify_view_ready_by_size(view, 421 transaction_notify_view_ready_by_geometry(view,
422 new_geo.width, new_geo.height); 422 xsurface->x, xsurface->y, new_geo.width, new_geo.height);
423 } else { 423 } else {
424 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); 424 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
425 } 425 }