Skip to content

Restore lock password focus after resume - #9181

Closed
ClGratton wants to merge 2 commits into
omacom:quattrofrom
ClGratton:fix/lock-resume-focus
Closed

ClGratton wants to merge 2 commits into
omacom:quattrofrom
ClGratton:fix/lock-resume-focus

Conversation

@ClGratton

@ClGratton ClGratton commented Aug 30, 2026 •

Copy link
Copy Markdown

Problem

After system resume, the visible password field can be left without keyboard focus. On multiple outputs, ext-session-lock surfaces may be recreated one after another. On a single output, the lock surface may survive suspend unchanged, so no screen-change callback occurs at all. A failed PAM attempt creates another focus-loss path because the password field is disabled during authentication and must be focused again after it is re-enabled.

Fixes #9180.

Cause

LockView previously made one imperative focus request during construction. Quickshell constructs lock views before the compositor can grant keyboard focus, and recreated views have no declared focus scope to restore. The earlier version of this PR retried on secure state, screen changes, and PAM completion, but a single-output lock surface can survive sleep without any of those events firing after resume.

Change

LockView is now a keyboard FocusScope with a declared focus target. The lock service sends explicit focus generations, acknowledges active focus, pauses while PAM owns a disabled field, and retries across sequential output recreation.

The sleep monitor now remains alive across the complete logind sleep cycle. After a known PreparingForSleep=false, it sends one generic resumeFromSleep IPC event to the lock service. Resume uses the complete twelve-second focus budget even if an early surface acknowledges focus. Unknown logind state never counts as resume, a vanished D-Bus producer is treated as failure, and the next delay inhibitor is armed before shell notification retries so a rapid second suspend remains protected.

The retry never submits or modifies password contents.

Verification

The focused lock, monitor, and sleep tests pass. The complete shell suite ran all 226 files on the corrected #9181 branch; every affected test passed, with only the five existing host/baseline failures in config-test, launch-about-test, runtime-smoke-test, snapper-test, and unowned-system-paths-test.

A real dual-output S3 cycle on NVIDIA and DisplayPort exercised the explicit resume event. Both outputs remained active, the full focus budget ran after logind reported resume, and the first unlock completed normally. A single-output reporter independently showed that an external PrepareForSleep=false listener driving the same recovery method fixes the preserved-surface case; the corrected branch is now available for an exact retest of that topology.

Copilot AI lite review requested due to automatic review settings August 30, 2026 14:27

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@isho

isho commented Sep 2, 2026

Copy link
Copy Markdown

BTW. I tried this on my local environment by copying the change and it solved my issue.

@freimer

freimer commented Sep 8, 2026

Copy link
Copy Markdown

Additional reproduction closely matching this focus-loss issue.

On Omarchy 4.0.2 with Quickshell 0.3.1, Hyprland 0.56.2, NVIDIA driver 610.57.04, and four outputs, waking an idle-locked session left the lock UI partially rendered. The password field was visible on some monitors, but pointer/keyboard focus could not reliably be restored. Clicking the password field did not fix it in this case.

The local journal showed simultaneous output-rendering failures:

qt.qpa.wayland: eglSwapBuffers failed with 0x3000
[nvidia-drm] Failed to allocate NVKMS memory for GEM object
qt.qpa.wayland: eglSwapBuffers failed with 0x3003

The installed LockView.qml already uses a full-surface MouseArea and calls forceActiveFocus() on click, so this appears to be beyond ordinary QML TextInput focus. It may involve Hyprland/session-lock input routing after output recreation, compounded here by the NVIDIA EGL allocation failure.
This was an idle display-blank wake, not a confirmed system suspend/resume cycle.

@Henaneitor

Copy link
Copy Markdown

Verified the same bug on a single-output NVIDIA desktop (Omarchy 4.0.3, Hyprland 0.56.2): lock taken before suspend, surface survives, typing does nothing until pointer input. forcePasswordFocus() alone after resume was not enough; the lock window is inactive until something activates it.

A PrepareForSleep=false listener that recovers focus (without requiring a click) unblocked keyboard-only unlock on that machine. This PR's sleep-monitor resumeFromSleep path is the right place for that event — more complete than putting a D-Bus watcher inside the lock plugin.

Related: #8361, #9180.

@adcuelloa

Copy link
Copy Markdown

Reproduced on current stable Omarchy 4.0.4-1.

Relevant environment:

  • Hyprland 0.56.2-2
  • Quickshell 0.3.1-1
  • kernel 7.2.5-3-omarchy
  • hybrid Intel/NVIDIA graphics
  • single active display

Before the workaround, the password field required a pointer click before accepting keyboard input. I cloned omarchy.lock and added the 250 ms self-healing focus guard proposed in #8628, paused while password authentication is active.

After applying it, I verified keyboard-only unlock in all three cases:

  1. Immediate manual lock: typed the password without pointer input.
  2. DPMS blank after locking: woke with Shift, then typed the password without pointer input.
  3. Suspend/lid resume: woke with Shift, then typed the password without pointer input.

This confirms the focus-loss symptoms and that repeated focus recovery covers this machine. I have not tested the #9181 branch itself, so this is supporting hardware/workaround evidence rather than a direct PR validation.

@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #8560, which covers the same lock focus restore on resume. I keep that one open and close this one to consolidate review.

If you feel this is the wrong decision, please open the PR again with a note on the difference.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

8 participants