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
9 changes: 9 additions & 0 deletions shell/plugins/lock/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -283,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()
}
}

}
}

Expand Down
34 changes: 34 additions & 0 deletions test/shell.d/lock-focus-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/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)

// lockView is declared inside the per-screen WlSessionLockSurface delegate, so
// naming it here is a ReferenceError that also skips startFingerprint().
assert(
!secureHandler.includes('lockView'),
'the session lock handler does not reach into the per-screen lock view'
)

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),
'each lock surface refocuses its password field when the compositor secures the lock'
)
JS