From aa5896766b610c6d1a78b197d5e9c1a39c21d54d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 21 May 2026 08:08:59 +0200 Subject: [PATCH] Mirror lock input across screens --- shell/plugins/lock/LockView.qml | 21 +++++++++++++++++---- shell/plugins/lock/Service.qml | 6 ++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/shell/plugins/lock/LockView.qml b/shell/plugins/lock/LockView.qml index bbf0440b..e882e0e7 100644 --- a/shell/plugins/lock/LockView.qml +++ b/shell/plugins/lock/LockView.qml @@ -12,7 +12,9 @@ Item { property string failureMessage: "" property int failedAttempts: 0 property bool inputEnabled: true + property string passwordText: "" property real scaleFactor: 1 + property bool syncingPasswordText: false readonly property string fingerprintGlyph: "\uDB80\uDE37" readonly property string placeholderText: fingerprintConfigured ? "Enter Password " + fingerprintGlyph : "Enter Password" @@ -25,6 +27,7 @@ Item { readonly property bool showPasswordCursor: inputEnabled && !authenticatingPassword && failureMessage.length === 0 signal submitPassword(string password) + signal passwordTextEdited(string password) signal clearFailureRequested() signal wakeRequested() @@ -42,13 +45,22 @@ Item { } function clearPassword() { - passwordInput.text = "" + passwordTextEdited("") } + function syncPasswordText() { + if (passwordInput.text === passwordText) return + syncingPasswordText = true + passwordInput.text = passwordText + syncingPasswordText = false + } + + onPasswordTextChanged: syncPasswordText() onInputEnabledChanged: { if (inputEnabled) Qt.callLater(forcePasswordFocus) } Component.onCompleted: { + syncPasswordText() if (inputEnabled) Qt.callLater(forcePasswordFocus) } @@ -122,6 +134,7 @@ Item { } onTextChanged: { + if (!root.syncingPasswordText) root.passwordTextEdited(text) if (text.length > 0) { root.wakeRequested() } @@ -129,15 +142,15 @@ Item { } onAccepted: { - var submitted = text - text = "" + var submitted = root.passwordText + root.passwordTextEdited("") if (submitted.length > 0) root.submitPassword(submitted) } Keys.onPressed: function(event) { root.wakeRequested() if (event.key === Qt.Key_Escape || (event.modifiers & Qt.ControlModifier && event.key === Qt.Key_U)) { - text = "" + root.passwordTextEdited("") event.accepted = true } } diff --git a/shell/plugins/lock/Service.qml b/shell/plugins/lock/Service.qml index 115099b4..39be1780 100644 --- a/shell/plugins/lock/Service.qml +++ b/shell/plugins/lock/Service.qml @@ -21,6 +21,7 @@ Item { property bool passwordPamConfigured: false property bool fingerprintConfigured: false property bool previewVisible: false + property string enteredPassword: "" property string pendingPassword: "" property string failureMessage: "" property int failedAttempts: 0 @@ -39,6 +40,7 @@ Item { } function resetAuthenticationState() { + enteredPassword = "" pendingPassword = "" failureMessage = "" failedAttempts = 0 @@ -106,6 +108,7 @@ Item { if (!lockRequested) return authenticatingPassword = false + enteredPassword = "" pendingPassword = "" failedAttempts += 1 failureMessage = "Authentication failed (" + failedAttempts + ")" @@ -164,7 +167,9 @@ Item { failureMessage: root.failureMessage failedAttempts: root.failedAttempts inputEnabled: root.lockRequested + passwordText: root.enteredPassword scaleFactor: lockSurface.screen && lockSurface.screen.devicePixelRatio > 0 ? lockSurface.screen.devicePixelRatio : 1 + onPasswordTextEdited: function(password) { root.enteredPassword = password } onSubmitPassword: function(password) { root.submitPassword(password) } onClearFailureRequested: root.failureMessage = "" onWakeRequested: root.runWake() @@ -192,6 +197,7 @@ Item { failureMessage: "" failedAttempts: 0 inputEnabled: false + passwordText: "" scaleFactor: previewWindow.screen && previewWindow.screen.devicePixelRatio > 0 ? previewWindow.screen.devicePixelRatio : 1 }