]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xwayland.c: Fix positioning with multiple queued configure events
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 25 Feb 2022 20:31:21 +0000 (21:31 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 25 Feb 2022 21:51:40 +0000 (21:51 +0000)
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.

include/labwc.h
src/xwayland.c

index bee3607f9fe3c1ab1be3e27f9d71b1d43a53f833..38bebc40d12c6559665af7b4976edae26f1e8f26 100644 (file)
@@ -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;
index ddbff726d5d440808ddf0a974a116e9ffd68c9a4..1dfb574a312547d4b8086c12bf491df0c70fdec9 100644 (file)
@@ -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