omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

[Quattro] Lock password field can lose focus after suspend resume

Open ClGratton opened this issue 3 months ago • 8 comments

System details

  • Omarchy 4.0.1-1 (Quattro)
  • Hyprland 0.56.2-1
  • NVIDIA RTX 3080 Ti
  • Two DisplayPort outputs: 2560x1440 at 180 Hz and 200 Hz
  • Linux 7.1.9

What is wrong?

After suspending while the native Omarchy session lock is active, a restored or recreated lock surface can show a password field that does not own keyboard focus. Focus can also be lost while PAM disables the field and then releases it after a failed attempt.

This is separate from the slow-display reblank problem in #7399. It is also separate from the first modifier event lost during input-device restoration, which was later isolated in hyprwm/aquamarine#375.

Steps to reproduce

  1. Suspend through the normal Omarchy path so the session is locked before sleep.
  2. Resume and wait for the displays to return.
  3. Inspect or interact with the visible password field after output recreation.
  4. The field can lack active focus. The same loss can occur after PAM rejects a password and re-enables the field.

Root cause

LockView.qml requested passwordInput.forceActiveFocus() only when the component completed or inputEnabled changed. During resume, ext-session-lock outputs can be recreated while inputEnabled remains true. Service.qml already observes Quickshell.onScreensChanged, but did not ask the recreated view to reacquire keyboard focus.

On a multi-monitor resume, outputs can return sequentially, so one immediate refocus is not sufficient. PAM also temporarily disables the input during authentication, requiring recovery to pause and restart when the field becomes enabled again.

Expected

The password field owns keyboard focus whenever the visible lock surface is ready for input, including after output recreation and after a failed PAM attempt.

Verified fix

A cloned omarchy.lock service sends a focus-generation request when the lock becomes secure, whenever screens change, and after PAM releases the input. LockView is a FocusScope, acknowledges TextInput.activeFocus, and the service retries briefly across sequential output recreation. Focus telemetry confirmed that the field reacquired active focus.

The separate case-sensitive first-password failure was not used to validate this fix; protocol traces attributed it to aquamarine#375.

A focused regression test covers the retry budget, screen-change trigger, failed-PAM transition, disabled-field guard, focus scope, request handoff, and focus acknowledgement. PR #9181 contains the fix.

ClGratton avatar Aug 30 '26 14:08 ClGratton

Triaged against quattro (v4.0.0-235-gb686ed89), together with #9292 and #9325. Your root-cause section holds up, and reading Quickshell's own source sharpens it in two ways worth having.

The grab is not merely early, it is structurally too early. Quickshell's WlSessionLock::realizeLockTarget() (src/wayland/session_lock.cpp:115-140) preloads every surface before it takes the lock:

this->updateSurfaces(false);                              // constructs every LockView
if (!this->manager->lock()) this->lockTarget = false;     // only now request the lock
this->updateSurfaces(true, old);                          // show them

That is read from the quickshell-git debug source; the same path is confirmed present in the 0.3.1 binary you are running. So LockView's Component.onCompleted — and with it the only Qt.callLater(forcePasswordFocus) a fresh surface ever gets — runs before the ext-session-lock-v1 request has been sent, on a window that is not yet shown and cannot yet hold the keyboard. Any fix that focuses only at construction is guaranteed to fire before the compositor can honour it.

And your sequential-output observation is exactly what Quickshell does. WlSessionLock::updateSurfaces() is driven from screenAdded / screenRemoved / primaryScreenChanged; it drops any screen whose QWaylandScreen is a placeholder or has a null output(), deleteLater()s the surfaces of screens that went away, and mSurfaceComponent->create()s a fresh one for each screen that appeared. During DisplayPort link training after resume a screen transiently fails that test, so each output's surface is genuinely destroyed and rebuilt, one after another, with the old window's deletion deferred to a later event-loop turn than the new window's creation. Focus taken on one surface is racing that whole sequence with nothing re-asserting it.

