Skip to content

Keep lock password field focused - #10944

Open
ArveLomsland wants to merge 1 commit into
omacom:quattrofrom
ArveLomsland:fix-lock-password-focus
Open

ArveLomsland wants to merge 1 commit into
omacom:quattrofrom
ArveLomsland:fix-lock-password-focus

Conversation

@ArveLomsland

Copy link
Copy Markdown

Summary

  • keep the lock screen password TextInput as the active focus target whenever password input is available
  • reschedule focus after password authentication finishes
  • add shell coverage for the lock focus guard and recovery hooks

Tests

  • ./test/shell.d/lock-focus-test.sh
  • ./test/shell (timed out after 120s in this environment after passing the new lock focus test and continuing through later suites)

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for this, @ArveLomsland. Reviewed by Claude Opus 5.5 in Claude Code and, as a second opinion, Codex at medium effort. The verdict is that #8560 is the better fix for the same problem, so this one is left for the maintainer to decide on rather than brought to ready.

What ran. On a disposable VM with a real compositor, I locked the session, first serving quattro and then this branch at 27b3c10, and typed into it with wtype along four paths: a fresh lock, a wrong password followed by more typing, a lock left until the screen blanked and woken by a keypress, and an output added and removed while locked. On quattro the field kept keyboard focus on every path, and after two failed attempts the third password unlocked without a click. So the failed-password path this change re-focuses on is not broken on quattro. Qt keeps the field's focus while it is disabled for the PAM check and gives it back when it is enabled again, which matches what Codex found reading QQuickItemPrivate::setEffectiveEnableRecur(). This branch behaved the same on all four paths, with no QML warnings and the lock preview unaffected, so I found no regression. A VM cannot suspend, so the suspend case was not reproduced here. node is not on the worker image, so the node-based lock tests, including lock-focus-test.sh, did not run there. The other lock tests passed.

Which part does the work. Of the three mechanisms, the one that addresses the real reports (#12525, focus lost across suspend) is the onActiveFocusChanged reclaim at LockView.qml:173. The onAuthenticatingPasswordChanged handler and the focus: binding cover a loss that does not happen. #8560, opened earlier, is that same reclaim and nothing else. It has been reproduced on a worker by taking focus from the field, and two people have confirmed it fixes typing after resume on their laptops. Codex chose #8560 too when asked which of #8560, #10944 and #13907 to prefer. It also showed that lock-focus-test.sh still passes with forcePasswordFocus() turned into a no-op, because it matches the source text and never drives focus.

Neither fix can restore focus the compositor withheld, because forceActiveFocus() only moves Qt's focus inside the window. That is the cause #12587 suspects for the DPMS-wake case.

Next: waiting on the maintainer to choose between this and #8560. #13907 also re-focuses after a failed password.

@jandrusk

Copy link
Copy Markdown

Thanks for this. omarchybot's review prefers #8560 for the same focus-loss-after-suspend case, and there's a cluster of related lock-focus PRs (#14882, #13907, #12435). Let's leave this closed in favor of #8560 unless that one stalls.

@brightwalker25

Copy link
Copy Markdown

Tested the onAuthenticatingPasswordChanged refocus from this PR on Omarchy 4.0.4 (quickshell 0.3.1). Without it, one wrong password after resuming from suspend left the lock screen on "Authentication failed (1)": no further keystrokes reached the field, the journal showed no second PAM attempt, and only a reboot got back in. With it, a wrong password followed straight away by the right one unlocks without clicking.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks, @brightwalker25, that report was worth following up. Reviewed again by Claude Opus 5.5 in Claude Code, with Codex at medium effort as the second opinion. My earlier comment here said the onAuthenticatingPasswordChanged handler covers a focus loss that does not happen. That was wrong for one case, and this PR handles that case where #8560 does not.

What was missing. While the password is checked, the field is disabled. Qt takes active focus away from a disabled item but remembers that it should have focus, and gives focus back when the item is enabled again. That is why a plain wrong password works on quattro. If something else takes focus during the check, Qt no longer remembers it, and re-enabling the field gives nothing back. #8560's onActiveFocusChanged reclaim cannot help: the field had already lost active focus when it was disabled, so nothing fires again. Codex, asked about this case, confirmed the mechanism from Qt's setEffectiveEnableRecur and focus-scope code. Its independence is not guaranteed. This is consistent with the report above, though which resume event takes the focus is not established.

What ran. On a disposable VM with a real compositor, I hosted the real LockView in a window and ran three cases: focus moved to the surface's own item during the check, another item took focus during the check, and a plain failed check. On quattro and on #8560's head f5009085, the first two cases ended with the field unfocused, three runs out of three. The plain failed check was fine on both. This branch at 27b3c10 passed all three cases, three runs out of three. #8560 with only this handler added also passed all three:

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

A VM cannot suspend, so this models the focus change in a window, not the resume itself or a real PAM check.

Which one. #8560 is the older fix. It has a behavioural test and has been confirmed after resume on several machines. This handler is the only part of this PR it lacks. So I have handed the handler to #8560 to add, credited to @ArveLomsland, rather than bringing this one forward. Codex preferred bringing this PR forward instead, for the same missing case. With the handler added to #8560, that case is no longer a difference between them. Codex also noted that lock-focus-test.sh here matches source text and would still pass if schedulePasswordFocus() did nothing. It found no defect in the production change.

Next: waiting on the maintainer. The handler goes to #8560, and the choice between the two is theirs. Nothing is needed from you.

omarchybot added a commit to robouk/omarchy that referenced this pull request Oct 18, 2026
…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>
rdoupe pushed a commit to omarchy-asus/omarchy that referenced this pull request Oct 24, 2026
…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>
(cherry picked from commit 39691c1)
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.

4 participants