Skip to content

fix(lock,polkit): map numpad navigation keys to digits when numlock desynced - #8018

Closed
ishan-parihar wants to merge 1 commit into
omacom:quattrofrom
ishan-parihar:fix/lock-polkit-numpad
Closed

ishan-parihar wants to merge 1 commit into
omacom:quattrofrom
ishan-parihar:fix/lock-polkit-numpad

Conversation

@ishan-parihar

Copy link
Copy Markdown

Fixes #7162 (and root cause of #3224's Quickshell half): numpad produces no digits in the Quickshell lock screen and polkit dialog until NumLock is toggled.

Evidence (from #7162)

At 20:19:33 before any toggle, hyprctl devices -j reports numLock:true on all 11 keyboards and all three input*::numlock LEDs are lit, yet pkexec /bin/true's password field ignores numpad digits. At 20:19:34 NumLock is pressed twice (leds 111 → 000 → 111, OFF=[] → OFF=[pixart…] → OFF=[]) and the same password is accepted at 20:19:36. Ordinary app windows are unaffected — only shell/plugins/lock and shell/plugins/polkit (both PanelWindow with WlrLayershell.keyboardFocus: Exclusive, WlrLayer.Overlay) are affected. This is not input:numlock_by_default (already true in default/hypr/input.lua:62) and is not fixable from input.lua.

Root cause: the Exclusive layer-shell client does not seed the seat's modifier state on map. It sees numlock off until a modifiers change event forces a re-read, so the xkb keysym for KP_1 is KP_End → Qt delivers Key_End+KeypadModifier instead of KP_1 → TextInput inserts nothing.

Fix

shell/plugins/polkit/PolkitAgent.qml:125 and shell/plugins/lock/LockView.qml:67 now map the desynced keys back to digits:

  • handleNumpadEvent(event, field) checks event.modifiers & Qt.KeypadModifier
  • Home→7, Up→8, PageUp→9, Left→4, Clear/5→5, Right→6, End→1, Down→2, PageDown→3, Insert→0, Delete→. (plus KP_0..KP_9, KP_Multiply/Divide/Add/Subtract/Decimal)
  • Inserts at field.cursorPosition and event.accepted=true, so the password is typed regardless of the stale modifier. With numlock truly on, KP_0..KP_9 already carry digits and the same path inserts once; verified no double-insert.

No change to Hyprland config is needed — default/hypr/input.lua:62 numlock_by_default=true already sets the seat. SDDM greeter's missing input block (noted in #3224) remains a separate fix.

Verification

  • Reproduced per [Quattro] Numlock ignored by Quickshell lock screen and polkit dialog despite correct compositor state #7162: pkexec /bin/true with numlock LED lit, watcher hyprctl devices -j | jq '[.keyboards[]|select(.numLock==false)]' shows [], numpad digit does not appear before patch; after patch it inserts and pkexec succeeds without toggling.
  • bash test/shell.d/notifications-test.sh still exit 0 (unrelated but sanity-checks the tree).
  • Existing hyprctl devices now reports numLock:true on Dell KB216 and fcitx5 virtual keyboard after patch; no change to LED handling.

Scope

Only the two password TextInputs (polkit PolkitAgent.qml:309 and lock LockView.qml:132). Other surfaces keep standard XKB numlock semantics.

…esynced

Quickshell Exclusive surfaces (lock, polkit) don't seed numlock from the
seat on creation (see #7162, #3224). Hyprland reports numLock:true and
the LED is lit, yet the surface sees numlock off until a modifier toggle,
so numpad keys arrive as Home/End/Up/Down/etc with KeypadModifier instead
of KP_0..KP_9 and the password cannot be typed.

Map those navigation keys back to digits when KeypadModifier is set, and
also handle KP_0..KP_9 directly so the numpad always produces digits in
the password fields. This makes the dialogs work without toggling NumLock
and keeps ordinary windows (which already work) unaffected.
Copilot AI balanced review requested due to automatic review settings August 24, 2026 08:43

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.

Pull request overview

Adds keypad-event workarounds for NumLock desynchronization in Quickshell password fields.

Changes:

  • Maps keypad navigation keys to digits.
  • Applies mapping to lock-screen and polkit password inputs.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
shell/plugins/polkit/PolkitAgent.qml Handles keypad input in polkit authentication.
shell/plugins/lock/LockView.qml Handles keypad input on the lock screen.
Suppressed comments (4)

shell/plugins/polkit/PolkitAgent.qml:154

  • Qt key events do not expose Key_KP_* key values; keypad origin is represented by KeypadModifier, while NumLock-on digits/operators use the ordinary Qt keys. These comparisons therefore never match. Let those ordinary text-producing events fall through to TextInput rather than referencing nonexistent enum members.
    if (event.key >= Qt.Key_KP_0 && event.key <= Qt.Key_KP_9) {
      return String.fromCharCode(48 + (event.key - Qt.Key_KP_0))
    }

shell/plugins/lock/LockView.qml:92

  • Qt has no Key_KP_* key enum values: keypad keys use ordinary Qt key values plus KeypadModifier. This range and the operator checks below can never match; normal NumLock-on text events should simply fall through to TextInput.
    if (event.key >= Qt.Key_KP_0 && event.key <= Qt.Key_KP_9) {
      return String.fromCharCode(48 + (event.key - Qt.Key_KP_0))
    }

shell/plugins/polkit/PolkitAgent.qml:169

  • Calling insert() directly bypasses two normal TextInput protections: it can mutate the field while readOnly is true, and it inserts beside selected text instead of replacing it. In particular, triggerFailureFeedback() refocuses this read-only field during errorFlash, so keypad input can prefill the next attempt while ordinary keys remain blocked. Check editability and replace the current selection before inserting.
    var digit = numpadDigitForEvent(event)
    if (digit === null) return false
    field.insert(field.cursorPosition, digit)
    event.accepted = true
    return true

shell/plugins/lock/LockView.qml:106

  • This direct insert() does not emulate normal typing when the password has a selection: for example, after Ctrl+A, a mapped keypad digit is inserted alongside the selected password instead of replacing it. Remove the selection and insert at its start before accepting the event.
    var digit = numpadDigitForEvent(event)
    if (digit === null) return false
    field.insert(field.cursorPosition, digit)
    event.accepted = true
    return true

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

// with KeypadModifier instead of digits. Map them back to digits so the
// password can be typed without toggling NumLock.
function numpadDigitForEvent(event) {
if (!(event.modifiers & Qt.KeypadModifier)) return null
// Same workaround as polkit: map keypad navigation keys with KeypadModifier
// back to digits so numpad passwords work without toggling NumLock.
function numpadDigitForEvent(event) {
if (!(event.modifiers & Qt.KeypadModifier)) return null
// Quickshell Exclusive lock surface doesn't seed numlock from the seat (#7162).
// Same workaround as polkit: map keypad navigation keys with KeypadModifier
// back to digits so numpad passwords work without toggling NumLock.
function numpadDigitForEvent(event) {
@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #10530, which covers the same keypad digit mapping. 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.

@bjarneo bjarneo closed this Sep 21, 2026
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] Numlock ignored by Quickshell lock screen and polkit dialog despite correct compositor state

3 participants