]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/cursor: ensure interactive move/resize ends correctly for CSD clients
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 28 Aug 2023 14:43:51 +0000 (16:43 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 10 Sep 2023 15:49:54 +0000 (16:49 +0100)
Before this patch, when moving a CSD client below a layershell surface -
like a panel that was configured with either the "top" or "overlay"
layers - we'd only send a matching release button event to the client but
not actually end the interactive move operation. That caused the drag to
continue even though the user already released the mouse button.

In comparison, SSD clients were not suffering from the same issue because
the initial mouse "down" event was not attached to any client surface and
thus it would not take the first early return because there was no surface
attached to the release event.

This patch fixes the issue by reordering the conditions where we return
early. It also ensures that when we finish the move, we still send the
release event to CSD clients.

Fixes: #1053
Reported-by: @DynamoFox (thanks)
src/cursor.c

index 38323a0236189522a49413d372dc5af784dbe2b4..f6f8b1d70cfbeb5f44465fb4019621e17798f850 100644 (file)
@@ -300,8 +300,7 @@ update_pressed_surface(struct seat *seat, struct cursor_context *ctx)
         * context menus (in contrast) do not use an XDG popup grab and
         * do not work properly if we send leave/enter events.
         */
-       if (seat->seat->pointer_state.grab ==
-                       seat->seat->pointer_state.default_grab) {
+       if (!wlr_seat_pointer_has_grab(seat->seat)) {
                return false;
        }
        if (seat->pressed.surface && ctx->surface != seat->pressed.surface) {
@@ -960,16 +959,6 @@ cursor_button_release(struct seat *seat, struct wlr_pointer_button_event *event)
 
        seat_reset_pressed(seat);
 
-       if (pressed_surface && ctx.surface != pressed_surface) {
-               /*
-                * Button released but originally pressed over a different surface.
-                * Just send the release event to the still focused surface.
-                */
-               wlr_seat_pointer_notify_button(seat->seat, event->time_msec,
-                       event->button, event->state);
-               return;
-       }
-
        if (server->input_mode == LAB_INPUT_STATE_MENU) {
                if (close_menu) {
                        menu_close_root(server);
@@ -983,6 +972,22 @@ cursor_button_release(struct seat *seat, struct wlr_pointer_button_event *event)
        if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
                /* Exit interactive move/resize mode */
                interactive_finish(server->grabbed_view);
+
+               if (pressed_surface) {
+                       /* Ensure CSD clients see the release event */
+                       wlr_seat_pointer_notify_button(seat->seat, event->time_msec,
+                               event->button, event->state);
+               }
+               return;
+       }
+
+       if (pressed_surface && ctx.surface != pressed_surface) {
+               /*
+                * Button released but originally pressed over a different surface.
+                * Just send the release event to the still focused surface.
+                */
+               wlr_seat_pointer_notify_button(seat->seat, event->time_msec,
+                       event->button, event->state);
                return;
        }