Skip to content

Accept keypad digits on the lock screen while NumLock is desynced - #12667

Open
prabhchintan wants to merge 3 commits into
omacom:quattrofrom
prabhchintan:lock-keypad-digits
Open

prabhchintan wants to merge 3 commits into
omacom:quattrofrom
prabhchintan:lock-keypad-digits

Conversation

@prabhchintan

Copy link
Copy Markdown

Problem

Typing a digit on the numeric keypad does nothing in the lock screen's password field. The same digit on the number row types fine. Anyone whose password has digits typed on the keypad has to toggle NumLock off and on at every lock (#8552).

Cause

Qt never reads the compositor's NumLock state at startup (QTBUG-32687). Even with NumLock on, the keypad reaches the field as Home, Up, PageUp and the rest with Qt.KeypadModifier set and no text, and TextInput treats them as cursor movement.

Fix

Map those keys back to their digits in the field's key handler when KeypadModifier is set. Digits that already carry text, the top row and plain cursor keys are untouched, and nothing is inserted while the field is read-only during authentication.

Same approach as #10530 takes for the polkit dialog. The lock keeps its own model so the two can land independently; if both land, the two helpers can fold into one.

Test plan

  • test/shell.d/lock-keypad-test.sh covers the mapping and the keys that must stay untouched
  • A Quickshell harness driving the real LockView field: keypad Home, End and Delete type 71., plain Home stays cursor movement, Key_7 with text is left to the field, nothing is inserted while authenticating
  • Neighbouring polkit, lock-* and menu shell tests pass
  • Live on Omarchy 4.0.4 (Apple Magic Keyboard with Numeric Keypad, NumLock on in Hyprland): digits type on the lock screen, the number row still works

Typing a digit on the numeric keypad does nothing in the lock screen's
password field, while the same digit on the number row types fine. Qt
never reads the compositor's NumLock state at startup (QTBUG-32687), so
even with NumLock on the keypad reaches the field as Home, Up, PageUp
and the rest with KeypadModifier set and no text, and the field treats
them as cursor movement. Anyone whose password has digits typed on the
keypad has to toggle NumLock off and on at every lock.

Map those keys back to their digits in the field's key handler when
KeypadModifier is set. Digits that already carry text, the top row, and
plain cursor keys are untouched, and nothing is inserted while the
field is read-only during authentication.

Same approach as omacom#10530 for the polkit dialog; the lock keeps its own
model so the two can land independently.

Fixes the lock screen half of omacom#8552.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

One layout-dependent limitation remains in the keypad workaround at 828ac788.

Verified by source inspection: keypad navigation-key events map to digits, while ordinary number-row/navigation keys pass through and the read-only guard prevents insertion during authentication.

The decimal key becomes the wrong character on comma layouts

LockModel.js:16 unconditionally maps keypad Delete to .. The default German keymap uses KP_Separator (,) when NumLock is synchronized, but the same KP_Delete event as dot layouts when it is off/desynchronized.

Source-derived comparison, not a live keyboard test:

Decimal-key mapping NumLock synchronized Desynchronized, with this PR
Dot layout . .
Comma layout, such as default German , .

Impact: a password containing a keypad-entered comma still cannot be entered correctly through this workaround. Unlike the baseline's lack of character insertion, the field now gains a masked character, making the wrong separator less apparent. This is incomplete layout support, not a newly introduced authentication failure.

Suggested change: avoid assuming . for the decimal key. Either leave that key outside the workaround and document the remaining NumLock-toggle requirement, or derive the separator from the actual keymap. The desynchronized event alone does not distinguish comma from dot layouts.


Review information

Test scope: source inspection of the pinned change, lock-service wiring, xkeyboard-config symbol definitions and Qt 6.11.2 key mapping. No runtime tests, live lock/PAM authentication or physical-keyboard validation were performed. The handler also converts keypad navigation when NumLock is intentionally off; dedicated navigation keys remain unaffected.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra Medium initial inspection, independent Opus 5.5 High and GPT 6 Sol Xhigh technical reviews, followed by Astra Medium synthesis and verification against source evidence.

It arrives as Delete on every layout but types "." on some and ","
(KP_Separator) on others, which the desynced event cannot tell apart.
@prabhchintan

Copy link
Copy Markdown
Author

