From 97ac960feebc552437fc2b536874671163b747ce Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Mon, 28 Aug 2023 16:43:51 +0200 Subject: [PATCH] src/cursor: ensure interactive move/resize ends correctly for CSD clients 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 | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/cursor.c b/src/cursor.c index 38323a02..f6f8b1d7 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -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; }