From 625127d5d376848fae4dc12eec5b2225d1a0ca3a Mon Sep 17 00:00:00 2001 From: ookami Date: Wed, 13 Nov 2024 16:02:04 +0800 Subject: [PATCH] Fix cursor events on lock/unlock See https://github.com/labwc/labwc/pull/1858 Delay refocus operations because only the role-specific surface commit/map handler has been processed in wlroots at this moment and node_at_coords returns the WLR_SCENE_NODE_RECT as a buffer has not been actually attached to the surface. --- sway/lock.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sway/lock.c b/sway/lock.c index 43f31330..168d469a 100644 --- a/sway/lock.c +++ b/sway/lock.c @@ -59,7 +59,8 @@ static void refocus_output(struct sway_session_lock_output *output) { } } -static void handle_surface_map(struct wl_listener *listener, void *data) { +static void update_focus(void *data) { + struct wl_listener *listener = data; struct sway_session_lock_output *surf = wl_container_of(listener, surf, surface_map); if (surf->lock->focused == NULL) { focus_surface(surf->lock, surf->surface->surface); @@ -67,6 +68,10 @@ static void handle_surface_map(struct wl_listener *listener, void *data) { cursor_rebase_all(); } +static void handle_surface_map(struct wl_listener *listener, void *data) { + wl_event_loop_add_idle(server.wl_event_loop, update_focus, listener); +} + static void handle_surface_destroy(struct wl_listener *listener, void *data) { struct sway_session_lock_output *output = wl_container_of(listener, output, surface_destroy); @@ -234,6 +239,7 @@ static void handle_unlock(struct wl_listener *listener, void *data) { struct sway_output *output = root->outputs->items[i]; arrange_layers(output); } + cursor_rebase_all(); } static void handle_abandon(struct wl_listener *listener, void *data) {