1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-29 16:02:51 -05:00

Some lockscreen restructure

This commit is contained in:
bbedward
2025-10-09 11:30:02 -04:00
parent 5e2371c2cb
commit e32622ac48
3 changed files with 44 additions and 78 deletions

View File

@@ -8,81 +8,54 @@ import qs.Services
Item { Item {
id: root id: root
function activate() { property string sharedPasswordBuffer: ""
loader.activeAsync = true property bool shouldLock: false
}
Component.onCompleted: { Component.onCompleted: {
if (SessionService.loginctlAvailable || SessionService.sessionPath) { IdleService.lockComponent = root
if (SessionService.locked || SessionService.lockedHint) {
console.log("Lock: Session locked on startup")
loader.activeAsync = true
}
}
} }
Connections { function activate() {
target: IdleService shouldLock = true
function onLockRequested() {
console.log("Lock: Received lock request from IdleService")
loader.activeAsync = true
}
} }
Connections { Connections {
target: SessionService target: SessionService
function onSessionLocked() { function onSessionLocked() {
console.log("Lock: Lock signal received -> show lock") shouldLock = true
loader.activeAsync = true
} }
function onSessionUnlocked() { function onSessionUnlocked() {
console.log("Lock: Unlock signal received -> hide lock") shouldLock = false
loader.active = false
}
function onLoginctlStateChanged() {
if (SessionService.lockedHint && !loader.active) {
console.log("Lock: LockedHint=true -> show lock")
loader.activeAsync = true
} else if (!SessionService.locked && !SessionService.lockedHint && loader.active) {
console.log("Lock: LockedHint=false -> hide lock")
loader.active = false
} }
} }
function onPrepareForSleep() { Connections {
if (SessionService.preparingForSleep && SessionData.lockBeforeSuspend) { target: IdleService
console.log("Lock: PrepareForSleep -> lock before suspend")
loader.activeAsync = true
}
}
}
LazyLoader { function onLockRequested() {
id: loader shouldLock = true
}
}
WlSessionLock { WlSessionLock {
id: sessionLock id: sessionLock
property bool unlocked: false locked: root.shouldLock
property string sharedPasswordBuffer: ""
locked: true WlSessionLockSurface {
color: "transparent"
onLockedChanged: {
if (!locked) {
loader.active = false
}
}
LockSurface { LockSurface {
id: lockSurface anchors.fill: parent
lock: sessionLock lock: sessionLock
sharedPasswordBuffer: sessionLock.sharedPasswordBuffer sharedPasswordBuffer: root.sharedPasswordBuffer
onUnlockRequested: {
root.shouldLock = false
}
onPasswordChanged: newPassword => { onPasswordChanged: newPassword => {
sessionLock.sharedPasswordBuffer = newPassword root.sharedPasswordBuffer = newPassword
} }
} }
} }
@@ -96,17 +69,15 @@ Item {
target: "lock" target: "lock"
function lock() { function lock() {
console.log("Lock screen requested via IPC") shouldLock = true
loader.activeAsync = true
} }
function demo() { function demo() {
console.log("Lock screen DEMO mode requested via IPC")
demoWindow.showDemo() demoWindow.showDemo()
} }
function isLocked(): bool { function isLocked(): bool {
return SessionService.locked || loader.active return sessionLock.locked
} }
} }
} }

View File

@@ -4,29 +4,23 @@ import Quickshell
import Quickshell.Wayland import Quickshell.Wayland
import qs.Common import qs.Common
WlSessionLockSurface { Rectangle {
id: root id: root
required property WlSessionLock lock required property WlSessionLock lock
required property string sharedPasswordBuffer required property string sharedPasswordBuffer
signal passwordChanged(string newPassword) signal passwordChanged(string newPassword)
signal unlockRequested()
readonly property bool locked: lock && !lock.locked
function unlock(): void {
lock.locked = false
}
color: "transparent" color: "transparent"
Loader { LockScreenContent {
anchors.fill: parent anchors.fill: parent
sourceComponent: LockScreenContent {
demoMode: false demoMode: false
passwordBuffer: root.sharedPasswordBuffer passwordBuffer: root.sharedPasswordBuffer
screenName: root.screen?.name ?? "" screenName: ""
onUnlockRequested: root.unlock() onUnlockRequested: root.unlockRequested()
onPasswordBufferChanged: { onPasswordBufferChanged: {
if (root.sharedPasswordBuffer !== passwordBuffer) { if (root.sharedPasswordBuffer !== passwordBuffer) {
root.passwordChanged(passwordBuffer) root.passwordChanged(passwordBuffer)
@@ -34,4 +28,3 @@ WlSessionLockSurface {
} }
} }
} }
}

View File

@@ -366,6 +366,8 @@ Singleton {
} }
function updateLoginctlState(state) { function updateLoginctlState(state) {
const wasLocked = locked
sessionId = state.sessionId || "" sessionId = state.sessionId || ""
sessionPath = state.sessionPath || "" sessionPath = state.sessionPath || ""
locked = state.locked || false locked = state.locked || false
@@ -384,6 +386,12 @@ Singleton {
prepareForSleep() prepareForSleep()
} }
if (locked && !wasLocked) {
sessionLocked()
} else if (!locked && wasLocked) {
sessionUnlocked()
}
loginctlStateChanged() loginctlStateChanged()
} }
@@ -483,10 +491,4 @@ Singleton {
} }
} }
Process {
id: lockSessionFallback
command: ["loginctl", "lock-session"]
running: false
}
} }