From cff7a88bda6b0b341df69820c6a40b4d1ab4a6ce Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Sat, 30 May 2026 23:01:28 +0800 Subject: [PATCH] layer_shell: fix reversed precedence check in handle_map When a new layer surface maps, Sway determines if it should steal focus by comparing its layer level against the currently focused layer. The previous check used `focused >= new` to determine whether to switch focus to new, which allowed lower precedence layers to steal focus from higher ones. This latent issue was masked by arrange_layers() coming through and fixing up the focus state afterwards. However it resulted in a focus "flicker" where layer-shell surfaces briefly lost focus before having it restored again almost immediately. This commit changes the comparison to `<=` so that lower precedence surfaces do not steal focus from higher precedence surfaces, and there is no focus flicker. --- sway/desktop/layer_shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index c8f485971..268c355c2 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -291,7 +291,7 @@ static void handle_map(struct wl_listener *listener, void *data) { wl_list_for_each(seat, &server.input->seats, link) { // but only if the currently focused layer has a lower precedence if (!seat->focused_layer || - seat->focused_layer->current.layer >= layer_surface->current.layer) { + seat->focused_layer->current.layer <= layer_surface->current.layer) { seat_set_focus_layer(seat, layer_surface); } }