Skip to content

Keep keyboard focus on the lock screen password field - #15362

Open
casmith wants to merge 2 commits into
omacom:quattrofrom
casmith:fix-lock-password-focus
Open

casmith wants to merge 2 commits into
omacom:quattrofrom
casmith:fix-lock-password-focus

Conversation

@casmith

@casmith casmith commented Oct 13, 2026 •

Copy link
Copy Markdown

The password field asked for focus once, when the lock surface was created. That's before the compositor gives the surface keyboard focus, so after locking (especially when the screen wakes up) typing went nowhere until you clicked the field. The field now takes focus when the surface gains keyboard focus, when something else takes focus from it, and after a password check finishes. It does this from events, with no timer.

Adds lock-password-focus-test.sh, which fails without the fix.

The field only took focus once, when the lock surface was created, before
the compositor had activated it, so typing went nowhere until a click.

Claude-Session: https://claude.ai/code/session_01XFh5eEKfnMU4nauT1rSfK3
@paulogeyer

Copy link
Copy Markdown
Contributor

I tested the open PRs for the lock screen password field losing focus (#6858, #14613, #12525) on my laptop. Each one was merged into current quattro and run through the same offscreen harness, which loads the real LockView.qml, takes focus away from the field, and checks whether it comes back.

PR focus dropped by the window (resume) focus moved inside the lock / wake from blank test
#15362 pass pass behavioural, fails on stock
#10944 pass pass source regex
#13907 pass pass source regex
#8560 pass pass source regex
#14882 pass fail / pass needs a compositor
#12435 pass fail / fail behavioural, fails on stock
#9523, #7164 fail fail refocus only when the lock is secured (#7164 conflicts)

I'd go with #15362. It passed every scenario, refocuses only while its lock surface is the active window (so other monitors don't retry), is the closest to quattro, and its fixture fails on stock. The others duplicate it. #13907 also passes, but its 100 ms retry timer keeps firing on every unfocused monitor for as long as the screen is locked.

Suggestion: add Fixes #6858 and Fixes #14613 so a merge closes them.

The harness can't reproduce the initial surface-activation race from #6858 offscreen, so a lid-close/resume check on real hardware is still worth doing before merging.

@omarchybot omarchybot added the bug Something isn't working label Oct 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks @casmith. Reviewed at b56650cc by Claude Opus 5.5 in Claude Code, with a second opinion from Codex at medium effort. This one is not the fix I'm recommending: #8560 does the same repair, was opened earlier, and covers a resume case this one can miss. So it is left with the maintainer.

What was checked. I read the diff against quattro and compared it with the other open pull requests for the same lost focus: #7164, #7471, #8560, #9523, #10944, #12435, #13907 and #14882. Nothing was run on a worker, because a fix that isn't the one recommended to land doesn't get one. When competing fixes are this close, the oldest one is preferred, and a newer one takes its place only if the older one misses a case or breaks something. #7164 and #9523 only refocus when the lock becomes secure, which doesn't happen again on resume. #7471's 100 ms retry keeps firing on every output whose lock surface doesn't hold the keyboard, for as long as the lock is up. #8560 reclaims focus whenever the field loses it (LockView.qml, onActiveFocusChanged), with no guard.

Where this one does less. restorePasswordFocus() (LockView.qml:96) only acts while Window.active is true. Codex traced a resume path through the QtWayland and Hyprland source where that never becomes true again. Suspend removes the keyboard, so Qt drops its focus window. The new keyboard then re-enters the same surface, and Qt ignores that because the surface is unchanged, so the window is never re-activated. Qt Quick still lets an item take focus while no window is focused, so #8560's unguarded forceActiveFocus() recovers there. Here, both handlers run and the guard rejects them, and it takes a click. That trace is Codex's, from reading the source. I haven't reproduced it, and a VM can't suspend. Going the other way, neither of us found a case on the real lock surface that this handles and #8560 misses. Qt hands focus back by itself when the field is re-enabled after a password check, and #8560 already covers focus moving to another item and focus lost when the window deactivates.