Good catch, and verified here against xkeyboard-config: the German keypad's decimal key is KP_Separator at level one, so a desynced Delete cannot be mapped to a single character safely. Dropped the decimal key from the mapping in the follow-up commit; the digits, which #8552 is about, still type, and the decimal key falls through to the field as before. Test updated to pin that.

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up to the earlier review and the author's reply, checked at 701b87e8.

Resolved: the keypad decimal key no longer types . on comma layouts. 701b87e8 removes the Key_Delete → . mapping and leaves the handler unchanged.

Verified with a Qt 6.11.2 test harness that drives the real LockView.qml field with synthesized key events:

Desynced keypad keys: 7, 1, decimal, 4 (arriving as Home, End, Delete, Left) Field text
Base branch ""
828ac788 71.4
701b87e8 714

The reply's "falls through to the field as before" is accurate. While desynced, the decimal key arrives as Delete with no text on both dot and comma layouts, and the field handles it as a forward delete, as on the base branch. With the cursor at the end and nothing selected it changes nothing, so a password containing a keypad decimal still needs NumLock toggled. For example, keypad 12.5 submits 125.

The earlier verified statements still hold at this head: desynced keypad keys type digits, the number row and dedicated navigation keys pass through, and nothing is inserted while authenticating. The branch merges cleanly with the current quattro tip, and lock-keypad-test.sh passes on that merge.

Keypad digits do not replace a selection

This is present since 828ac788; the new commit did not introduce it. LockView.qml:63 calls passwordInput.insert(passwordInput.cursorPosition, digit). In Qt 6.11.2 the public TextInput.insert() keeps an existing selection, while typed text replaces it. Harness results:

After typing ab, then Ctrl+A Field text
Number-row 7, 1 71
Desynced keypad 7, 1 ab71

Impact: selecting the password to retype it with keypad digits submits the old text plus the new digits. The attempt fails, and in the masked field the cause is easy to miss.

Suggested change: remove the selection before inserting:

if (passwordInput.selectionStart !== passwordInput.selectionEnd)
  passwordInput.remove(passwordInput.selectionStart, passwordInput.selectionEnd)

In the same harness this makes the Ctrl+A case type 71 and leaves the other cases unchanged. #10530 uses the same insert pattern in the polkit dialog.

Optional test improvement: lock-keypad-test.sh loads only LockModel.js, so it would still pass if the Keys.onPressed branch in LockView.qml were removed. The existing Quickshell-driven lock-password-overflow-test.sh and its fixture show a way to cover the KeypadModifier gate, the read-only guard and the selection case.

Documentation: the PR description's test plan still says keypad Home, End and Delete type 71.; at this head they type 71, and the decimal key still needs the NumLock toggle. Separately, the comment at LockModel.js:1-2 attributes the desync to QTBUG-32687, a Qt 5.1 report closed in 2013. In Qt 6.11.2's Wayland client, the compositor's locked modifiers are applied and are lost when a later keymap event creates a fresh keyboard state, which matches the cause discussed recently in #8552. Naming the actual trigger would make it clearer when the workaround can be removed.

Related open PRs: #11072 also adds shell/plugins/lock/LockModel.js with different helpers; a simulated merge reports an add/add conflict, so whichever lands second has to combine the two files. #10530 still maps keypad Delete to ., so the two helpers now disagree on the decimal key if they are folded together as the PR description proposes.


Review information

Test scope: source inspection of the new head, the previously reviewed head and the base, with Qt 6.11.2, libxkbcommon 1.13.2 and xkeyboard-config 2.48. The PR's test was run in an isolated sandbox at the head and on a simulated merge with the current base. A Qt 6.11.2 QML test harness drove LockView.qml offscreen with stubbed shell modules and synthesized key events. No live keyboard, compositor, lock surface or PAM authentication was used. The related-PR search was keyword-based, not exhaustive.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

TextInput.insert() leaves an existing selection in place, while typed text replaces it, so selecting the password and retyping it with keypad digits submitted the old text plus the new digits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed by Claude Opus 5.5 and verified on a disposable Omarchy worker. The fix works, and I pushed one small correction to your branch.

