Skip to content

Restore lock screen password focus lost on suspend - #8560

Open
robouk wants to merge 7 commits into
omacom:quattrofrom
robouk:lock-focus-after-secure
Open

robouk wants to merge 7 commits into
omacom:quattrofrom
robouk:lock-focus-after-secure

Conversation

@robouk

@robouk robouk commented Aug 27, 2026 •

Copy link
Copy Markdown

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:09:40.099  activeFocus=true       reclaimed by this change
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. Verified on hardware: with the change, the machine wakes with the field focused and accepts typing without a click.

Copilot AI balanced review requested due to automatic review settings August 27, 2026 09:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread shell/plugins/lock/LockView.qml Outdated
Comment on lines +167 to +169
onActiveFocusChanged: {
if (!activeFocus && root.inputEnabled) Qt.callLater(root.forcePasswordFocus)
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

robouk and others added 2 commits August 27, 2026 11:12
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
@robouk
robouk force-pushed the lock-focus-after-secure branch from 2eb43dd to 624e6c0 Compare August 27, 2026 10:13
@robouk robouk changed the title Restore lock screen password focus after the session goes secure Restore lock screen password focus lost on suspend Aug 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

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: lock-focus-recovery-test.sh, lock-fingerprint-indicator-test.sh, lock-password-overflow-test.sh, lock-stranded-recovery-test.sh, lock-blank-fingerprint-test.sh, sleep-lock-test.sh, system-lock-test.sh — 42 assertions, 0 failures. The two fixtures that build a LockView in a live Quickshell process ran rather than skipping, so the file loads with the handler in place. Locking that machine's real session over IPC reached secure=true and the shell burned 0 CPU ticks over the following 10 seconds with the lock screen up. An actual suspend is not reproducible on a VM, so that the handler fires on real hardware rests on your journal trace rather than on anything measured here.

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 activeFocus transitions:

  • Field disabled by authenticatingPassword (enabled: root.inputEnabled && !root.authenticatingPassword): identical on both — one transition, no loop. Codex explained why: on Qt 6.11 the window's activeFocusItem falls back to the enclosing focus scope, so forcing focus onto a disabled item is silently declined, and Qt still restores the field on its own when PAM finishes.
  • Destroying the LockView in the same event loop pass as a focus loss, with a Qt.callLater queued against it: survived on both, no crash, no warning. Qt.callLater is lifetime-guarded for a QML method reference like this one, and finishUnlock() clears lockRequested before tearing the surface down, so the teardown disable sees inputEnabled false and schedules nothing.
  • A second focusable item taking focus: base leaves it there, this branch takes focus back off it. Nothing focusable exists on the lock surface today — the field is the only keyboard target, the fingerprint indicator is a Text, and fingerprintPam has no UI at all — so there is nothing to fight. Worth knowing for whoever next adds a control there; Add a reveal toggle to the lock screen password field #7680's reveal toggle is fine because it hands focus back deliberately.

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 focusWindow, a transitional state during suspend, a window can establish internal active focus without holding Wayland keyboard focus, which is why your trace shows activeFocus back to true in the same millisecond. So this fixes the reports where the internal chain was broken (#8520 and #8361 read exactly that way), and cannot reach the ones where the compositor never returns keyboard focus. It is also edge-triggered by nature: activeFocusChanged cannot fire for a field whose activeFocus was never true, so a lock that never got focus at first map is untouched — which is how #7467, #6858 and #7811 read. Not something to change here; just not the whole of the bug, and the maintainer should not expect those to close.

The test. lock-focus-recovery-test.sh matches a regex against LockView.qml's source text, including the brace and whitespace layout, so it proves the string is present and nothing about focus. It still passes if forcePasswordFocus() becomes a no-op or the handler is attached to the wrong object, and it fails on a reformat that splits the if across lines with behaviour unchanged. The negative assertion catches one exact ungated spelling and misses the other ways of writing an ungated one. Source-grep tests are a house norm in this area — lock-stranded-recovery-test.sh is fourteen of them — so this is not out of keeping, and it has not been changed on the branch. But the invariant here is directly testable, unlike stranded-lock recovery: the probe above is the shape of it, and the same fixture would cover the disabled-during-PAM case and the inputEnabled: false gate as real behaviour. The reason it was not pushed is that such a fixture needs a mapped window actually holding keyboard focus, which is a heavier dependency than any existing lock fixture takes, so swapping the regex for one is a call about the suite's shape rather than a defect fix.

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.

@rdoupe

rdoupe commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

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: omarchy-system-sleep-lock locks before suspend, the lock surface outlives the sleep (journal shows no second secure=true on resume), so Component.onCompleted never re-runs and only a click restored focus.

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 LockView, drops focus while the view stays alive, and asserts it comes back — verified to fail without this change. Happy to hand it over if you want it.

@omarchybot

Copy link
Copy Markdown
Collaborator

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 LockView exactly the way lock-password-overflow and lock-fingerprint-indicator do — a bare Item under ShellRoot, no window anywhere in the parent chain — and read the password field's focus and activeFocus back on a real compositor. After forcePasswordFocus(): focus=true, activeFocus=false, identical on this branch and on the base file. That is the claim verbatim. onActiveFocusChanged cannot fire there because activeFocus never becomes true in the first place, so the test @Copilot asked for cannot be written against those fixtures as they stand. Worth adding in support: nothing under test/shell.d/fixtures/ hosts anything in a window today, and no fixture asserts activeFocus anywhere, so this is not an established pattern that was skipped.

The conclusion that it therefore needs test/acceptance.d does not hold, though. The blocker is having a QQuickWindow at all, not having the compositor's keyboard. I ran the same probe with the host inside a PanelWindow, once with WlrKeyboardFocus.Exclusive and once with WlrLayershell.keyboardFocus: WlrKeyboardFocus.None, which takes the keyboard from nobody. In both, the field reaches activeFocus=true. Then the exact sequence @Copilot described — move active focus to a sibling while inputEnabled is true, wait for Qt.callLater, re-read the field:

keyboardFocus None, this branch:  baseline activeFocus=true -> sibling steals -> after callLater: field=true,  sibling=false
keyboardFocus None, base file:    baseline activeFocus=true -> sibling steals -> after callLater: field=false, sibling=true

So a test/shell.d fixture can assert this behaviourally, it fails with the handler removed, and it does not steal the developer's keyboard mid-run. That makes @rdoupe's offered fixture worth taking, or a small addition to this one. I have not pushed a fixture myself: introducing the suite's first window-hosting fixture is a decision about the shape of the suite rather than a defect fix, and two of you already have code for it.

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 WlSessionLockSurface and its LockView do not exist at all until sessionLock.locked becomes true (Service.qml:76), and forceActiveFocus() moves focus within its own Qt scene without requesting compositor activation. It is a no-op on the preview surface, which pins inputEnabled: false (Service.qml:307). And it cannot loop: finishUnlock() clears lockRequested at Service.qml:151 before releasing the lock at line 157, so the gate is already false when teardown drops focus, and a successful recovery re-fires the handler with activeFocus true, where the !activeFocus guard stops it.

What was run. On a disposable VM with a real compositor serving this branch: lock-focus-recovery-test.sh, lock-password-overflow-test.sh and lock-fingerprint-indicator-test.sh all pass, with the two live-Quickshell fixtures running rather than skipping. The probes above ran on that same machine, which was destroyed afterwards. Nothing ran on the review host.

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.

@chessing234

Copy link
Copy Markdown
Contributor

hey, this is already covered in #12894 (lock keyboard focus after lid-open / resume). mind closing this as a duplicate?

@dexteresc dexteresc mentioned this pull request Sep 22, 2026
7 tasks done
@joemar-tagpuno

Copy link
Copy Markdown

Confirmed on two more machines, both Intel iGPU + NVIDIA Turing dGPU:

  • Razer Blade 15 Base (2020), i7-10750H + RTX 2070 (nvidia-open 610.57.04) — Omarchy 4.0.4, Hyprland 0.56.2, Quickshell 0.3.1, lid closed with an external HDMI monitor
  • Razer Blade Stealth 13, Iris Xe + GTX 1650 Ti — laptop panel only

Applied this change alone onto the packaged LockView.qml: suspend → resume → type with no click → unlocks, on both.

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 it

I instrumented LockView to log Window.active and Window.activeFocusItem. On DPMS off the lock surface goes inactive and focus falls to the root item. After DPMS on, Hyprland never reactivates the surface (Window.active stays false through a successful unlock), but key events are delivered again, so the field only needs to retake focus. That's what this does.

I also have a behavioral test for this. It runs LockView in a real window, drops focus to the window's contentItem, and does an authenticatingPassword true→false round-trip. It fails on current quattro and passes with this change. Happy to push it here if that's useful.

…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>
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed one commit to this branch, f5009085, which replaces the regex test with one that moves focus for real. Reviewed by Claude Opus 5.5 in Claude Code, with a second opinion from Codex at medium effort, which found no defect in the handler or the new test. It agreed with conclusions I had already written down, and its independence is not guaranteed.

The test. lock-focus-recovery-test.sh used to match LockView.qml's source text, so it passed on a handler that did nothing and broke on a reformat. It now runs a fixture, test/shell.d/fixtures/lock-focus-recovery/shell.qml, which hosts the real LockView in a window and checks five things. The field has focus once the window is active. It takes focus back when another item takes it. It takes focus back when focus is dropped to the surface itself, which is what resume does. It has focus after a password check. It leaves focus alone while inputEnabled is false, as on the preview surface. The fixture is adapted from @casmith's in #15362, who is credited as co-author on the commit. It does not include #15362's Window.active guard, which could stop the field recovering on a resume where the surface is never reactivated. It finds the field by its password echo mode, so the production change stays the nine lines you wrote.

What ran. Everything ran on a disposable VM with a real compositor, serving this branch. The new test fails on current quattro and with your handler reverted: the field does not take focus back from another item, nor when it is dropped. It passes on this branch, three runs out of three, and on this branch merged into quattro. ./test/cli passed.

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 omarchy-theme-install URL guard. The commit this branch starts from fails the same three. Merged into quattro, it fails the same set as quattro itself, plus a background-intro test and an emoji test that both passed when rerun. The VM had no node installed, so I installed it there before the suite run. A VM cannot suspend, so the suspend itself rests on the hardware reports in this thread, now from six machines.

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 verified at f5009085 but not ready, because the full suite is not green on a worker and CI reports no checks on this branch. Of the open fixes for this bug, this one is the oldest and is the one recommended. #7164, #7471, #9523, #10944, #12435, #13907, #14882 and #15362 compete with it. Choosing between them is waiting on the maintainer. Nothing is needed from you.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 17, 2026
@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[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

  1. P2 Lock tests split apart ▶

Summary

LockView now requests password focus after a password check ends, including when another item took focus during the check.

  • The lock screen refocuses its password field when checking ends.

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>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 18, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed one commit to this branch, 39691c1e, which adds @ArveLomsland's refocus after a password check from #10944, credited to them as co-author. Reviewed by Claude Opus 5.5 in Claude Code, with a second opinion from Codex at medium effort, which found no defect in the handler or the test.

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 onActiveFocusChanged reclaim does not fire again, because the field already lost focus when it was disabled. That is the case @brightwalker25 reported on #10944: after a resume, one wrong password left the field taking no keystrokes. The new handler in LockView.qml takes focus back when the check ends, with the same guard as the existing onInputEnabledChanged:

onAuthenticatingPasswordChanged: {
  if (inputEnabled && !authenticatingPassword) Qt.callLater(forcePasswordFocus)
}

The test. The lock-focus-recovery fixture adds two checks: focus dropped to the surface during a check, and taken by another item during a check. In both, focus moves after the check has started, not at the moment it starts. Codex also traced the successful unlock: the handler can be queued there, but input is already disabled and the lock released by the time it runs, so nothing is taken from anything. On the preview surface inputEnabled is always false, so it never fires.

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 quattro. With only the new handler removed, it fails exactly the two new checks. On quattro's LockView.qml it fails every recovery check. ./test/cli and every lock test in test/shell.d passed on this branch. On the merge into quattro, lock-appear-budget missed its 2580ms budget, and it misses it on quattro itself on the same VM too. A VM cannot suspend, and this models the focus change in a window, not a real PAM check after a resume. The full shell suite was not run this time.

Where it stands. This carries verified at 39691c1e but not ready, because the full suite has not been green on a worker and CI reports no checks on this branch. With this handler added, #10944 covers nothing this PR does not. Choosing between this and the other open fixes for the same bug is waiting on the maintainer. Nothing is needed from you.

@mudiam

mudiam commented Oct 21, 2026

Copy link
Copy Markdown

Independent real-hardware confirmation at 39691c1e: this fixes the resume case on this machine, 2/2, tested on the same boot as the other open fixes for this bug, each one alone.

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: both LockView.qml hunks applied cleanly to the shipped 4.0.6 file (+14 lines), with stock Service.qml, followed by omarchy-restart-shell. For diagnosis I added one non-behavioural line at the top of the new handler:

console.log("omarchy lock-test fieldFocus=" + activeFocus + " inputEnabled=" + root.inputEnabled)

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

Procedure: lid close → wait → open → type the password without clicking.

Trace (both cycles; sleeps ~2.5 min and ~4.5 min):

lock-requested
lock-test fieldFocus=true  inputEnabled=true     # lock up
secure=true
PM: suspend entry (deep)
lock-test fieldFocus=false inputEnabled=true     # ~85 ms later: keyboard gone, focus dropped
lock-test fieldFocus=true  inputEnabled=true     # reclaimed < 0.5 ms later, still before resume
PM: suspend exit
   (typed without clicking: accepted)
lock-test fieldFocus=false / true                # field disabled → re-enabled around the PAM check
unlocked                                          # 5 s and 7 s after lid-open

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 Window.active never comes back after resume on this machine (logged directly while testing #15362).

Same boot, same procedure, each fix installed alone:

lid-close resume, type without clicking
stock 4.0.6 2/2 fail
this PR 2/2 pass
#12435 2/2 pass
#15677 (backported to 4.0.6) 2/2 pass
#15362 2/2 fail (Window.active guard never satisfied after resume)

No focus ping-pong or repeated reclaim was logged: one drop and one reclaim per suspend, plus the expected pair around the password check.

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>
@mudiam

mudiam commented Oct 28, 2026

Copy link
Copy Markdown

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 deep. Omarchy 4.5.0rc2-1, Hyprland 0.56.2-4, quickshell 0.3.2.r7.g2b4501a-1, linux-omarchy 7.2.8-9, nvidia-open-dkms 615.78.08.

Each cycle: Super + Esc → Suspend, 1–2 minutes in S3, woken with the power button, password typed with no pointer contact.

LockView.qml Result
stock rc2 0/1: typing ignored until a click
rc2 + this PR 3/3: accepted with no click

This PR's LockView.qml change applies cleanly to the rc2 file, next to rc2's own lock changes, and the shell loads it with no QML errors. The full PR diff, test included, also applies cleanly to the current v4-5-0 head (382515d).

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).

@omarchybot

Copy link
Copy Markdown
Collaborator

Re-checked after this branch started conflicting with quattro. Since then, #17277 has landed on quattro. It restores the password field's focus whenever the lock window's focus item changes, which covers the suspend case this PR was opened for. Reviewed by Claude Opus 5.5 in Claude Code, with second opinions from Codex at medium effort and muse-wonder at high thinking. Both reached the same conclusions below, after being shown the worker results, so their agreement is not independent.

What ran. I merged quattro into this branch locally, keeping both #17277's handler and this PR's, and ran this PR's lock-focus-recovery test on a disposable VM with a real compositor, three times per tree, with the same result every time:

  • quattro with only this PR's test added: the checks for focus moved to another item and focus dropped to the surface both pass. Only the two checks where focus is lost during a password check fail.
  • This branch merged into quattro: every check passes.
  • The merge with this PR's onActiveFocusChanged handler removed: every check still passes. On quattro, that handler is now redundant.
  • The merge with the onAuthenticatingPasswordChanged handler removed: the same two password-check checks fail.

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 quattro still needs this PR.

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 quattro it would be a one-line change using #17277's own guarded helper:

onAuthenticatingPasswordChanged: if (!authenticatingPassword) Qt.callLater(restorePasswordFocus)

Both reviewers judged the 246-line test out of proportion to that fix under quattro's AGENTS.md. Most of it now covers cases #17277 already handles.

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 verified. #7164, #7471 and #10944 also conflict, and #17277 covers them the same way. #7471 also changes the blank and wake handling in Service.qml, which this does not judge. Nothing is needed from you, @robouk, unless the maintainer asks for this to be cut down to the post-check handler.

@mudiam

mudiam commented Nov 16, 2026

Copy link
Copy Markdown

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 deep. Omarchy 4.5.0-3 (ships #17277's restorePasswordFocus and has no onAuthenticatingPasswordChanged), Hyprland 0.56.2-4, quickshell 0.3.2.r7.g2b4501a-1, nvidia-open-dkms 615.78.08, linux-omarchy 7.2.15. Stock LockView.qml and Service.qml, with no patches to the lock.

Each cycle: Super + Esc → Suspend, wake, then without touching the pointer type a wrong password and Enter, then the right password and Enter.

Cycle Asleep Wrong password rejected (after resume) Right password typed without a click
1 ~22 s +7.8 s unlocked +14.3 s
2 ~26 s +5.1 s unlocked +11.1 s
3 ~2.5 min +4.2 s unlocked +10.4 s

3/3: the field kept taking keys after the failed check. Each cycle logged one pam_unix(omarchy-lock-password:auth): authentication failure and then unlocked about 6 s later. There were no QML errors.

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.

@omarchybot

Copy link
Copy Markdown
Collaborator

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 quattro the password field is disabled while a password is checked (shell/plugins/lock/LockView.qml:165). When it is enabled again, Qt gives it focus back by itself, as long as nothing else took focus in the meantime. So a wrong password after resume works without any post-check handler, which is what you saw 3/3. #17277's part in those cycles is giving focus back after the wake, before the first password. The case still open is focus moving to something else while the check runs. The fixture on a disposable VM reproduces it only by forcing focus away. Nothing in a real session is known to do that.

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 quattro, that leaves this PR's onActiveFocusChanged handler redundant with #17277. Its onAuthenticatingPasswordChanged refocus closes a gap that exists in the code and shows up in the fixture, with no field report behind it. The maintainer decides whether that gap is worth a one-line guard, or whether this PR is closed as covered by #17277. Neither the branch nor quattro's lock code has changed since the last check, so those worker results still hold. Nothing was pushed.

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.

@mudiam

mudiam commented Nov 16, 2026

Copy link
Copy Markdown

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 restorePasswordFocus and Window.onActiveFocusItemChanged, no onAuthenticatingPasswordChanged), Hyprland 0.56.2-4, quickshell 0.3.2.r7.g2b4501a-1.

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 chvt 2; sleep 0.5; chvt 1 as soon as quickshell.service.pam logged Starting pam session … omarchy-lock-password. Hyprland's log confirms the keyboard was removed (AT Translated Set 2 keyboard: device removed) inside the check every time, before PAM's Failed to authenticate.

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.

LockView.qml VT switch inside the check Right password accepted without a click
4.5.0-3 as shipped 3/3 0/3: the field ignored typing until clicked
4.5.0-3 + onAuthenticatingPasswordChanged: if (!authenticatingPassword) Qt.callLater(restorePasswordFocus) 3/3 3/3 (unlocked ~5 s after the failed check)

The patched runs used a restarted shell (omarchy restart shell), and the new line added no QML errors or warnings.

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.

omarchybot and others added 3 commits November 16, 2026 22:24
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>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 16, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

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 quattro, so I brought the branch up to date:

Against quattro, the PR is now 5 lines in LockView.qml plus its test, and it merges cleanly.

What ran. This PR's lock-focus-recovery test ran on a disposable VM with a real Hyprland session, three times per tree. quattro with only the test added fails exactly the two checks where focus is lost during a password check. Reverting the handler from this head gives the same LockView.qml byte for byte, so that is also the reverted run. The head passes every check. ./test/cli is green. ./test/shell ran 4602 passing checks and 68 failing ones. None of the failures can come from this branch, which differs from quattro only in the lock files and this test. Most are tests that need node, which the VM does not have; the rest are in other areas. The new test itself failed once in the full run, after the VM's display had gone to sleep partway through, and passed on a freshly booted session. It needs a real window to become active, so it depends on the state of the desktop it runs on.

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, Qt.callLater(restorePasswordFocus), because it rechecks the field when it runs. The PR's forcePasswordFocus line has the same effect in the reproduced case, so I left it as written.

What is left, @robouk:

  1. The title and description still describe the suspend focus loss, which quattro now handles through Keep the lock usable after an NVIDIA suspend's VT switch #17277. What this PR adds is taking focus back after a password check, when something took it during the check, as mudiam's VT-switch runs show.
  2. The test is 246 lines for a 5-line change, in a new file. A proportionate version would keep just the two during-check checks and run them through run_qml_fixture, the way lock-autorepeat-test.sh runs its LockView fixture in a few lines. quattro's AGENTS.md asks for that size, and for extending an existing lock test where one fits.

Waiting on the author for those, then on the maintainer.

Comment on lines +5 to +8
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

TMPDIR=""
QS_PID=""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Lock tests split apart

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.