layer: do not focus on-demand clients in commit-handler

...because we should only try to focus them as part of normal input
handling semantics, for example when receiving a cursor-button-press.
This commit is contained in:
Johan Malm 2024-03-16 20:58:00 +00:00 committed by Johan Malm
parent e67e8d6ed0
commit 6990ff713b

View file

@ -228,6 +228,13 @@ layer_try_set_focus(struct seat *seat, struct wlr_layer_surface_v1 *layer_surfac
} }
} }
static bool
is_on_demand(struct wlr_layer_surface_v1 *layer_surface)
{
return layer_surface->current.keyboard_interactive ==
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND;
}
static void static void
handle_surface_commit(struct wl_listener *listener, void *data) handle_surface_commit(struct wl_listener *listener, void *data)
{ {
@ -252,9 +259,28 @@ handle_surface_commit(struct wl_listener *listener, void *data)
} }
/* Process keyboard-interactivity change */ /* Process keyboard-interactivity change */
if (committed & WLR_LAYER_SURFACE_V1_STATE_KEYBOARD_INTERACTIVITY) { if (committed & WLR_LAYER_SURFACE_V1_STATE_KEYBOARD_INTERACTIVITY) {
/*
* On-demand interactivity should only be honoured through
* normal focus semantics (for example by surface receiving
* cursor-button-press).
*/
if (is_on_demand(layer_surface)) {
struct seat *seat = &layer->server->seat;
if (seat->focused_layer == layer_surface) {
/*
* Must be change from EXCLUSIVE to ON_DEMAND,
* so we should give us focus.
*/
struct server *server = layer->server;
try_to_focus_next_layer_or_toplevel(server);
}
goto out;
}
/* Handle EXCLUSIVE and NONE requests */
struct seat *seat = &layer->server->seat; struct seat *seat = &layer->server->seat;
layer_try_set_focus(seat, layer_surface); layer_try_set_focus(seat, layer_surface);
} }
out:
if (committed || layer->mapped != layer_surface->surface->mapped) { if (committed || layer->mapped != layer_surface->surface->mapped) {
layer->mapped = layer_surface->surface->mapped; layer->mapped = layer_surface->surface->mapped;