Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Restores password-field focus when the compositor takes focus during lock activation.
Changes:
- Detects lost active focus while input is enabled.
- Defers reclaiming password focus through
Qt.callLater.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| onActiveFocusChanged: { | ||
| if (!activeFocus && root.inputEnabled) Qt.callLater(root.forcePasswordFocus) | ||
| } |
There was a problem hiding this comment.
The fixtures exist, but they cannot assert activeFocus. Both lock-password-overflow and lock-fingerprint-indicator host LockView in a windowless Item, and Qt only propagates activeFocus from an active window. I checked against a live quickshell: after forcePasswordFocus(), focus is true and activeFocus is false. So onActiveFocusChanged never fires there and the suggested test would pass without exercising anything.
Getting real focus needs a focused window, and test/shell.d runs against the developer's live compositor, so that would steal the keyboard mid-run. Per agents/skills/acceptance-tests.md that belongs in test/acceptance.d, which I cannot run here without the omarchy-iso repo.
Added lock-focus-recovery-test.sh instead, in the same source-assertion idiom lock-blank-fingerprint-test.sh uses for the blank timer. It covers the handler and its inputEnabled gate, and fails with the fix removed. Happy to add the acceptance variant if you would rather have it there.
Suspending drops keyboard focus from the lock screen password field, and nothing puts it back. Focus is only taken in Component.onCompleted and when inputEnabled changes, and inputEnabled is bound to lockRequested, which is already true by the time the machine suspends and stays true across resume. The only remaining path was the background MouseArea's onClicked handler, so the machine woke to a lock screen that ignored the keyboard until it was clicked. Reclaim focus when the field loses it while the lock is up. Traced on a 4.0 desktop, timestamps from journalctl: 11:09:39.982 activeFocus=true field focused at lock 11:09:39.992 secure=true 11:09:40.086 kernel: PM: suspend entry (deep) 11:09:40.099 activeFocus=false focus dropped 11:10:07.577 kernel: PM: suspend exit A plain lock without a suspend does not drop focus, so reproducing this needs an actual suspend rather than just locking the session. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WDCXKUYgyKMb1ACcoBAbro
Asserts the password field reclaims focus when it loses it while the lock is up, and that recovery stays gated on inputEnabled so the preview surface does not fight for focus. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WDCXKUYgyKMb1ACcoBAbro
2eb43dd to
624e6c0
Compare
|
Reviewed by Claude Opus 5 in Claude Code, with an independent second opinion from Codex at xhigh reasoning. No defect found in the production change. Two things worth writing down, plus one note on the test. What was actually run. Everything ran on a disposable VM with a real compositor serving this branch, never on the review machine: The failure mode worth hunting was a focus fight — something else takes focus, this handler takes it straight back, and the session spins with an unusable lock screen. It cannot happen in the current tree, and that was measured rather than assumed. I built a probe that hosts LockView in a mapped window with exclusive keyboard focus, once from the base file and once from this branch, counting the field's
One thing the change does not do, which matters for which issues it closes. The handler repairs Qt's internal item-focus chain; it never asks the compositor for the lock surface's keyboard focus. Measured: on a plain window deactivation and reactivation, base and this branch behave identically, because Qt restores the selected child unaided. Codex supplied the reconciling detail — when Qt has no current The test. Where this stands. Nothing pushed to the branch, nothing to fix. It is waiting on the maintainer, and on a decision this PR cannot make for itself: #7164, #7471 and #7592 are all open against the same defect in the same file, #7592 being the closest — same bug, level-triggered with a retry timer where this is edge-triggered. This one is the smallest of the four and the only one with no timer. #8561 and #8531 touch only Service.qml and do not conflict. |
|
Confirmed on hardware. AMD laptop, single eDP panel, Hyprland, omarchy 4.0.1. Before: suspend from the menu, resume, screen lit by trackpad movement, typed password ignored until a click. After applying this patch alone onto the installed 4.0.1 tree and rebooting: suspend, resume, type — accepted with no click and no trackpad contact. Mechanism matches the comment in the diff: One offer: the test here asserts on the source text with a regex, so it passes on code that does not work and breaks on a reformat. I have a headless fixture that loads the real |
|
Re-reviewed at 624e6c0, which has not moved. The production change still looks right, so this pass went at the testing question in the thread above and tried to settle it by measurement rather than argument. Reviewed by Claude Opus 5 in Claude Code, with an independent second opinion from Codex at xhigh reasoning — with the caveat that Codex's independence is not currently guaranteed, since it can read this session's own working notes. @robouk's claim is correct, and now measured. I built a probe that hosts The conclusion that it therefore needs So a On the handler itself. Codex checked the two things a focus grab could plausibly break and agreed with what I had found by reading, supplying the mechanism for each. It cannot take focus from an application the user is typing into, because the What was run. On a disposable VM with a real compositor serving this branch: Verdict is unchanged from the last pass: no defect in the production change, and it is waiting on the maintainer, who has four open PRs against this same bug to choose between. @rdoupe's hardware report is the first end-to-end confirmation on real hardware from someone other than the author, which the previous review could not supply, because a VM cannot suspend. |
|
hey, this is already covered in #12894 (lock keyboard focus after lid-open / resume). mind closing this as a duplicate? |
|
Confirmed on two more machines, both Intel iGPU + NVIDIA Turing dGPU:
Applied this change alone onto the packaged In case it helps whoever reviews this: suspend isn't needed. Blanking the display while locked reproduces it on demand: omarchy-system-lock
hyprctl dispatch 'hl.dsp.dpms({ action = "disable" })'
hyprctl dispatch 'hl.dsp.dpms({ action = "enable" })'
# type the password without clicking: ignored before this change, unlocks with itI instrumented I also have a behavioral test for this. It runs |
…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>
|
I pushed one commit to this branch, The test. What ran. Everything ran on a disposable VM with a real compositor, serving this branch. The new test fails on current The full shell suite is not green on that VM, and none of its failures come from this branch. On this branch it failed three tests: two ASCII/branding tests and the Issues. None are linked as closing. #6858 includes a lock that never had focus at first map, which this change cannot reach. #14613 reports that even clicking the field did not bring input back, which is more than the focus loss fixed here. Where it stands. This carries |
[Medium impact] The PR affects password entry on the lock screen. The focus change appears sound, but the test layout must meet the contributor guide before merging. Findings
Summary
Reviews (3) · Last reviewed commit: "Report the lock focus test as skipped, n..." · Reviewed by Greptile |
…ring While the password is checked the field is disabled, and Qt only gives focus back to a re-enabled item if nothing else took focus meanwhile. If the surface or another item takes it during the check, the field comes back unfocused and the onActiveFocusChanged reclaim never fires again, because the field had already lost active focus when it was disabled. Refocus when the check ends, and cover both cases in the fixture. The handler is @ArveLomsland's, from omacom#10944. Co-Authored-By: Arve Lømsland <arve@lomsland.no> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I pushed one commit to this branch, What was missing. While the password is checked, the field is disabled. Qt gives focus back to a re-enabled item only if nothing else took focus in the meantime. If the surface or another item takes it during the check, the field comes back unfocused, and the onAuthenticatingPasswordChanged: {
if (inputEnabled && !authenticatingPassword) Qt.callLater(forcePasswordFocus)
}The test. The What ran. Everything ran on a disposable VM with a real compositor, three runs of each. The fixture passes on this branch and on this branch merged into Where it stands. This carries |
|
Independent real-hardware confirmation at Machine: Lenovo ThinkPad P17 Gen 1, built-in keyboard ( Setup: both console.log("omarchy lock-test fieldFocus=" + activeFocus + " inputEnabled=" + root.inputEnabled)
Procedure: lid close → wait → open → type the password without clicking. Trace (both cycles; sleeps ~2.5 min and ~4.5 min): This matches the trace in the PR description, and it answers the open question from the #15362 review on real hardware. The focus reclaimed while no keyboard exists survives the keyboard's re-add, even though Same boot, same procedure, each fix installed alone:
No focus ping-pong or repeated reclaim was logged: one drop and one reclaim per suspend, plus the expected pair around the password check. |
…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>
|
Re-tested on 4.5.0-rc2, which doesn't include this. Same machine as my earlier comment: Lenovo ThinkPad P17 Gen 1, NVIDIA Quadro T1000 only, S3 Each cycle: Super + Esc → Suspend, 1–2 minutes in S3, woken with the power button, password typed with no pointer contact.
This PR's This machine is set not to suspend on lid close, so a lid close only locks it. That lock-without-suspend path kept focus on stock rc2, so the failure is specific to the suspend/resume case this PR fixes. Could this be considered for 4.5? It's still being reported on 4.0.6 (#15345, #16372). |
|
Re-checked after this branch started conflicting with What ran. I merged
The confirmations from @mudiam (4.0.6 and 4.5.0-rc2) both come from builds that do not contain #17277, so they show this PR fixed the bug then. They do not show that What still stands. One case: focus taken from the field while it is disabled during a password check. #17277 deliberately skips the restore at that moment, and nothing retries once the check ends. @brightwalker25 described hitting this on #10944, on 4.0.4: after a resume, one wrong password left the field taking no keystrokes. On onAuthenticatingPasswordChanged: if (!authenticatingPassword) Qt.callLater(restorePasswordFocus)Both reviewers judged the 246-line test out of proportion to that fix under What I did not do. I pushed nothing. The merge is correct as a merge, and both reviewers agreed on that. But the PR it produces is no longer the fix it was opened as. Turning this PR into only that remaining handler is a change to what the PR is, not a defect fix, so that call is the maintainer's. Where it stands. Waiting on the maintainer. It no longer merges cleanly and carries no |
|
Real-hardware data on the one case left open above: a wrong password after resume, on a build that has #17277. Machine: Lenovo ThinkPad P17 Gen 1, NVIDIA Quadro T1000 only, S3 Each cycle: Super + Esc → Suspend, wake, then without touching the pointer type a wrong password and Enter, then the right password and Enter.
3/3: the field kept taking keys after the failed check. Each cycle logged one So on this machine, #17277 alone covers the wrong-password-after-resume case as well. This doesn't rule out the race @brightwalker25 hit on #10944 (focus taken by something else during the check), since nothing here takes focus at that moment. It does mean the post-check handler isn't needed for this hardware. |
|
Thanks for running this, @mudiam. It narrows what is left here. Your cycles test a different path from the case my last comment said still stands. On A correction to my last comment: I put @brightwalker25's report on #10944 under that remaining case. It came from 4.0.4, before #17277, and the plain suspend focus loss #17277 fixed explains a dead field there just as well. So nobody has reproduced the remaining case on a build that contains #17277. On Reviewed by Claude Opus 5.5 in Claude Code, with second opinions from Codex at medium effort and muse-wonder at high thinking. Both read your results the same way. They were shown my earlier comment, so that agreement is not independent. Asked to check that comment for overstatements, both found the #10944 one corrected above. Waiting on the maintainer. |
|
I reproduced the remaining case in a real session on a build with #17277, and the one-line guard fixes it. Machine: Lenovo ThinkPad P17 Gen 1, NVIDIA Quadro T1000 only. Omarchy 4.5.0-3 (#17277's Trigger: a VT switch during the password check. My earlier wrong-password test couldn't hit this, because nothing took focus during the ~2 s check. Typing Ctrl+Alt+F2 inside that window by hand is unreliable, so a root helper followed the journal and ran Each cycle: Super+Esc → Lock, type a wrong password and press Enter (the VT switch fires during the check), return to the lock, then type the right password without touching the pointer.
The patched runs used a restarted shell ( This matches the gap described above: the keyboard goes away while the field is disabled, #17277's restore skips it on purpose, and nothing retries when the check ends. A VT switch is one real way to take focus during a check, so the post-check guard closes a gap you can hit on real hardware, not just in the fixture. |
quattro's omacom#17277 restores the password field's focus when the lock window's focus item changes; this keeps that handler and this branch's post-check refocus side by side. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quattro's Window.onActiveFocusItemChanged restores the field's focus when a suspend takes it, which is what this handler did, so its comment that nothing puts focus back no longer holds. The lock-focus-recovery fixture passes every check without it; the post-check refocus is what still covers focus taken during a password check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: muse-wonder High <noreply@meta.com>
|
Thanks, @mudiam. A VT switch during the check, field dead 0/3 without the guard and working 3/3 with it, is the real-session reproduction this was missing. The post-check refocus is now a fix for a bug people can hit on
Against What ran. This PR's Second opinion. Codex at medium effort and muse-wonder at high thinking found no defect. Both judged the merge resolution and the removal correct, and judged pushing them to be integration work, not a rewrite. They were shown my reasoning, so that agreement is not independent. muse-wonder found the pass-instead-of-skip line fixed above. Both mildly prefer the form mudiam tested, What is left, @robouk:
Waiting on the author for those, then on the maintainer. |
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| TMPDIR="" | ||
| QS_PID="" |
There was a problem hiding this comment.
The new lock-focus-recovery-test.sh adds a separate file even though existing tests already cover LockView. The contributor guide requires extending the area's existing test file rather than adding another *-test.sh.
Before merging, move this coverage into an existing lock test and use run_qml_fixture instead of copying its setup and cleanup.
File Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Suspending drops keyboard focus from the lock screen password field, and nothing puts it back. Focus is only taken in
Component.onCompletedand wheninputEnabledchanges, andinputEnabledis bound tolockRequested, which is already true by the time the machine suspends and stays true across resume. The only remaining path was the backgroundMouseArea'sonClickedhandler, so the machine woke to a lock screen that ignored the keyboard until it was clicked.Reclaim focus when the field loses it while the lock is up.
Traced on a 4.0 desktop, timestamps from journalctl:
A plain lock without a suspend does not drop focus, so reproducing this needs an actual suspend rather than just locking the session. Verified on hardware: with the change, the machine wakes with the field focused and accepts typing without a click.