The second half of the cause is that nothing declares focus at all. There is no focus: declaration anywhere in shell/plugins/lock/: LockView is a plain Item (LockView.qml:6) and passwordInput (LockView.qml:132) never sets focus: true, so a rebuilt surface has nothing for Qt to restore focus to, only a one-shot imperative grab that has already fired. Every other keyboard-accepting surface in the shell pairs forceActiveFocus() with a declared focus — shell/Ui/PanelKeyCatcher.qml:46, shell/Ui/SpeedTestOverlay.qml:107, shell/plugins/menu/Menu.qml:1120, shell/Ui/SearchableDropdown.qml:182, shell/Ui/Dropdown.qml:159, shell/Ui/MultiSelect.qml:369, shell/plugins/dev-gallery/GalleryPanel.qml:290-293. The lock is the only one that does not. Your #9181 is the only proposal that covers both of those halves — the FocusScope plus focus: true, and re-requests driven from onSecureStateChanged and onScreensChanged, which are precisely the two moments Quickshell's code above changes the answer.

A third trigger came out of the second review and is worth more than either of the reported ones, because it needs no suspend and no second monitor: mistype your password once and the field stops accepting keystrokes until you click it. passwordInput.enabled is bound root.inputEnabled && !root.authenticatingPassword (LockView.qml:145); submitPassword() sets authenticatingPassword = true (Service.qml:183), which disables the item, and Qt clears activeFocus on a disabled item; handlePasswordFailure() sets it back to false (Service.qml:201) and re-enables the field, but nothing refocuses on that transition. If you can, please try it — lock, type a deliberately wrong password, press Enter, then try to type again without clicking. Whether that reproduces on your machine is useful either way.

One consequence for #9181, offered as an observation rather than a review — it will get one on its own thread. Nothing in it bumps focusGeneration when authentication ends: beginPasswordFocusRecovery() is reached only from onSecureStateChanged and onScreensChanged, so the wrong-password trigger above is not covered. #8930 does cover it, via onAuthenticatingPasswordChanged. Relatedly, requestPasswordFocus() and onFocusGenerationChanged gate on lockRequested / inputEnabled but not on !authenticatingPassword, so retries landing mid-authentication hit a disabled field and do nothing.

Two things outside its scope that you may care about. #8930 identifies a genuinely different way the lock ends up unable to authenticate: a plugin reload destroying the live WlSessionLock while the compositor keeps the session locked, leaving no client behind the lock. No amount of refocusing touches that one; omarchy-shell lock status reporting sessionLocked: false while the screen is still locked is the tell, and it is worth checking whether any of your resume failures were that. Separately, #9325 reports the same symptom after resume caused by fcitx5 wedging the input method rather than by focus — the tell there is that clicking the field does not help and only systemctl --user restart omarchy-fcitx5.service does. If any of your own failures survive a click, that is a third bug, not this one.

Not a v4.0.2 regression: the only change to shell/plugins/lock/ in that release is a one-line textFormat: Text.PlainText addition to the placeholder label. The behaviour arrived with the Quickshell lock in 7ea4e1ab ("Switch hyprlock to QS"), in 4.0.0.

Six open PRs now propose fixes for this — #7164, #7592, #8560, #8869, #9181 and #8930 — so which one lands is the maintainer's decision rather than triage's, and I have not opened a competing one. #9181 was read as part of this diagnosis and will be reviewed on its own thread.

Status: explained — mechanism proven in source, not reproduced. The worker fleet had no free slots during this run, so no suspend/resume cycle was exercised. Reviewed by Claude Opus 5 and independently by Codex at xhigh reasoning; where the two agreed, that agreement is not fully independent, since Codex can read the first reviewer's working notes.

omarchybot avatar Aug 31 '26 12:08 omarchybot

Adding a single-monitor data point, plus a limit I ran into testing #9181.

Setup: Omarchy 4.0.0.r1980 (Quattro), Hyprland, single DisplayPort output, RTX 3080 / NVIDIA 610.57.04, kernel 7.2.2. Suspend triggered by hypridle, so the session is locked before sleep.

Symptom: after resume, the password field has no keyboard focus — typing does nothing until I click into it. A plain lock without suspend focuses correctly.

Testing #9181: I cloned omarchy.lock and applied the PR. Plain lock still focuses correctly, but after suspend/resume the field still needs a click.

Why it doesn't reach my case: none of the PR's three focus triggers fire on resume here.

  • Quickshell.onScreensChanged — my lock surface is not recreated on resume. No lock-requested, no Not creating lock surface in the journal; the view survives the suspend untouched.
  • lock becoming secure — that happens before the suspend (secure=true at 13:02:51, PM: suspend entry in the same second), so it is far too early.
  • PAM releasing the input — not applicable.

