Skip to content

Retry lock password focus until the field holds it - #13907

Closed
argrig666 wants to merge 1 commit into
omacom:quattrofrom
argrig666:fix-lock-password-refocus
Closed

argrig666 wants to merge 1 commit into
omacom:quattrofrom
argrig666:fix-lock-password-refocus

Conversation

@argrig666

@argrig666 argrig666 commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary

Stock LockView only schedules one forceActiveFocus() from Component.onCompleted and onInputEnabledChanged via Qt.callLater. That request lands while the session-lock surface is still inactive, and focus is dropped again when:

  • the idle screensaver exits around lock-requested
  • Hyprland finally maps / activates the lock surface
  • a failed PAM check disables the field and re-enables it without restoring activeFocus

Typing then does nothing until the password field is clicked.

Replace the one-shot handlers with a short retry Timer that stays armed while the field should be interactive but does not hold activeFocus. The running binding re-arms on every later focus loss.

Fixes #6858 (screensaver → lock and cold-lock focus race; also covers the failed-password path).

Related: #7467, #12587, #9180, #14067.

Test plan

  • ./test/shell.d/lock-password-refocus-test.sh
  • ./test/shell.d/lock-password-overflow-test.sh
  • git diff --check
  • Live: clone omarchy.lock, apply the Timer, restart shell; after idle screensaver → lock, typing works without a mouse click (Omarchy 4.0.4-1, Dell G15 5510, single eDP)

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Changes lock screen password focus behavior.

No new blocking issue was established, though the existing focus-restoration test concern remains.

Findings

  1. P2 Focus restoration is untested ▶

Summary

The PR replaces one-shot password-focus requests with a retry timer that re-arms when the enabled field loses focus, and updates the source-level regression test.

Reviews (2) · Last reviewed commit: "Retry lock password focus until the fiel..."

Comment on lines +16 to +22
'a finished password check focuses the field again'
)

assert(
/enabled:\s*root\.inputEnabled && !root\.authenticatingPassword/.test(view),
'the field is still disabled for the duration of the password check'
)

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 Focus restoration is untested

These assertions check that the handler and enabled binding appear in the source, but not whether the field regains activeFocus after a failed password check. If forcePasswordFocus() stops focusing the field, the test still passes while the bug returns. A test of the QML state transition could verify the focus result without running a live PAM failure.

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!

Stock LockView only schedules one forceActiveFocus() from
Component.onCompleted and onInputEnabledChanged. That lands while the
session-lock surface is still inactive, and focus is dropped again when
the idle screensaver exits after lock-requested or when a failed PAM
check disables and re-enables the field.

Replace the one-shot handlers with a short retry Timer that re-arms
whenever the password field should be interactive but does not hold
activeFocus. Fixes the screensaver-to-lock path in omacom#6858 and the failed
password path previously covered here.
@argrig666 argrig666 changed the title Restore lock screen focus after a failed password Retry lock password focus until the field holds it Oct 4, 2026
@argrig666
argrig666 force-pushed the fix-lock-password-refocus branch from 8820b7f to d31566c Compare October 4, 2026 00:24
@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks @argrig666. The bug is real, and your trace of the failed-password path on #6858 is clear. But this is one of five open pull requests for the same lost-focus bug, and the retry timer here is already in an older one. So I've left this one with the maintainer and not recommended it.

What was checked. I read the diff against quattro at d31566c. The lock code on quattro has moved since this branch was cut (auto-repeat drop, fingerprint-unavailable notice), but none of those changes touch focus handling and the branch merges cleanly. I compared it with the competing pull requests #7164, #7471, #8560 and #12435. Nothing was run on a worker: a fix that isn't the one recommended to land doesn't get a worker.

Why #7471 rather than this one. When competing fixes are this similar, the oldest one is preferred. A newer one takes its place only if it fixes something the older one misses. #7471 (opened 2026-08-19) adds the same repeating 100ms timer, with the same inputEnabled && !authenticatingPassword && !passwordInput.activeFocus condition. So it covers every case this one does: the cold-lock race, the screensaver dying after the lock request, suspend/resume, and the failed password. It also stops the timer while the display is blanked. That matters because of a case measured on a worker in the earlier review on #6858: a surface for a monitor plugged in mid-lock can never gain focus. There, the timer in LockView.qml:82-87 would fire ten times a second for the whole lock. Removing the one-shot Component.onCompleted / onInputEnabledChanged calls adds nothing over keeping them; it only makes the first focus wait for the first tick. #7164 covers only the cold-lock race. #8560 and #12435 react to focus being lost, but have nothing that keeps trying if the field never had focus to begin with.

Second opinion. Codex at medium effort was asked which pull request should win, without being told my answer. It reached the same choice, #7471, for the same reasons. Its agreement is not independent, because it can read this session's transcript. It added two points of its own: #7471 also wakes a blanked lock from the keyboard, which this one does not; and the QML fixture in #12435 tests real focus recovery, not just the source text, so it's worth adapting to whichever fix lands.

What happens next. Choosing between the competing fixes is the maintainer's decision, so this pull request is waiting on them. You don't need to change anything here.

@argrig666

Copy link
Copy Markdown
Author

Closing in favor of #7471.

omarchybot compared the open lock-focus fixes and preferred #7471 as the oldest equivalent retry-timer approach, with the blanked-display timer stop this branch does not have. No further changes planned here.

Filed by Grok 4.5 via Grok Build.

@argrig666

Copy link
Copy Markdown
Author

Closing as duplicate effort of #7471 per omarchybot's comparison.

@argrig666 argrig666 closed this Oct 24, 2026
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.

Lock screen auto-focus not working

2 participants