[gnome-shell] screenShield: Tie `LockedHint` to locked state



commit c5019dbf62a38ded3ea1c33441a73a80fdc808bc
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jan 7 22:33:47 2021 +0100

    screenShield: Tie `LockedHint` to locked state
    
    Currently the hint reflects the `active` state, which effectively
    corresponds to the screen blank. That's a bit surprising considering
    the name, plus the `active` state is already exposed by the ScreenSaver
    D-Bus interface for anyone interested.
    
    It seems reasonable that the `LockedHint` property reflects the lock
    state, so change the handling to do exactly that.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/351
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1561>

 js/ui/screenShield.js | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index fa3a7a8167..9a64fc32c3 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -151,12 +151,20 @@ var ScreenShield = class {
         if (prevIsActive != this._isActive)
             this.emit('active-changed');
 
-        if (this._loginSession)
-            this._loginSession.SetLockedHintRemote(active);
-
         this._syncInhibitor();
     }
 
+    _setLocked(locked) {
+        let prevIsLocked = this._isLocked;
+        this._isLocked = locked;
+
+        if (prevIsLocked !== this._isLocked)
+            this.emit('locked-changed');
+
+        if (this._loginSession)
+            this._loginSession.SetLockedHintRemote(locked);
+    }
+
     _activateDialog() {
         if (this._isLocked) {
             this._ensureUnlockDialog(true /* allowCancel */);
@@ -563,8 +571,7 @@ var ScreenShield = class {
 
         this._activationTime = 0;
         this._setActive(false);
-        this._isLocked = false;
-        this.emit('locked-changed');
+        this._setLocked(false);
         global.set_runtime_state(LOCKED_STATE_STR, null);
     }
 
@@ -624,14 +631,12 @@ var ScreenShield = class {
         let userManager = AccountsService.UserManager.get_default();
         let user = userManager.get_user(GLib.get_user_name());
 
-        if (this._isGreeter)
-            this._isLocked = true;
-        else
-            this._isLocked = user.password_mode != AccountsService.UserPasswordMode.NONE;
-
         this.activate(animate);
 
-        this.emit('locked-changed');
+        const lock = this._isGreeter
+            ? true
+            : user.password_mode !== AccountsService.UserPasswordMode.NONE;
+        this._setLocked(lock);
     }
 
     // If the previous shell crashed, and gnome-session restarted us, then re-lock


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]