On multi-monitor, output recreation effectively doubles as a resume signal. With a single output there is no such signal.

Deeper cause: nothing in Omarchy listens for resume at all. omarchy-system-sleep-monitor matches PrepareForSleep only for boolean true, then returns:

if [[ $line == *"boolean true"* ]]; then
  "$sleep_lock"
  return 0
fi

So there is no event a focus recovery could hook into on the way back up.

What worked here: on top of #9181, I exposed beginPasswordFocusRecovery() as an IPC method and drove it from a small user unit listening for PrepareForSleep = boolean false, retrying for ~11s since input devices come back a few seconds after resume. Password entry then works without clicking, on the first try.

Handling PrepareForSleep=false inside the lock service itself would make the recovery independent of monitor count. Happy to test any patch.


Investigated and written by Claude Opus 5 (Claude Code), on my machine and with my logs.

ledubois avatar Sep 01 '26 17:09 ledubois

@ledubois Thank you for isolating the preserved single-output case. I have updated #9181 with a persistent logind sleep monitor and an explicit resumeFromSleep IPC path, so focus recovery no longer depends on screensChanged, secure-state changes, or PAM completion. Resume runs the complete twelve-second retry budget, and the monitor rearms the next sleep inhibitor before retrying the shell notification.

The corrected branch passed its focused tests and a real dual-output S3 cycle, including a normal first unlock. If you are willing to retest #9181 on the single-output setup from your report, that would verify the exact preserved-surface topology that motivated this correction.

ClGratton avatar Sep 02 '26 09:09 ClGratton

Hit this on single-monitor AMD hardware (the existing report was NVIDIA dual-DP), and in my case the lock never recovered at all — it ended in a hard reboot. Adding the data point in case it helps narrow the focus-recovery path.

Environment

  • Omarchy 4.0.2-1
  • Kernel 7.1.9-arch1-2 (uname -r)
  • Hyprland 0.56.2-1, quickshell 0.3.1-1, qt6-base 6.11.2-2
  • GPU: AMD Radeon 780M / Phoenix1 (amdgpu, RDNA-3), single monitor HDMI-A-1 3440x1440
  • fprintd not installed — password-only lock (omarchy-lock-password)
  • SDDM autologin into uwsm start ... Hyprland

What happened

  1. Machine was idle (screen off). Woke it — omarchy idle ... idle-monitor: active.
  2. Lock screen up. Typed password once, got it wrong: one pam_unix(omarchy-lock-password:auth): authentication failure.
  3. Lock UI then accepted no further input. Typing + Enter did nothing — no new Password: prompt was ever relayed, no second PAM session started.
  4. After ~4 minutes I gave up, switched to a TTY (Ctrl+Alt+F3), and rebooted to get back in.

Journal (previous boot, times CDT)

21:46:33  omarchy-shell[1345]:  omarchy idle ... idle-monitor: active
21:46:44  omarchy-shell[376723]: quickshell.service.pam.subprocess: Starting pam session for user "layer8man" with config "omarchy-lock-password"
21:46:44  omarchy-shell[376723]: quickshell.service.pam.subprocess: Relaying pam message: "Password: " echo: 0 error: 0 responseRequired: 1
21:46:44  quickshell[376723]:    pam_unix(omarchy-lock-password:auth): authentication failure; ... user=layer8man
21:46:46  omarchy-shell[376723]: quickshell.service.pam.subprocess: Got response ...: Failed to authenticate.

--- 21:46:46 -> 21:50:48 : ~4 min, ZERO further output from the lock process (376723). ---
--- No new "Password:" prompt, no second auth attempt, no lock-requested / unlocked events. ---

21:50:48  login[407907]: LOGIN ON tty3 BY layer8man      # escaped to a TTY
21:54:16  systemd[1]: (full system shutdown — I rebooted)

Throughout the session the shell logs a constant stream of qt.qpa.wayland: There are no outputs - creating placeholder screen, Not creating lock surface for screen QScreen(..., name="") as it is not backed by a valid wayland output, and quickshell.hyprland.ipc: Got removal for monitor "FALLBACK" which was not previously tracked (every ~18s, unrelated to the lock). So there's frequent phantom-output churn on this box even single-head, which is presumably what defeats the focus-recovery here too.

Not a pam_faillock lockout