What this adds. The fixture in test/shell.d/fixtures/lock-password-focus/ drives real focus changes rather than matching source text, which is better than the test #8560 carries. I've passed it to #8560's review so it can be adapted there, with credit to you. The window-active guard shouldn't come across with it.

Next: waiting on the maintainer to choose between the competing fixes. You don't need to change anything here.

omarchybot added a commit to robouk/omarchy that referenced this pull request Oct 17, 2026
…g source

The regex test passed on a no-op handler and failed on a reformat. This hosts
the real LockView in a window and takes focus from the field the ways it is
lost: to another item, and dropped to the surface as on resume. It checks the
field takes it back each time, has it after a password check, and leaves it
alone while input is disabled. Adapted from the fixture in omacom#15362.

Co-Authored-By: Clay Smith <casmith@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mudiam

mudiam commented Oct 21, 2026

Copy link
Copy Markdown

Real-hardware lid-close/resume check, as suggested above: at b56650cc this does not fix the resume case on this machine (2/2 fail). A one-line log shows why, and it matches the source trace in the review: Window.active never comes back after resume, so restorePasswordFocus() is always rejected.

Machine: Lenovo ThinkPad P17 Gen 1, built-in keyboard (AT Translated Set 2 keyboard, removed by libinput on every suspend), NVIDIA Quadro T1000 only, S3 deep. Omarchy 4.0.6-1, Hyprland 0.56.2-4, quickshell 0.3.2.r7.g2b4501a-1, qt6-base 6.12.0-3, qt6-wayland 6.12.0-1.

Setup: the LockView.qml hunks applied cleanly to the shipped 4.0.6 file, which was the only lock change installed (stock Service.qml), followed by omarchy-restart-shell. For diagnosis I changed one line, with no behaviour change:

onWindowActiveChanged: { console.log("omarchy lock-test windowActive=" + windowActive + " fieldFocus=" + passwordInput.activeFocus); Qt.callLater(restorePasswordFocus) }

test/shell.d/lock-password-focus-test.sh passes on the PR head.

Procedure: lid close → wait ~10 s → open → wait ~3 s → type the password without clicking → wait ~10 s and type again → click only if that still fails.

Trace (identical both cycles, with sleeps of ~45 s and ~22 min):

lock-requested
lock-test windowActive=true  fieldFocus=true     # lock secured
PM: suspend entry (deep)
lock-test windowActive=false fieldFocus=false    # ~100 ms later: keyboard capability gone
PM: suspend exit
   (typing: nothing reaches the field; waiting and retyping: still nothing)
   (no windowActive=true is ever logged, not even after the click that made typing work)
unlocked

So after resume the window stays inactive for the rest of the lock. Both handlers fire only on the way down and are then rejected by the windowActive guard. The click works through forceActiveFocus on press while no window has focus, and doesn't re-activate the window either.

Same boot, same machine, same procedure, each fix tested on its own:

lid-close resume, type without clicking
stock 4.0.6 2/2 fail
#12435 2/2 pass
#15677 (backported to 4.0.6) 2/2 pass
this PR 2/2 fail

The offscreen harness above can't reach this path (as noted there), so on this hardware the behavioural fixture's "resume" pass doesn't carry over to a real suspend. The fixture is still useful, as the review says, minus the windowActive guard.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks @mudiam, that settles the open question from the earlier review. Re-read at b56650cc (unchanged) by Claude Opus 5.5 in Claude Code, with a second opinion from Codex at medium effort.

What changed. The resume failure in the earlier review was a source trace nobody had reproduced. The lid-close test above reproduces it on real hardware (2/2), and its log shows the mechanism the trace described: after resume Window.active never returns to true, so every call to restorePasswordFocus() (LockView.qml:96) is rejected by its windowActive guard and typing goes nowhere until a click. Both of us read the report against the diff and agree it fits the code. Nothing was run on a worker for this pass, since a VM cannot suspend.

