From 5bdd7ba643952ebed91d7e8cf5f0c5879dab1bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20Podgor=C5=A1ek?= Date: Wed, 4 Nov 2026 12:52:26 +0100 Subject: [PATCH 1/3] Give the first wake after a blank a longer grace Moving the mouse or pressing a key on a locked, blanked display wakes the panel, but panels take seconds to light up after DPMS off. Waking armed the standard 5-second idle interval immediately at input time, reblanking before users could finish typing their password. Grant a 15-second grace on the first wake after blanking, and preserve that deadline across bursts of subsequent wake events so mouse movements cannot shorten the grace back to five seconds before the user can type. Fixes #17453. --- shell/plugins/lock/Service.qml | 37 ++++++++++++++++++- .../lock-fingerprint-service/shell.qml | 25 +++++++++++++ test/shell.d/lock-fingerprint-service-test.sh | 9 +++++ 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/shell/plugins/lock/Service.qml b/shell/plugins/lock/Service.qml index a02708e05fde..8a68bdbe93c6 100644 --- a/shell/plugins/lock/Service.qml +++ b/shell/plugins/lock/Service.qml @@ -222,6 +222,8 @@ Item { resetAuthenticationState() lockRequested = true + idleBlankTimer.blanked = false + idleBlankTimer.graceDeadline = 0 armBlankTimer() logEvent("lock-requested") queueSessionLock() @@ -243,20 +245,44 @@ Item { pendingSessionLockTimer.stop() resetAuthenticationState() idleBlankTimer.stop() + idleBlankTimer.blanked = false + idleBlankTimer.graceDeadline = 0 sessionLock.locked = false logEvent("unlocked") runWake() } function armBlankTimer(delayMs) { + var now = Date.now() + // Bursts of wake input must not shorten the first-wake grace back to the + // idle interval before the user has had time to type. + if (!delayMs && idleBlankTimer.graceDeadline > now) { + if (now + idleBlankTimer.idleMs <= idleBlankTimer.graceDeadline) { + if (!idleBlankTimer.running) { + idleBlankTimer.interval = idleBlankTimer.graceDeadline - now + idleBlankTimer.armedAt = now + idleBlankTimer.restart() + } + return + } + idleBlankTimer.graceDeadline = 0 + } idleBlankTimer.interval = delayMs || idleBlankTimer.idleMs - idleBlankTimer.armedAt = Date.now() + idleBlankTimer.armedAt = now idleBlankTimer.restart() } function runWake() { if (!wakeProcess.running) wakeProcess.running = true - if (lockRequested) armBlankTimer() + if (lockRequested) { + if (idleBlankTimer.blanked) { + idleBlankTimer.blanked = false + idleBlankTimer.graceDeadline = Date.now() + idleBlankTimer.wakeMs + armBlankTimer(idleBlankTimer.wakeMs) + } else { + armBlankTimer() + } + } resumeFingerprint() nudgeFingerprint() } @@ -349,6 +375,8 @@ Item { } function runBlank() { + idleBlankTimer.blanked = true + idleBlankTimer.graceDeadline = 0 pauseFingerprint() if (!blankProcess.running) blankProcess.running = true } @@ -771,6 +799,11 @@ Item { // panel lights (on NVIDIA it waits out a VT switch and a modeset), so the // idle run-up blanked the lock just as it appeared. readonly property int resumeMs: 15000 + // Displays take seconds to light after DPMS off, so the first wake after a + // blank gets a longer grace before the idle countdown reblanks. + readonly property int wakeMs: 15000 + property bool blanked: false + property double graceDeadline: 0 interval: idleMs repeat: false property double armedAt: 0 diff --git a/test/shell.d/fixtures/lock-fingerprint-service/shell.qml b/test/shell.d/fixtures/lock-fingerprint-service/shell.qml index 0580f4e8e74b..3651cfc8f562 100644 --- a/test/shell.d/fixtures/lock-fingerprint-service/shell.qml +++ b/test/shell.d/fixtures/lock-fingerprint-service/shell.qml @@ -237,6 +237,31 @@ ShellRoot { check(!service.fingerprintPaused, "unlock reset clears a pause so the next lock starts the reader") service.applyFingerprintProbe("Daemon is restarting") check(!recheck.running, "an unknown probe outside the lock cannot restart it") + + // First wake after blank grants a longer grace so the user can type + // before reblanking; bursts of wake input preserve that deadline. + service.lockRequested = true + service.runBlank() + service.runWake() + check(blankTimer.interval === 15000, "first wake after a blank arms the longer grace") + var initialDeadline = blankTimer.armedAt + blankTimer.interval + blankTimer.stop() + + blankTimer.start() + service.runWake() + service.runWake() + check(blankTimer.interval === 15000 && blankTimer.armedAt + blankTimer.interval >= initialDeadline, + "burst of wake inputs preserves the long grace deadline") + + blankTimer.graceDeadline = Date.now() - 1000 + service.runWake() + check(blankTimer.interval === 5000, "wake input after grace consumed re-arms normal 5s interval") + blankTimer.stop() + + service.runBlank() + service.runWake() + check(blankTimer.interval === 15000, "wake after blanking again arms the longer grace") + blankTimer.stop() } finally { service.lockRequested = false service.resetAuthenticationState() diff --git a/test/shell.d/lock-fingerprint-service-test.sh b/test/shell.d/lock-fingerprint-service-test.sh index fb020eece385..edf09ab5fffb 100644 --- a/test/shell.d/lock-fingerprint-service-test.sh +++ b/test/shell.d/lock-fingerprint-service-test.sh @@ -2,8 +2,17 @@ set -euo pipefail +# shellcheck disable=SC1091 source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" require_quickshell "lock fingerprint service test" +qml_fixture_scratch +printf '#!/bin/bash\nexit 0\n' >"$QML_FIXTURE_TMP/bin/omarchy-system-wake" +printf '#!/bin/bash\nexit 0\n' >"$QML_FIXTURE_TMP/bin/omarchy-brightness-display" +printf '#!/bin/bash\nexit 0\n' >"$QML_FIXTURE_TMP/bin/omarchy-brightness-keyboard" +chmod +x "$QML_FIXTURE_TMP/bin/omarchy-system-wake" \ + "$QML_FIXTURE_TMP/bin/omarchy-brightness-display" \ + "$QML_FIXTURE_TMP/bin/omarchy-brightness-keyboard" + run_qml_fixture lock-fingerprint-service "fingerprint service handles enrollment, failures and recovery" Ui Commons From 097f97d05583914dfebe576a40658a8cab3f9502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20Podgor=C5=A1ek?= Date: Thu, 5 Nov 2026 12:33:47 +0100 Subject: [PATCH 2/3] Hold the burst-of-wake grace deadline exactly in the lock service test The burst check accepted any deadline at or past the first wake's, so restarting the full 15s grace on every burst wake would pass. Shift the armed grace back 7s before the burst so a re-granted deadline lands strictly later, and require armedAt + interval to equal the first wake's deadline. --- .../fixtures/lock-fingerprint-service/shell.qml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/shell.d/fixtures/lock-fingerprint-service/shell.qml b/test/shell.d/fixtures/lock-fingerprint-service/shell.qml index 3651cfc8f562..e8dacb1248b9 100644 --- a/test/shell.d/fixtures/lock-fingerprint-service/shell.qml +++ b/test/shell.d/fixtures/lock-fingerprint-service/shell.qml @@ -239,18 +239,24 @@ ShellRoot { check(!recheck.running, "an unknown probe outside the lock cannot restart it") // First wake after blank grants a longer grace so the user can type - // before reblanking; bursts of wake input preserve that deadline. + // before reblanking; bursts of wake input preserve that deadline. Move + // the armed grace back 7s so the burst reads as seconds after the first + // wake even though both run inside the same wall-clock millisecond: a + // burst that re-granted the grace would land the deadline 7s later and + // fail the exact match. service.lockRequested = true service.runBlank() service.runWake() check(blankTimer.interval === 15000, "first wake after a blank arms the longer grace") + blankTimer.armedAt -= 7000 + blankTimer.graceDeadline -= 7000 var initialDeadline = blankTimer.armedAt + blankTimer.interval blankTimer.stop() blankTimer.start() service.runWake() service.runWake() - check(blankTimer.interval === 15000 && blankTimer.armedAt + blankTimer.interval >= initialDeadline, + check(blankTimer.interval === 15000 && blankTimer.armedAt + blankTimer.interval === initialDeadline, "burst of wake inputs preserves the long grace deadline") blankTimer.graceDeadline = Date.now() - 1000 From d584b101d290f7f39b1e6ce97a665916818fa424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20Podgor=C5=A1ek?= Date: Mon, 9 Nov 2026 12:40:01 +0100 Subject: [PATCH 3/3] Never let an idle arm shorten a pending blank grace Guard armBlankTimer so a shorter delay does not cut short a longer pending countdown, replacing the graceDeadline mechanism. This fixes the resume-grace overwrite from PR review (teuteuguy's timeline: resume arm 15s -> screensChanged or runWake no-arg re-arm 5s). Update the lock fingerprint service test fixture to cover resume grace preservation across output re-detection and wake bursts, as well as the stopped-timer re-arm semantics. --- shell/plugins/lock/Service.qml | 30 +++++----------- .../lock-fingerprint-service/shell.qml | 34 ++++++++++++++----- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/shell/plugins/lock/Service.qml b/shell/plugins/lock/Service.qml index 8a68bdbe93c6..118af08730d0 100644 --- a/shell/plugins/lock/Service.qml +++ b/shell/plugins/lock/Service.qml @@ -223,7 +223,6 @@ Item { resetAuthenticationState() lockRequested = true idleBlankTimer.blanked = false - idleBlankTimer.graceDeadline = 0 armBlankTimer() logEvent("lock-requested") queueSessionLock() @@ -246,29 +245,21 @@ Item { resetAuthenticationState() idleBlankTimer.stop() idleBlankTimer.blanked = false - idleBlankTimer.graceDeadline = 0 sessionLock.locked = false logEvent("unlocked") runWake() } function armBlankTimer(delayMs) { - var now = Date.now() - // Bursts of wake input must not shorten the first-wake grace back to the - // idle interval before the user has had time to type. - if (!delayMs && idleBlankTimer.graceDeadline > now) { - if (now + idleBlankTimer.idleMs <= idleBlankTimer.graceDeadline) { - if (!idleBlankTimer.running) { - idleBlankTimer.interval = idleBlankTimer.graceDeadline - now - idleBlankTimer.armedAt = now - idleBlankTimer.restart() - } - return - } - idleBlankTimer.graceDeadline = 0 - } - idleBlankTimer.interval = delayMs || idleBlankTimer.idleMs - idleBlankTimer.armedAt = now + var want = delayMs || idleBlankTimer.idleMs + // A longer pending countdown is never cut short: wake input right after + // a blank, and the output re-detection right after a resume, must not + // reset those longer graces to the idle run-up while more than the + // run-up is left. Once less of a grace remains than a run-up takes, an + // ordinary arm refreshes the countdown as before. + if (idleBlankTimer.running && idleBlankTimer.armedAt + idleBlankTimer.interval - Date.now() > want) return + idleBlankTimer.interval = want + idleBlankTimer.armedAt = Date.now() idleBlankTimer.restart() } @@ -277,7 +268,6 @@ Item { if (lockRequested) { if (idleBlankTimer.blanked) { idleBlankTimer.blanked = false - idleBlankTimer.graceDeadline = Date.now() + idleBlankTimer.wakeMs armBlankTimer(idleBlankTimer.wakeMs) } else { armBlankTimer() @@ -376,7 +366,6 @@ Item { function runBlank() { idleBlankTimer.blanked = true - idleBlankTimer.graceDeadline = 0 pauseFingerprint() if (!blankProcess.running) blankProcess.running = true } @@ -803,7 +792,6 @@ Item { // blank gets a longer grace before the idle countdown reblanks. readonly property int wakeMs: 15000 property bool blanked: false - property double graceDeadline: 0 interval: idleMs repeat: false property double armedAt: 0 diff --git a/test/shell.d/fixtures/lock-fingerprint-service/shell.qml b/test/shell.d/fixtures/lock-fingerprint-service/shell.qml index e8dacb1248b9..d1d12af0ccd3 100644 --- a/test/shell.d/fixtures/lock-fingerprint-service/shell.qml +++ b/test/shell.d/fixtures/lock-fingerprint-service/shell.qml @@ -239,17 +239,16 @@ ShellRoot { check(!recheck.running, "an unknown probe outside the lock cannot restart it") // First wake after blank grants a longer grace so the user can type - // before reblanking; bursts of wake input preserve that deadline. Move - // the armed grace back 7s so the burst reads as seconds after the first - // wake even though both run inside the same wall-clock millisecond: a - // burst that re-granted the grace would land the deadline 7s later and - // fail the exact match. + // before reblanking; bursts of wake input preserve that countdown. Move + // the armed countdown back 7s so the burst reads as seconds after the + // first wake even though both run inside the same wall-clock + // millisecond: a burst that reset or re-granted the countdown would + // move its deadline and fail the exact match. service.lockRequested = true service.runBlank() service.runWake() check(blankTimer.interval === 15000, "first wake after a blank arms the longer grace") blankTimer.armedAt -= 7000 - blankTimer.graceDeadline -= 7000 var initialDeadline = blankTimer.armedAt + blankTimer.interval blankTimer.stop() @@ -259,9 +258,28 @@ ShellRoot { check(blankTimer.interval === 15000 && blankTimer.armedAt + blankTimer.interval === initialDeadline, "burst of wake inputs preserves the long grace deadline") - blankTimer.graceDeadline = Date.now() - 1000 + blankTimer.armedAt = Date.now() - 11000 service.runWake() - check(blankTimer.interval === 5000, "wake input after grace consumed re-arms normal 5s interval") + check(blankTimer.interval === 5000, "wake input once less than 5s of the grace remains re-arms the normal 5s interval") + blankTimer.stop() + service.runWake() + check(blankTimer.interval === 5000, "input ending a password check arms the normal 5s run-up even with grace left over") + + // A resume arms the same longer countdown, through the blank timer's + // own suspend-gap check; the wake paths that fire within a second of + // the resume must not reset it to the idle run-up. + blankTimer.interval = 5000 + blankTimer.armedAt = Date.now() - 60000 + blankTimer.start() + blankTimer.triggered() + check(blankTimer.interval === 15000, "a countdown frozen by suspend re-arms the resume grace instead of blanking") + service.armBlankTimer() + check(blankTimer.interval === 15000, "an output re-detection right after a resume keeps the resume grace") + service.runWake() + check(blankTimer.interval === 15000, "a wake burst right after a resume keeps the resume grace") + blankTimer.armedAt = Date.now() - 11000 + service.runWake() + check(blankTimer.interval === 5000, "input once the resume grace is mostly spent re-arms the normal 5s interval") blankTimer.stop() service.runBlank()