For anyone finding this by searching "locked out after one wrong password": it is not an account lockout. /etc/pam.d/omarchy-lock-password and system-auth use pam_faillock with deny=10 / unlock_time=120, and faillock showed zero recorded failures afterward. The lock UI is just wedged.

Happy to test PR #9181 on this hardware.

layer8man2 avatar Sep 09 '26 03:09 layer8man2

Reproduced on Omarchy 4.0.3-1 / Hyprland 0.56.2 / Quickshell 0.3.1 (single internal display, Intel+NVIDIA hybrid — not the multi-monitor case this issue focuses on, but same underlying symptom after suspend/resume via the system menu Suspend action). Sounds like PR #9181 already has a verified fix for the output-recreation path — any chance that gets merged? Still open on 4.0.3-1.


Posted by Claude Code on behalf of typebrook

typebrook avatar Sep 13 '26 21:09 typebrook

Re-checked against current quattro (b83d3df08). The bug is still there: LockView.qml asks for focus only in Component.onCompleted, when inputEnabled changes, and on a click (LockView.qml:81-86, 151), and onScreensChanged in Service.qml:786 asks for none. The recent lock changes on quattro (#7158, #7806, #13431) touch fingerprint recovery, key repeat and the wallpaper, not focus.

What has changed since the last note here: #9181, the fix this issue pointed at, was closed on 2026-09-21 as a duplicate of #8560. That leaves three open pull requests, and none of them covers every case reported in this thread:

  • #8560 takes focus back when the field loses it. That covers a surface that survives resume and drops focus during it, which is what its own journal trace shows. It does nothing for a surface recreated on resume whose field never had focus to lose (the multi-output case in the report), since there is no focus change for it to react to, and it adds nothing when authentication ends. It carries verified from a worker probe of exactly the lose-and-retake case.
  • #7164 asks for focus once when the lock becomes secure. That happens before suspend, as @ledubois's journal shows, so it does not fire on resume at all.
  • #8930 retries focus for up to five seconds after construction, a screen change, a wake and the end of authentication, so it plausibly covers all three triggers. It is a large branch that also changes sudo and update handling, and has not been assigned for work here, so it has not been run on a worker. One gap the second opinion found in it: retries are suppressed while displayBlanked is set, and a screen change clears displaysBlank rather than displayBlanked, so the return of an output alone does not restart them.

None of the three asks the compositor to activate the lock window. Two single-output reports here (@ledubois, and @Henaneitor on #9181) say forcing item focus after resume was not enough until something activated the window, and that has not been established either way.

Not reproduced: a VM cannot suspend, so this was read in source rather than run. Reviewed by Claude Opus 5.5 in Claude Code, with a second opinion from Codex at medium effort, which read the three branches independently and reached the same conclusion: none of them, merged alone, is shown to close this issue. Its independence is not guaranteed, but the displayBlanked gap above is its finding.

No pull request is linked as closing this one, since none is shown to fix all of it. Which fix lands, and whether it should also handle resume directly, is the maintainer's decision, and the issue is waiting on that.

omarchybot avatar Oct 09 '26 09:10 omarchybot

I traced this one below the lock screen. The app-level PRs work around it, but the cause is in the compositor. Here's a proposal.

Root cause. When libinput removes the keyboards across suspend, Hyprland 0.56.2 drops the seat's keyboard capability without sending wl_keyboard.leave first. CWLSeatProtocol::updateCapabilities (src/protocols/core/Seat.cpp) sets m_currentCaps before anything else, and CWLKeyboardResource::sendLeave() does nothing once that bit is gone. Hyprland keeps its own focus on the lock surface, so when a keyboard comes back, the client's new wl_keyboard gets enter on the same surface without ever having seen a leave.

Qt's Wayland client doesn't handle that sequence. Destroying the keyboard deactivates the window, but Qt still remembers that surface as focused. When the enter arrives for the same surface, handleKeyboardFocusChanged sees nothing new and returns, so the window is never re-activated. That's why Window.active never comes back after resume (as seen in #15362), and why only grabbing item focus during the suspend (#8560) works.

wlroots compositors don't hit this: wlr_seat_set_capabilities sends leave before dropping the capability.

Reproduced without a suspend. I used headless Hyprland, a Quickshell WlSessionLock with a TextInput, and wtype virtual keyboards added and removed. Stock 0.56.2 sends capabilities(0) with no leave, then enter on the same surface. Window.active stays false and the keys never reach the field. Patched, a leave comes right before each capabilities(0), Window.active comes back after every re-add, and typing works with no click.

Proposed fix (Hyprland): before m_currentCaps changes, send leave on the keyboard resources when the keyboard bit is lost. Do the same for the pointer, as leave plus frame, matching wlroots. Hyprland's own focus is kept, so a re-added device enters the same surface. It's about 20 lines; diff here: https://github.com/omarchy-asus/omarchy-asus/pull/305/files (seat-leave-on-capability-loss.patch). We're shipping it in our Omarchy 4.5 RC build of Hyprland. Hyprland main still has the same gap.

Since Omarchy ships its own Hyprland build, carrying this there would fix the lock screen and every other Qt window after resume, with no change to LockView.qml. If you'd rather keep a lock-screen-only fix, #8560 is the one with hardware proof.

rdoupe avatar Oct 24 '26 21:10 rdoupe

Re-checked against current quattro (e2c7007c1). The maintainer merged #17277 there on 2026-11-01, and it covers the main case in this thread. It is not in a release yet: the newest tag, v4.5.0-rc2, comes before it.

What #17277 does. shell/plugins/lock/LockView.qml:89 now runs when the lock window's focus item changes. If the password field is enabled but has lost focus, it puts focus back on the field (LockView.qml:77-78).

What I ran. I used a worker VM built from the Omarchy ISO, with Hyprland 0.56.2. Keys were typed through a fresh uinput keyboard, and I checked whether dots appeared in the field. To stand in for the keyboard disappearing across suspend, I unbound every keyboard the seat had, so hyprctl devices listed none, then bound them again. That is the capability loss @rdoupe traced.

  • At 36566f517, the commit before #17277: a cold lock took typing. After the keyboards were removed and restored, typed keys never reached the field.
  • At e2c7007c1: after the same removal and restore, the keys showed up as dots.

Before #17277 (36566f517): after every keyboard is removed and restored while locked, typed keys never reach the field On quattro (e2c7007c1): after the same removal and restore, the typed keys show as dots

So on Hyprland as it ships today, the shell recovers without the compositor patch @rdoupe proposed. #17277 reacts when Qt drops the field's focus, not when the keyboard returns. Both second opinions traced why that works: forceActiveFocus() puts the field back as the window's focus item even though the window is never re-activated, so keys the compositor still sends to the lock surface reach the field. Whether to also carry the Hyprland patch is the maintainer's call. It would fix the same gap for every other Qt window, not just the lock.

What this does not show.

  • Multi-output resume, where surfaces are recreated. On the VM, I added a headless output while locked, focused it, typed, removed it and typed again. The keys landed at both commits, so the VM does not reproduce this case, and the run shows neither the bug nor a fix. Reading the code, a newly created view requests focus when it is built (LockView.qml:90-92), and the new hook runs again when that window's focus item changes. It is plausible that this case is covered, but nobody has shown it on hardware.
  • A real suspend. A VM cannot suspend. Unbinding the keyboards stands in for the keyboard part of a resume, not for the rest of it.

One gap is left, found by reading the code. While a password is being checked, the field is disabled (LockView.qml:165). Suppose focus leaves the window during the check, for example because a suspend lands then. The new hook runs while the field is still disabled, so its guard skips the refocus. When the check ends, nothing on quattro asks for focus again. The field gets focus back only if nothing else took it in the meantime. #8560 adds the missing step: an onAuthenticatingPasswordChanged handler that refocuses once the check ends. Since that pull request already exists, triage is not opening another one.

This was checked by Claude Opus 5.5 in Claude Code, with second opinions from Codex at medium effort and muse-wonder via pi at high effort. Both agreed on what #17277 covers, that the failed-password gap is real, and that #8560 closes it. Their independence is not guaranteed, because they can read this session's transcript. No pull request is linked as closing this issue, because none is shown to fix all of it.

Waiting on the maintainer: whether to take #8560's post-check refocus on top of #17277, and whether to carry the Hyprland seat patch. Once a release with #17277 ships, it would help to hear from reporters on both setups. On a single output (@ledubois, @layer8man2, @typebrook): does typing work straight after resume? On two outputs (@ClGratton): does it work there too?

omarchybot avatar Nov 01 '26 23:11 omarchybot