diff --git a/Modules/LockScreen/LockScreen.qml b/Modules/LockScreen/LockScreen.qml index 1bbd9ccc1..cfc417cd2 100644 --- a/Modules/LockScreen/LockScreen.qml +++ b/Modules/LockScreen/LockScreen.qml @@ -25,12 +25,6 @@ Loader { } else { CavaService.unregisterComponent("lockscreen"); } - - if (root.active) { - LockKeysService.registerComponent("lockscreen"); - } else { - LockKeysService.unregisterComponent("lockscreen"); - } } onNeedsCavaChanged: { @@ -46,11 +40,6 @@ Loader { PanelService.lockScreen = this; } - Component.onDestruction: { - CavaService.unregisterComponent("lockscreen"); - LockKeysService.unregisterComponent("lockscreen"); - } - Timer { id: unloadAfterUnlockTimer interval: 250 @@ -280,13 +269,21 @@ Loader { height: 0 visible: false enabled: !lockContext.unlockInProgress - font.pointSize: Style.fontSizeM - color: Color.mPrimary echoMode: TextInput.Password - passwordCharacter: "•" passwordMaskDelay: 0 - text: lockContext.currentText - onTextChanged: lockContext.currentText = text + + // Bidirectional sync — avoids a declarative binding which breaks on input + onTextChanged: { + if (lockContext.currentText !== text) + lockContext.currentText = text; + } + Connections { + target: lockContext + function onCurrentTextChanged() { + if (passwordInput.text !== lockContext.currentText) + passwordInput.text = lockContext.currentText; + } + } Keys.onPressed: function (event) { if (Keybinds.checkKey(event, 'enter', Settings)) { @@ -317,9 +314,49 @@ Loader { Component { id: blackScreenComponent + // Black surface for disabled monitors — still captures keyboard for password entry Rectangle { anchors.fill: parent color: "black" + + TextInput { + id: blackScreenPasswordInput + width: 0 + height: 0 + visible: false + enabled: !lockContext.unlockInProgress + echoMode: TextInput.Password + passwordMaskDelay: 0 + + // Bidirectional sync — avoids a declarative binding which breaks on input + onTextChanged: { + if (lockContext.currentText !== text) + lockContext.currentText = text; + } + Connections { + target: lockContext + function onCurrentTextChanged() { + if (blackScreenPasswordInput.text !== lockContext.currentText) + blackScreenPasswordInput.text = lockContext.currentText; + } + } + + Keys.onPressed: function (event) { + if (Keybinds.checkKey(event, 'enter', Settings)) { + lockContext.tryUnlock(); + event.accepted = true; + } + } + + Component.onCompleted: forceActiveFocus() + } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + acceptedButtons: Qt.NoButton + onPositionChanged: blackScreenPasswordInput.forceActiveFocus() + } } } }