Skip to content

Keep lock password field focused after resume from suspend - #16757

Open
cashcon57 wants to merge 1 commit into
omacom:quattrofrom
cashcon57:fix-lock-focus-after-suspend
Open

cashcon57 wants to merge 1 commit into
omacom:quattrofrom
cashcon57:fix-lock-focus-after-suspend

Conversation

@cashcon57

Copy link
Copy Markdown

Hey! This fixes something that had been bugging me for a while: after waking from suspend, the lock screen's password field looks ready, but typing does nothing until you click somewhere on the screen. Locking without a suspend (Super+Ctrl+L, idle lock) was always fine.

The fix: the password field takes focus back whenever it loses it while input is on. It's one handler on the TextInput in LockView.qml. While a password is being checked the field is disabled, and that case is left alone, since Qt already restores focus when the field re-enables (I checked: a wrong password never had this problem).

Why it happens: I traced it to Qt, not Omarchy or Hyprland.

  • Suspending takes the input devices away, so Hyprland drops the keyboard capability from the seat. That's correct, and so is what it does on resume: it re-adds the capability, and the new wl_keyboard gets an enter for the lock surface right away. From a WAYLAND_DEBUG trace of the shell across a suspend:
    wl_seat#4.capabilities(0)
    ...resume...
    wl_seat#4.capabilities(3)
     -> wl_seat#4.get_keyboard(new id wl_keyboard#120)
    wl_keyboard#120.keymap(...)
    wl_keyboard#120.enter(61510, wl_surface#103, ...)   <- the lock surface
    
  • Qt receives that enter but never re-activates the window. In Qt 6.12's Wayland plugin, QWaylandInputDevice::Keyboard::~Keyboard() calls QWindowSystemInterface::handleFocusWindowChanged(nullptr) directly, so QWaylandDisplay never clears mLastKeyboardFocus or mActiveWindows. When the replacement keyboard's enter arrives, handleKeyboardFocusChanged() sees the same window as last time and returns early. The window stays inactive, its activeFocusItem stays null, and keys are delivered to it with nothing focused to take them. It's still the same in Qt's dev branch.
  • I logged the lock window's state on my machine to confirm: active, then inactive the moment the suspend starts, then inactive all the way through resume until unlock. Calling forceActiveFocus() while the window is in that inactive state does work (that's exactly what the existing click handler does), which is why this fix is enough.

About the real fix: I know the proper fix belongs in Qt, and I'm planning to report it there. But getting a change through Qt's process takes a long time, and in the meantime every suspend on Omarchy hits this. So this works around it in the lock screen, in a way that does nothing once Qt is fixed: if focus is never lost on resume, the handler never runs. No version checks, nothing to remove later. It also covers any other way the field might lose focus that I haven't found.

Testing:

  • Several suspend/resume cycles on an ASUS ROG Zephyrus G14 (GA403UI), Hyprland 0.56.2, Qt 6.12.0, Quickshell 0.3.2: typing works straight after wake without a click. Before the fix, it failed almost every time.
  • Super+Ctrl+L, idle lock and a wrong password all still behave as before.
  • The tests that load LockView.qml pass on current quattro: lock-appear-budget, lock-autorepeat, lock-fingerprint-indicator, lock-poster, video-background.
  • I didn't add a test. The bug needs the lock window itself to lose and regain keyboard focus across a real suspend, and the shell test fixtures build LockView without a window. A test that only moves focus between items wouldn't fail for the reason this change exists. Happy to add one if you'd like it shaped differently.

Thanks for Omarchy, it's been really fun to tinker with!

🤖 Generated with Claude Code

https://claude.ai/code/session_013T5dtrbgarMEm8jyNFcGmX

Qt clears the lock window's focus when the seat loses its keyboard across a
suspend and never re-activates the window on resume, so typing did nothing
until a click. Take focus back whenever it is lost while input is on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013T5dtrbgarMEm8jyNFcGmX
@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Keeps the lock password field focused by scheduling forcePasswordFocus() when the enabled field loses focus.

  • The lock screen restores password focus when it is lost.

Reviews (1) · Last reviewed commit: "Keep lock password field focused after r..." · Reviewed by Greptile

@omarchybot omarchybot added the bug Something isn't working label Nov 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for the careful trace, @cashcon57. The Qt explanation is clear, and the fix in this pull request is sound.

Since you opened it, quattro has merged #17277 (1843592). It fixes the same symptom with the same approach: LockView.qml now listens on Window.onActiveFocusItemChanged and calls restorePasswordFocus(). That function gives focus back to the password field whenever the field should be taking keys and isn't, and it skips the field while a password is being checked. #17277 attributes the dropped keyboard to the VT switch NVIDIA forces around suspend. Your trace points to the seat dropping its keyboard. Either way, the field loses focus, the window's focus item changes, and that handler runs.

What was checked: I read this diff against current quattro, where it still merges cleanly. I did not run it on a worker: the code it changes already has the equivalent fix, so a test would only show that the two fixes coincide.

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) each read both diffs. Neither found a defect in this one. Neither found any focus-loss path that this pull request recovers and #17277 doesn't, and the two handlers together cause no conflict. Both concluded that #17277 supersedes this. Codex also pointed out that Qt changes the window's focus item before it changes the field's activeFocus, so #17277's handler runs on the same transition yours does. Their agreement is worth less than it sounds, because their independence isn't guaranteed.

What happens next: this is waiting on the maintainer, and my recommendation to them is to close it as covered by #17277. If typing after a resume still goes nowhere on current quattro without a click, please say so here. That would mean a path #17277 misses, and your trace would be the place to start.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants