From 5a026f65c96cd631629380a27e1c774e21a95209 Mon Sep 17 00:00:00 2001
From: mlmrx
Date: Mon, 31 Aug 2026 18:20:30 -0700
Subject: [PATCH 1/3] Refocus lock screen when session secures
---
shell/plugins/lock/Service.qml | 1 +
test/shell.d/lock-focus-test.sh | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
create mode 100755 test/shell.d/lock-focus-test.sh
diff --git a/shell/plugins/lock/Service.qml b/shell/plugins/lock/Service.qml
index 9ecb1cc09be0..edcdbc5ea71f 100644
--- a/shell/plugins/lock/Service.qml
+++ b/shell/plugins/lock/Service.qml
@@ -238,6 +238,7 @@ Item {
root.pendingSessionLock = false
sessionLockStabilizeTimer.stop()
pendingSessionLockTimer.stop()
+ lockView.forcePasswordFocus()
root.startFingerprint()
}
}
diff --git a/test/shell.d/lock-focus-test.sh b/test/shell.d/lock-focus-test.sh
new file mode 100755
index 000000000000..973e517114fc
--- /dev/null
+++ b/test/shell.d/lock-focus-test.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -euo pipefail
+
+source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
+
+run_node_test <<'JS'
+const fs = require('fs')
+const serviceQml = fs.readFileSync(path.join(root, 'shell/plugins/lock/Service.qml'), 'utf8')
+
+const secureHandlerStart = serviceQml.indexOf('onSecureStateChanged:')
+const lockHandlerStart = serviceQml.indexOf('onLockStateChanged:', secureHandlerStart)
+const secureHandler = serviceQml.slice(secureHandlerStart, lockHandlerStart)
+const secureBlockMatch = secureHandler.match(/if \(secure\) \{([\s\S]*?)\n \}/)
+const secureBlock = secureBlockMatch ? secureBlockMatch[1] : ''
+
+assert(
+ secureBlock.includes('lockView.forcePasswordFocus()'),
+ 'the password field regains focus when the compositor secures the lock surface'
+)
+JS
From 7a2dc844ac20cdabf55df869e1cfc215bcc11c06 Mon Sep 17 00:00:00 2001
From: Omarchybot <317366263+omarchybot@users.noreply.github.com>
Date: Thu, 1 Oct 2026 20:35:06 +0200
Subject: [PATCH 2/3] Refocus from the lock surface, where lockView is in scope
lockView is declared inside the per-screen WlSessionLockSurface delegate, so naming it from WlSessionLock's own onSecureStateChanged threw "ReferenceError: lockView is not defined" every time the lock became secure. The throw also aborted the handler before root.startFingerprint(), the call that starts fingerprint unlock when the fingerprint check finishes before the lock is secure. Each surface now refocuses its own field through a Connections on sessionLock, and the test checks the call sits there and not in the session lock's handler.
Co-Authored-By: Claude Opus 5.5
---
shell/plugins/lock/Service.qml | 10 +++++++++-
test/shell.d/lock-focus-test.sh | 15 +++++++++++----
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/shell/plugins/lock/Service.qml b/shell/plugins/lock/Service.qml
index edcdbc5ea71f..5a7ccd128ad4 100644
--- a/shell/plugins/lock/Service.qml
+++ b/shell/plugins/lock/Service.qml
@@ -238,7 +238,6 @@ Item {
root.pendingSessionLock = false
sessionLockStabilizeTimer.stop()
pendingSessionLockTimer.stop()
- lockView.forcePasswordFocus()
root.startFingerprint()
}
}
@@ -284,6 +283,15 @@ Item {
onWakeRequested: root.runWake()
}
+ // lockView lives in this per-screen delegate, so the session lock's own
+ // handler cannot see it; refocus from here once the lock is secure.
+ Connections {
+ target: sessionLock
+ function onSecureStateChanged() {
+ if (sessionLock.secure) lockView.forcePasswordFocus()
+ }
+ }
+
}
}
diff --git a/test/shell.d/lock-focus-test.sh b/test/shell.d/lock-focus-test.sh
index 973e517114fc..96c203fe1170 100755
--- a/test/shell.d/lock-focus-test.sh
+++ b/test/shell.d/lock-focus-test.sh
@@ -11,11 +11,18 @@ const serviceQml = fs.readFileSync(path.join(root, 'shell/plugins/lock/Service.q
const secureHandlerStart = serviceQml.indexOf('onSecureStateChanged:')
const lockHandlerStart = serviceQml.indexOf('onLockStateChanged:', secureHandlerStart)
const secureHandler = serviceQml.slice(secureHandlerStart, lockHandlerStart)
-const secureBlockMatch = secureHandler.match(/if \(secure\) \{([\s\S]*?)\n \}/)
-const secureBlock = secureBlockMatch ? secureBlockMatch[1] : ''
+// lockView is declared inside the per-screen WlSessionLockSurface delegate, so
+// naming it here is a ReferenceError that also skips startFingerprint().
assert(
- secureBlock.includes('lockView.forcePasswordFocus()'),
- 'the password field regains focus when the compositor secures the lock surface'
+ !secureHandler.includes('lockView'),
+ 'the session lock handler does not reach into the per-screen lock view'
+)
+
+const surface = serviceQml.slice(serviceQml.indexOf('WlSessionLockSurface {'))
+
+assert(
+ /Connections \{\s*target: sessionLock\s*function onSecureStateChanged\(\) \{\s*if \(sessionLock\.secure\) lockView\.forcePasswordFocus\(\)/.test(surface),
+ 'each lock surface refocuses its password field when the compositor secures the lock'
)
JS
From f618457f67307ce6fba302f44fafea71a4f8cd6f Mon Sep 17 00:00:00 2001
From: Omarchybot <317366263+omarchybot@users.noreply.github.com>
Date: Fri, 2 Oct 2026 00:41:00 +0200
Subject: [PATCH 3/3] Bound the lock focus test to the lock surface delegate
The surface check sliced from WlSessionLockSurface to the end of Service.qml, so a Connections block moved out of the delegate, where lockView is out of scope, would still have passed. The slice now ends at the delegate's closing brace.
Co-Authored-By: Claude Opus 5.5
---
test/shell.d/lock-focus-test.sh | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/test/shell.d/lock-focus-test.sh b/test/shell.d/lock-focus-test.sh
index 96c203fe1170..346057587b22 100755
--- a/test/shell.d/lock-focus-test.sh
+++ b/test/shell.d/lock-focus-test.sh
@@ -19,7 +19,13 @@ assert(
'the session lock handler does not reach into the per-screen lock view'
)
-const surface = serviceQml.slice(serviceQml.indexOf('WlSessionLockSurface {'))
+const surfaceStart = serviceQml.indexOf('WlSessionLockSurface {')
+let surfaceEnd = serviceQml.indexOf('{', surfaceStart)
+for (let depth = 0; surfaceEnd < serviceQml.length; surfaceEnd++) {
+ if (serviceQml[surfaceEnd] === '{') depth++
+ if (serviceQml[surfaceEnd] === '}' && --depth === 0) break
+}
+const surface = serviceQml.slice(surfaceStart, surfaceEnd + 1)
assert(
/Connections \{\s*target: sessionLock\s*function onSecureStateChanged\(\) \{\s*if \(sessionLock\.secure\) lockView\.forcePasswordFocus\(\)/.test(surface),