lockscreen: fix PAM never instantiating (moved out of WlSessionLock)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-07-08 12:09:52 +01:00
parent 57d4ea4e0f
commit 9239f60549

View file

@ -201,12 +201,18 @@ in
import QtQuick
import Qt5Compat.GraphicalEffects
// ext-session-lock screen, replacing hyprlock. Lives in the shell
// process: set `locked: true` and the compositor hands every
// screen to a LockSurface below until PAM says otherwise.
WlSessionLock {
id: lock
// ext-session-lock screen, replacing hyprlock. Set `locked: true`
// and the compositor hands every screen to a LockSurface below
// until PAM says otherwise.
//
// PAM and state live in a Scope OUTSIDE WlSessionLock: its default
// property is the surface *component*, so a PamContext declared
// inside it is never instantiated `pam` didn't resolve and
// submit() threw, which is why enter/the arrow did nothing.
Scope {
id: root
property alias locked: lock.locked
property string password: ""
property bool failed: false
@ -223,15 +229,18 @@ in
// user's own password via the unix_chkpwd setuid wrapper.
config: "login"
onPamMessage: {
if (this.responseRequired) this.respond(lock.password);
if (this.responseRequired) this.respond(root.password);
}
onCompleted: result => {
lock.password = "";
root.password = "";
if (result === PamResult.Success) lock.locked = false;
else lock.failed = true;
else root.failed = true;
}
}
WlSessionLock {
id: lock
WlSessionLockSurface {
id: surface
color: "black"
@ -289,7 +298,7 @@ in
color: Theme.cardBg
border.width: Theme.borderWidth
border.color: pam.active ? Theme.base0D
: lock.failed ? Theme.base08
: root.failed ? Theme.base08
: Theme.base03
Behavior on border.color { ColorAnimation { duration: Theme.animFade } }
@ -307,7 +316,7 @@ in
Text {
anchors.centerIn: parent
visible: pwInput.text === "" && lock.failed
visible: pwInput.text === "" && root.failed
text: "wrong password"
color: Theme.base08
font.family: Theme.fontFamily
@ -322,7 +331,7 @@ in
echoMode: TextInput.Password
focus: true
function go() {
lock.submit(text);
root.submit(text);
text = "";
}
// Explicit key handlers: accepted() doesn't
@ -364,6 +373,7 @@ in
Component.onCompleted: pwInput.forceActiveFocus()
}
}
}
'';
};
@ -422,6 +432,8 @@ in
IpcHandler {
target: "lock"
function lock(): void { root.lock(); }
// Escape hatch from a VT: qs ipc call lock unlock
function unlock(): void { lockScreen.locked = false; }
}
// Screenshot pin: the Shift+Super+S keybind brackets hyprshot