Repository navigation
Reclaim lock screen keyboard focus after resume from suspend - #12435
jonathan-downs wants to merge 1 commit into
Conversation
|
Tested this on my machine and it fixes the issue: after suspend/resume the lock screen password field accepts typing immediately, no click on the screen needed first. Suspend via lid close, resume, type password — works on the first try. Thanks for tracking this down. |
|
hey, this is already covered in #12894 (lock keyboard focus after lid-open / resume). mind closing this as a duplicate? |
Suspend can remove every keyboard. When the seat loses its keyboard, Qt's Wayland backend drops its focus window, which clears the password field's focus. When the keyboard comes back, the compositor re-enters the lock surface, but Qt still records that surface as focused and never re-activates the window, so typing is dropped until the screen is clicked. Take focus back as soon as the lock window's focus item is cleared. Qt only turns that into active focus while no other window has focus, so it cannot pull focus away from another monitor's lock surface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e4fab87 to
21025d3
Compare
|
Hitting this on every resume here too. Data point in case it helps review: Setup: Omarchy 4.0.4, Hyprland 0.56.2, Quickshell 0.3.1, kernel 7.2.5-3-omarchy, Razer Blade 15 (2022), Intel iGPU driving the internal panel + NVIDIA dGPU (open 610.57.04). Repro: lock screen comes up before sleep (lid close). Happens after both deep (S3) suspend and hibernate. After resume the field looks ready, but typing does nothing until the field is clicked. What I tried from outside the lock surface after
That points at the Qt side, as this PR describes: the compositor-level focus looks fine, and the window's focus item just never comes back. It would be great to see this merged. This comment was written by Claude Code (Anthropic's AI assistant) while it helped me debug this on my machine. The tests and log results above are from my system. |
|
Reviewed at 21025d3 by Claude Opus 5.5 in Claude Code, with a second opinion from Codex at medium effort. Neither found a defect in the change, and it now carries Reproduced on a worker. On a disposable VM with a real compositor serving this branch, Tests. On the same worker: Competing fixes. #8560, #7592, #10944 and #7164 are open against the same bug. #8560 does the same repair from the password field's Where it stands. Waiting on the maintainer, who has to choose between this and #8560. Nothing is left for you to do. It is not |
|
Still needed — #12894 was closed without merge, so this isn't covered yet. Same resume/lock-focus cluster as #9180 / #14882 / #13907 / #10944 / #8560 / #6858. This head has a focused reclaim + test and omarchybot verified it; merge is clean. Suggest picking one implementation from the cluster and closing the rest. |
|
Tested on real hardware with a before/after comparison on the same boot. It fixes the bug here, including on Qt 6.12 (the analysis above was against 6.11.2). Machine: Lenovo ThinkPad P17 Gen 1, built-in keyboard ( Trigger confirmed: the Hyprland log shows Setup: the PR's
The PR cycles covered a short (~27s) and a long (~22 min) sleep. Typing was done a few seconds after lid-open, once input was back. Not tested: multi-monitor (single internal panel here), fingerprint (no reader enrolled), and #12438's numpad state. |
|
@celestial-fix added another matching real-hardware trace on #14067: Dell Inspiron, s2idle, secure lock surface, no PAM conversation before the click, and the keyboard is removed and re-added across the seat transition while pointer input still works. Full evidence: #14067 (comment) One useful addition is that a locked VT round-trip produced the same symptom. That may be a cheaper way to exercise this focus-loss path than a lid-close suspend. They have not isolated that trigger yet, so I would treat it as a reproduction lead rather than confirmed coverage. |
|
@celestial-fix has now tested this PR on the Dell Inspiron from #14067. With the patched lock plugin applied, lid-close suspend and resume accepted password input immediately without a click and unlocked normally. That moves their earlier trace from a matching reproduction to direct real-hardware confirmation of this fix. Full result: #14067 (comment) |
|
Adding an archived VM before/after result for Stack: Omarchy 4.0.6-1, packaged Hyprland 0.56.2-4, Quickshell 0.3.2.r7.g2b4501a-1, qt6-base 6.12.0-3, qt6-wayland 6.12.0-1, UWSM 0.27.1-1, QEMU/KVM, one output. The native-lock sequence was:
An ordinary FloatingWindow/TextInput control passed across the same kind of VT round trip even when the native lock failed, so a generic text-input fixture would have missed this regression. This is corroboration for the native lock fix. A separate retained-SDDM-greeter/direct-VT input problem remained unresolved in the wider multi-user experiment. Physical multiple monitors and fingerprint hardware were not tested, and this is not a complete aggregate-suite signoff. The VM experiment has now ended. |
|
@theswampdawg Thanks for preserving this. The controlled shipped-versus- |
|
Re-checked at 21025d3 by Claude Opus 5.5 in Claude Code, with second opinions from Codex at medium effort and muse-wonder via pi at high thinking. The branch no longer merges into
This PR still covers one case What ran. On a disposable VM with a real compositor, I put your
Nothing was pushed to your branch, and the suite was not run on it, because it does not merge. What else is still open. #8560, #10944 and #7164 are still open against the same bug. Apart from the password-check case, this PR now adds only the regression test. The reviewers noted three things about that test. Its preview and password-check steps pass whichever handler is present, so they do not check the handler. It uses its own launcher where Waiting on the maintainer. They need to decide whether the password-check case and the test are worth keeping on top of #17277. If they are, resolving the conflict means choosing how this handler and #17277's fit together. Otherwise this can be closed as fixed by #17277. Nothing is needed from you until then. |
Summary
After lid-close suspend and resume, the lock screen shows the password field, but typing does nothing until the screen is clicked. A plain lock with no suspend is unaffected.
Root cause. The field loses focus inside Qt; the compositor side is fine:
device removedline for each one, and 18 keyboard adds across 17 suspends in one boot.wl_keyboard. Qt's destructor clears the application's focus window directly (qwaylandinputdevice.cpp), soQQuickWindow::focusOutEventclears the password field's focus.wl_keyboard, and Hyprland sendsenterfor the lock surface that is still focused (Seat.cpp). ButQWaylandDisplay::handleKeyboardFocusChangedstill records that surface as the last keyboard focus and returns early (qwaylanddisplay.cpp). The window is never re-activated: keys reach it, but no item has focus to receive them.forceActiveFocus()is honoured while no window has focus (qquickdeliveryagent.cpp).Fix.
LockViewtakes focus back whenever its window's active focus item is cleared while input is enabled. That is the exact state the bug leaves behind, so no resume detection is needed. It should also cover other ways every keyboard can disappear while locked, such as unplugging a desktop's only USB keyboard (untested). When another lock surface has focus,forceActiveFocus()only records the field as its window's focus item, so focus never moves between monitors.Changes from the earlier version of this PR. That version watched logind's
PrepareForSleepthrough a new systemd user service and poked the shell over IPC on each resume. It worked because the IPC call ran the sameforceActiveFocus()a click does, but it tied the fix to resume events instead of the focus loss itself. It also added a script, a unit, an IPC verb and a seconddbus-monitor, and without a migration it would never have been enabled on existing installs. All of that is gone.Related
enterfor the newly bound keyboard is not followed by amodifiersevent, which thewl_keyboard.enterspec requires, so Qt's fresh keymap state has Num Lock off. That is a Hyprland bug and is not addressed here.hyprctl reloadon the docked clamshell path. On an undocked laptop that path never reloads, so it does not cover this case.Test plan
test/shell.d/lock-focus-reclaim-test.sh: drops the lock window's focus the wayQQuickWindow::focusOutEventdoes and checks that the password field takes it back. It also checks that the preview view (input disabled) never takes focus, and that focus returns after a password check disables and re-enables the field. It fails without the fix and passes with it.lock-password-overflow,lock-fingerprint-indicator,lock-blank-fingerprint,lock-stranded-recovery,video-background,owe-integration./test/clipasses./test/shellpasses except for 5 files that fail identically on a cleanquattrocheckout on this machine, because it lacks anomarchy-pkgscheckout andomasnap:config,kernel-headers-migration,screenshot-sanity,snapper,unowned-system-paths🤖 Generated with Claude Code
Fixes #12525
Fixes #14067