From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Fri, 25 Feb 2022 20:31:21 +0000 (+0100) Subject: xwayland.c: Fix positioning with multiple queued configure events X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=5f62f2ba9993d46510e09ff088a9c8acdef26c52;p=proto%2Flabwc.git xwayland.c: Fix positioning with multiple queued configure events Prevents a single action like ToggleDecorations + ToggleMaximize to position the view somewhere with negative coordinates when unmaximizing. It may still position the view on negative coordinates but later commit events will fix the position. This issue only exists on xwayland because there are no configure serials which we could use to ignore all repositioning until we are at the latest desired state. --- diff --git a/include/labwc.h b/include/labwc.h index bee3607f..38bebc40 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -274,7 +274,7 @@ struct view { */ struct border padding; - struct { + struct view_pending_move_resize { bool update_x, update_y; double x, y; uint32_t width, height; diff --git a/src/xwayland.c b/src/xwayland.c index ddbff726..1dfb574a 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -10,27 +10,37 @@ handle_commit(struct wl_listener *listener, void *data) assert(view->surface); /* Must receive commit signal before accessing surface->current* */ - view->w = view->surface->current.width; - view->h = view->surface->current.height; - bool move_pending = view->pending_move_resize.update_x - || view->pending_move_resize.update_y; - - if (view->pending_move_resize.update_x) { - view->x = view->pending_move_resize.x + - view->pending_move_resize.width - view->w; - view->pending_move_resize.update_x = false; + struct wlr_surface_state *state = &view->surface->current; + struct view_pending_move_resize *pending = &view->pending_move_resize; + + bool move_pending = pending->update_x || pending->update_y; + bool size_changed = view->w != state->width || view->h != state->height; + + if (!move_pending && !size_changed) { + return; } - if (view->pending_move_resize.update_y) { - view->y = view->pending_move_resize.y + - view->pending_move_resize.height - view->h; - view->pending_move_resize.update_y = false; + + view->w = state->width; + view->h = state->height; + + if (pending->update_x) { + /* Adjust x for queued up configure events */ + view->x = pending->x + pending->width - view->w; + } + if (pending->update_y) { + /* Adjust y for queued up configure events */ + view->y = pending->y + pending->height - view->h; } if (move_pending) { wlr_scene_node_set_position(&view->scene_tree->node, view->x, view->y); } + if ((int)pending->width == view->w && (int)pending->height == view->h) { + /* We reached the end of all queued size changing configure events */ + pending->update_x = false; + pending->update_y = false; + } ssd_update_geometry(view); - damage_view_whole(view); } static void