[gnome-shell/gnome-40] screenShield: Don't unnecessarily close or recreate inhibitors
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-40] screenShield: Don't unnecessarily close or recreate inhibitors
- Date: Mon, 16 Aug 2021 00:44:56 +0000 (UTC)
commit 8cf2f74257cc0bb81301c52b8367eb77a07a91bc
Author: Sebastian Keller <skeller gnome org>
Date: Fri Jul 23 17:35:00 2021 +0200
screenShield: Don't unnecessarily close or recreate inhibitors
ScreenShield::_syncInhibitor() was closing (and recreating) the
inhibitor everytime it was called, even if no change was needed.
This gets called in various places, including on property changes in
the login1 dbus object. These happen by the time logind already started
suspending at which point new inhibitors can no longer be created. It is
only waiting for existing inhibitors to be closed, so closing the
inhibitor without a new inhibitor will cause the suspending to proceed
immediately if no other inhibitors are present. This can also happen
before the lock screen is shown, which will then complete after resume.
Fix this by keeping track of the expected inhibition state and only
create or close inhibitors if there was a change to that.
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3736
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1927>
(cherry picked from commit fb313033eaf97fe072850f1bda5cb6eaf02c0312)
js/ui/screenShield.js | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index 9a64fc32c3..426e635772 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -122,6 +122,7 @@ var ScreenShield = class {
this._isActive = false;
this._isLocked = false;
this._inUnlockAnimation = false;
+ this._inhibited = false;
this._activationTime = 0;
this._becameActiveId = 0;
this._lockTimeoutId = 0;
@@ -203,20 +204,29 @@ var ScreenShield = class {
}
_syncInhibitor() {
- let lockEnabled = this._settings.get_boolean(LOCK_ENABLED_KEY);
- let lockLocked = this._lockSettings.get_boolean(DISABLE_LOCK_KEY);
- let inhibit = this._loginSession && this._loginSession.Active &&
- !this._isActive && lockEnabled && !lockLocked && Main.sessionMode.unlockDialog;
+ const lockEnabled = this._settings.get_boolean(LOCK_ENABLED_KEY);
+ const lockLocked = this._lockSettings.get_boolean(DISABLE_LOCK_KEY);
+ const inhibit = !!this._loginSession && this._loginSession.Active &&
+ !this._isActive && lockEnabled && !lockLocked &&
+ !!Main.sessionMode.unlockDialog;
+
+ if (inhibit === this._inhibited)
+ return;
+
+ this._inhibited = inhibit;
+
if (inhibit) {
- this._loginManager.inhibit(_("GNOME needs to lock the screen"),
+ this._loginManager.inhibit(_('GNOME needs to lock the screen'),
inhibitor => {
- if (this._inhibitor)
- this._inhibitor.close(null);
- this._inhibitor = inhibitor;
+ if (inhibitor) {
+ if (this._inhibitor)
+ inhibitor.close(null);
+ else
+ this._inhibitor = inhibitor;
+ }
});
} else {
- if (this._inhibitor)
- this._inhibitor.close(null);
+ this._inhibitor?.close(null);
this._inhibitor = null;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]