What that means for the competing fixes. The recommendation is unchanged: #8560 is older and its forcePasswordFocus() is called without checking Window.active, so it does not have this blocker. Codex points out a gap worth closing before it lands: #8560 reclaims focus when the field loses it, which on this path happens as the machine goes to sleep, and nobody has yet shown on hardware that the focus survives resume. The report above tested #12435 and #15677 but not #8560. Neither #8560's fixture nor this one can reach the inactive lock-surface state, so a lid-close check of #8560 is the evidence still missing.

Next: waiting on the maintainer to choose between the competing fixes. Nothing is needed from you, @casmith.

@mudiam

mudiam commented Oct 21, 2026

Copy link
Copy Markdown

On the missing evidence for #8560: I ran that lid-close check about an hour before this review, on the same machine and boot with #8560 installed alone. It passes 2/2: focus is reclaimed ~85 ms into suspend, before the keyboard returns, and typing works after resume without a click. Trace and details: #8560 (comment)

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks @mudiam, that was the missing piece. Re-read at b56650cc (unchanged) by Claude Opus 5.5 in Claude Code, with a second opinion from Codex at medium effort.

What changed. The earlier review said nobody had yet run a lid-close check on #8560. Your report on #8560 (comment) covers that: 2/2 pass on the same machine where this one fails 2/2. Its trace fits the code. #8560 reclaims focus when the field loses it, without checking Window.active, so focus is back before suspend finishes and is still there after resume. Here, both handlers go through the windowActive guard at LockView.qml:96, so nothing reclaims focus after resume. Codex read the reports against both diffs separately and came to the same conclusion.

Your fixture. The behavioural test from this pull request is now in #8560 (commit f5009085, test/shell.d/fixtures/lock-focus-recovery/), with you credited as co-author. Codex found nothing else here that #8560 lacks. Nothing was run on a worker for this pass, since a VM cannot suspend.

Next: the recommendation is still #8560, and choosing between the competing fixes is up to the maintainer. Nothing is needed from you, @casmith.

rdoupe pushed a commit to omarchy-asus/omarchy that referenced this pull request Oct 24, 2026
…g source

The regex test passed on a no-op handler and failed on a reformat. This hosts
the real LockView in a window and takes focus from the field the ways it is
lost: to another item, and dropped to the surface as on resume. It checks the
field takes it back each time, has it after a password check, and leaves it
alone while input is disabled. Adapted from the fixture in omacom#15362.

Co-Authored-By: Clay Smith <casmith@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f500908)
rdoupe added a commit to omarchy-asus/omarchy-asus that referenced this pull request Oct 24, 2026
…eld keeps the keyboard after a suspend or a wrong password (general-0003) (#297)

After a suspend and resume, and after a wrong password, the native lock's
password field had no keyboard focus: typing did nothing until the field
was clicked. The field only took focus when the lock view was built and
when inputEnabled changed, and inputEnabled stays true across a suspend.
While a password is checked the field is disabled, and Qt gives focus
back to the re-enabled field only if nothing else took it meanwhile.

- general-0003, the same in both recipes, from fork asus/v4-5-0-rc1
  (28a967beb..c5887be86, upstream's four commits, squashed): the field
  takes focus back whenever it loses it while the lock takes input, and
  once a password check ends. The preview, built with input disabled, is
  left alone.
- It is omacom/omarchy#8560 (head 39691c1e) as is, for
  omacom/omarchy#9180: upstream's triage recommends it, and it is the one
  open fix with a lid close and resume passing on hardware.
  omacom/omarchy#15362 (refocus on Window.active) failed on resume and is
  not used.
- Its lock-focus-recovery-test.sh fails 5 of 6 checks without the patch
  and passes with it.
- In the general- series: the bug is stock Omarchy's, not the hardware's.
- pkgrel 1.108 in both recipes; sha256sums, DELTA and NOTES.md updated.

Fixes #295

Co-authored-by: rdoupe <1207041+rdoupe@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants