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.
This commit is contained in:
ookami 2024-11-13 16:02:04 +08:00 committed by ookami
parent 5312376077
commit 625127d5d3

View file

@ -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) {