layer: update pointer focus on unmap

Ensure that pointer focus is restored to the surface below when a layer
surface or popup is unmapped. Can be tested like below:

1. Open a terminal and move the cursor over it so it becomes an I-beam
2. Open a launcher (e.g. fuzzel) so the cursor becomes an arrow
3. Close the launcher
4. The cursor should become an I-beam again

Note: this commit restores `cursor_update_focus()` in
`handle_popup_destroy()` which was removed in bdbb1be3. I don't remember
why it was removed.
This commit is contained in:
tokyo4j 2026-02-22 18:30:01 +09:00 committed by Johan Malm
parent bdbb1be35a
commit b4e1c256f8

View file

@ -378,6 +378,7 @@ handle_unmap(struct wl_listener *listener, void *data)
if (seat->focused_layer == layer_surface) {
try_to_focus_next_layer_or_toplevel(layer->server);
}
cursor_update_focus(layer->server);
layer->being_unmapped = false;
}
@ -454,6 +455,7 @@ handle_popup_destroy(struct wl_listener *listener, void *data)
wl_list_remove(&popup->commit.link);
}
/* TODO: do this on unmap instead? */
if (surface_is_focused(seat, popup->wlr_popup->base->surface)) {
/* Give focus back to whoever had it before the popup */
if (popup->parent_was_focused && popup->wlr_popup->parent) {
@ -462,6 +464,7 @@ handle_popup_destroy(struct wl_listener *listener, void *data)
desktop_focus_topmost_view(popup->server);
}
}
cursor_update_focus(popup->server);
free(popup);
}