From 311ccfbdd94d69918b62af0cf816f951aa28963c Mon Sep 17 00:00:00 2001 From: lkn Date: Tue, 23 Jun 2026 13:41:28 +0200 Subject: [PATCH] fix drag freeze/crash: implicit grab with motion delivery Preserve pointer focus while buttons are held (implicit grab) to ensure the client gets the release. Still deliver motion events to the focused surface so drag and text selection work correctly. --- src/backend/wayland/wl_pointer_focus.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/backend/wayland/wl_pointer_focus.c b/src/backend/wayland/wl_pointer_focus.c index e17dfcd..c0af0a7 100644 --- a/src/backend/wayland/wl_pointer_focus.c +++ b/src/backend/wayland/wl_pointer_focus.c @@ -124,6 +124,20 @@ wl_update_pointer_focus(uint32_t time_msec) if (!wl_state.seat) return; + /* Preserve implicit grab: don't change focus while buttons are held. + * Still deliver motion to the focused surface for drag/selection. */ + if (wl_state.seat->pointer_state.button_count > 0) { + struct wlr_surface *focused = wl_state.seat->pointer_state.focused_surface; + if (focused) { + double sx, sy; + struct wl_toplevel_view *v = NULL; + view_surface_at(wl_state.pointer_x, wl_state.pointer_y, &sx, &sy, &v); + wlr_seat_pointer_notify_motion(wl_state.seat, time_msec, sx, sy); + wlr_seat_pointer_notify_frame(wl_state.seat); + } + return; + } + double sx, sy; struct wl_toplevel_view *view = NULL; struct wlr_surface *surface = NULL;