From 8fde769b788bee6462ad7d2b83bc0f78a136e2ed Mon Sep 17 00:00:00 2001 From: dvh Date: Wed, 11 Nov 2026 10:07:16 +0100 Subject: [PATCH] don't give the keyboard back to a lock surface being destroyed wlroots still lists the lock surface being destroyed, and inserts new ones at the head, so when the focused surface was the newest one, destroylocksurface() gave the focus back to it and then nothing had it: the password could not be typed until an output changed. Happens e.g. when unplugging a monitor while locked with waylock. --- dwl.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dwl.c b/dwl.c index 6dbcebb..921f353 100644 --- a/dwl.c +++ b/dwl.c @@ -1512,14 +1512,21 @@ destroylocksurface(struct wl_listener *listener, void *data) if (lock_surface->surface != seat->keyboard_state.focused_surface) return; - if (locked && cur_lock && !wl_list_empty(&cur_lock->surfaces)) { - surface = wl_container_of(cur_lock->surfaces.next, surface, link); - client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat)); - } else if (!locked) { + if (!locked) { focusclient(focustop(selmon), NULL, 1); - } else { - wlr_seat_keyboard_clear_focus(seat); + return; } + + /* The surface being destroyed is still in the list */ + if (cur_lock) { + wl_list_for_each(surface, &cur_lock->surfaces, link) { + if (surface != lock_surface) { + client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat)); + return; + } + } + } + wlr_seat_keyboard_clear_focus(seat); } void