Reproduced. A Quickshell harness drove the real LockView password field with the key events Qt delivers while NumLock is desynced: keypad keys arriving as Home, End, Left and the rest with KeypadModifier and no text. On quattro, and on this branch with the LockView.qml change reverted, they type nothing. On this branch all ten type 0–9, both on its own and merged into the current quattro (821ae58). The rest behaves as described: a keypad 7 that already carries text types once, the number row and a plain Home are unchanged, the desynced decimal key inserts nothing, and nothing is typed while the password is being checked.

Pushed b164715: a keypad digit now replaces a selection. TextInput.insert() keeps an existing selection where typed text replaces it, so selecting the password with Ctrl+A and retyping 71 on the keypad gave ab71 where the number row gives 71. insertKeypadDigit now removes the selection before inserting. The same harness gives 71 for both after the change.

Tests on the worker: lock-keypad-test.sh (14 checks), polkit-test.sh, the lock overflow, fingerprint and stranded-recovery tests and ./test/cli pass. The full ./test/shell run has three failures, in ascii-test.sh, branding-about-animation-test.sh and omarchy-kernel-migration-test.sh. All three fail the same way without this change, so they are not caused by it. GitHub reports no CI checks on this branch.

No second opinion yet. The second reviewer, Codex Medium, answers, but omabot's daily review budget was spent before it reached this pull request, so nothing has checked this review. It stays short of ready until a later run gets a second opinion on this head.

#8552 is not linked as fixed, because it also covers the polkit dialog (#10530) and the launcher. Waiting on the second opinion, then on the maintainer.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Handles keypad input on the lock screen.

The PR should not merge until intentional NumLock-off keypad navigation is preserved.

Findings

  1. P1 Keypad navigation inserts digits ▶
  2. P2 Keypad handler remains untested ▶

Summary

The PR adds a lock-screen keypad keycode mapping, invokes it from the password field, and tests the mapping.

  • Desynced keypad navigation keycodes are converted to digits while the field is editable.
  • Deliberate NumLock-off keypad navigation is also converted to digits.

Reviews (1) · Last reviewed commit: "Replace a selection when a keypad digit ..."

Comment on lines +60 to +65
if (passwordInput.readOnly || !(event.modifiers & Qt.KeypadModifier)) return false
var digit = LockModel.keypadDigit(event.key)
if (digit === "") return false
// insert() keeps a selection where typing replaces it.
if (passwordInput.selectionStart !== passwordInput.selectionEnd) passwordInput.remove(passwordInput.selectionStart, passwordInput.selectionEnd)
passwordInput.insert(passwordInput.cursorPosition, digit)

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.

P1 Keypad navigation inserts digits
If a user deliberately turns NumLock off and presses keypad Home, End, or an arrow key to move the cursor, this handler inserts a digit instead. Shift- and Control-modified keypad navigation is intercepted too, so moving the cursor or extending a selection can change the password.

Comment on lines +5 to +6
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

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 Keypad handler remains untested
This test calls only the JavaScript keycode mapping; it never sends a key through the lock screen's password field. A regression in the new modifier check, selection replacement, or read-only guard could therefore pass the test while keypad input behaves incorrectly.

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!

@LeoMrel

LeoMrel commented Oct 21, 2026

Copy link
Copy Markdown

Independent confirmation from another affected setup, in case it helps move this forward.

Omarchy 7.2.8, Hyprland, ASUS laptop + external USB keyboard. After a real suspend/resume the lock screen keypad types navigation keys (KP_7 → Home, KP_4 → ←…) while hyprctl devices -j reports numLock: true on every keyboard and the LED is on. A manual omarchy-system-lock is fine, and I ruled out fcitx5, clamshell handling, DPMS cycles and hyprctl reload.

I'm running a local patch that does essentially what this PR does (map Qt.KeypadModifier + Insert/End/Down/PageDown/Left/Clear/Right/Home/Up/PageUp to digits 0–9 in the password field's Keys.onPressed), and it fully fixes the symptom after suspend, with no side effects on the main-cluster arrow keys. I haven't tested this PR's own code, only an equivalent mapping.

On the Greptile P1 (user deliberately has Num Lock off): on a password field I don't see that as a practical problem, since the keypad navigation keys have no use there.

Related: #8552, #12438, and PR #12435 (which explains that every suspend removes/re-adds the input devices, clearing Qt's state).

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

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants