Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions shell/plugins/polkit/PolkitAgent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ Item {
return PolkitModel.authorizationLabel(message)
}

function insertKeypadDigit(event) {
if (fingerprintMode || passwordInput.readOnly || !responseRequired) return false
if (!(event.modifiers & Qt.KeypadModifier)) return false
var digit = PolkitModel.keypadDigit(event.key)
if (digit === "") return false
passwordInput.insert(passwordInput.cursorPosition, digit)
return true
}

function loadPamConfig(raw) {
fingerprintConfigured = PolkitModel.fingerprintConfiguredFromPamConfig(raw)
}
Expand Down Expand Up @@ -264,6 +273,8 @@ Item {
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
if (root.responseRequired) root.submitResponse()
event.accepted = true
} else if (root.insertKeypadDigit(event)) {
event.accepted = true
}
}
}
Expand Down Expand Up @@ -327,6 +338,8 @@ Item {
if (event.key === Qt.Key_Escape) {
root.cancelRequest()
event.accepted = true
} else if (root.insertKeypadDigit(event)) {
event.accepted = true
}
}
}
Expand Down
23 changes: 22 additions & 1 deletion shell/plugins/polkit/PolkitModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,31 @@ function authorizationLabel(message) {
return match ? "Authorize running '" + match[1] + "'" : text
}

// Qt never reads system NumLock at startup (QTBUG-32687), so keypad digits
// arrive as navigation keys. Values are Qt::Key_* from qnamespace.h.
function keypadDigit(k) {
switch (k) {
case 0x01000006: return "0" // Key_Insert
case 0x01000011: return "1" // Key_End
case 0x01000015: return "2" // Key_Down
case 0x01000017: return "3" // Key_PageDown
case 0x01000012: return "4" // Key_Left
case 0x0100000b: return "5" // Key_Clear
case 0x00000035: return "5" // Key_5 (some layouts)
case 0x01000014: return "6" // Key_Right
case 0x01000010: return "7" // Key_Home
case 0x01000013: return "8" // Key_Up
case 0x01000016: return "9" // Key_PageUp
case 0x01000007: return "." // Key_Delete
}
return ""
}

if (typeof module !== "undefined") {
module.exports = {
promptLooksFingerprint: promptLooksFingerprint,
fingerprintConfiguredFromPamConfig: fingerprintConfiguredFromPamConfig,
authorizationLabel: authorizationLabel
authorizationLabel: authorizationLabel,
keypadDigit: keypadDigit
}
}
15 changes: 15 additions & 0 deletions test/shell.d/polkit-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,19 @@ auth required pam_unix.so
`),
'polkit reports no fingerprint when pam_fprintd is absent'
)

assertEqual(polkit.keypadDigit(0x01000006), "0", "keypad 0 arrives as Insert when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x01000011), "1", "keypad 1 arrives as End when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x01000015), "2", "keypad 2 arrives as Down when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x01000017), "3", "keypad 3 arrives as PageDown when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x01000012), "4", "keypad 4 arrives as Left when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x0100000b), "5", "keypad 5 arrives as Clear when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x35), "5", "keypad 5 can arrive as Key_5 with KeypadModifier")
assertEqual(polkit.keypadDigit(0x01000014), "6", "keypad 6 arrives as Right when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x01000010), "7", "keypad 7 arrives as Home when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x01000013), "8", "keypad 8 arrives as Up when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x01000016), "9", "keypad 9 arrives as PageUp when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x01000007), ".", "keypad decimal arrives as Delete when NumLock is desynced")
assertEqual(polkit.keypadDigit(0x34), "", "top-row 4 is not remapped")
assertEqual(polkit.keypadDigit(0x01000004), "", "Return is not remapped as a keypad digit")
JS