fix(lock): lock screen swallowed every keystroke; add Ctrl+L to lock
The renderer-side guard added in v1.0.17 called preventDefault on every keydown while locked. A keydown's default action IS inserting the character into the focused field, so the lock screen's password box received nothing and a locked app could never be unlocked. Menu accelerators are already stopped in main (before-input-event); the renderer guard now just skips its own logic. Also: Ctrl+L locks the screen from anywhere in the app, terminals included. The chord is only taken when a lock actually engages, so an unconfigured app keeps Ctrl+L for the shell's clear-screen.
This commit is contained in:
1 parent
244199c512
commit
83dc3f15cc
7 files changed
+31
-15
No files matched your search
+18
-1
@@ -166,12 +166,29 @@ function createWindow(): void {
|
||||
}
|
||||
})
|
||||
|
||||
// Ctrl+L is the panic lock: it must work from anywhere in the app, terminals
|
||||
// included, so it is captured here ahead of the page. It only takes the chord
|
||||
// away when a lock actually engages — an unconfigured app keeps Ctrl+L for
|
||||
// the shell's clear-screen.
|
||||
// Swallow the menu accelerators that would otherwise act behind the lock
|
||||
// overlay (see isLockBlockedShortcut). A throw in here would break typing
|
||||
// altogether, so the whole guard is defensive.
|
||||
win.webContents.on('before-input-event', (event, input) => {
|
||||
try {
|
||||
if (input.type !== 'keyDown' || !getLockController().isLocked()) return
|
||||
if (input.type !== 'keyDown') return
|
||||
const lock = getLockController()
|
||||
if (
|
||||
!lock.isLocked() &&
|
||||
input.control &&
|
||||
!input.shift &&
|
||||
!input.alt &&
|
||||
!input.meta &&
|
||||
input.key.toLowerCase() === 'l'
|
||||
) {
|
||||
if (lock.lockNow().locked) event.preventDefault()
|
||||
return
|
||||
}
|
||||
if (!lock.isLocked()) return
|
||||
if (isLockBlockedShortcut(input)) event.preventDefault()
|
||||
} catch {
|
||||
/* an input guard must never take the window down with it */
|
||||
|
||||
Reference in new issue
Block a user