From fd85678f6723a4d22baddf20f10aa7412c6651c8 Mon Sep 17 00:00:00 2001 From: Sergio Costas Rodriguez Date: Tue, 7 May 2024 16:47:04 +0200 Subject: [PATCH 1/2] Hide overview before locking screen There seems to be a bug in St/Clutter that crashes Gnome Shell if Dash to Dock is enabled and the user locks the screen from the overview mode. This patch is a workaround in the meantime, while the true bug is found, to avoid this. It exits the overview mode before locking the screen. Fix https://github.com/micheleg/dash-to-dock/issues/2216 --- docking.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docking.js b/docking.js index 23ffd34a6..64dece309 100644 --- a/docking.js +++ b/docking.js @@ -1662,10 +1662,42 @@ const WorkspaceIsolation = class DashToDockWorkspaceIsolation { export class DockManager { + _restoreLock() { + Main.screenShield.__proto__.lock = this._oldLock; + Main.overview.disconnect(this._lockHiddenID); + this._lockHiddenID = 0; + } + + _modifyLock() { + // This replaces the Lock() method in ScreenShield singleton + // to ensure that trying to lock the screen in Overview mode will return first + // to normal mode. This is needed to avoid https://github.com/micheleg/dash-to-dock/issues/2214 + // until a definitive fix is sent. + let oldLock = Main.screenShield.__proto__.lock; + this._oldLock = oldLock; + this._lockHiddenID = Main.overview.connect("hidden", () => { + if (this._lockAfterHide) { + this._lockAfterHide = false; + if (!Main.overview.visible) { + oldLock.bind(Main.screenShield)(this._lockAnimate); + } + } + }); + Main.screenShield.__proto__.lock = function(animate) { + if (!Main.overview.visible) { + oldLock.bind(Main.screenShield)(animate); + return; + } + this._lockAfterHide = true; + this._lockAnimate = animate; + Main.overview.hide(); + }.bind(this); + } constructor(extension) { if (DockManager._singleton) throw new Error('DashToDock has been already initialized'); DockManager._singleton = this; + this._modifyLock(); this._extension = extension; this._signalsHandler = new Utils.GlobalSignalsHandler(this); this._methodInjections = new Utils.InjectionsHandler(this); @@ -2531,6 +2563,7 @@ export class DockManager { } this._restoreDash(); this._deleteDocks(); + this._restoreLock(); this._revertPanelCorners(); if (this._oldSelectorMargin) this.searchController.margin_bottom = this._oldSelectorMargin; From 5e2079db698d3f605a7e71b1dd38a034d979bcea Mon Sep 17 00:00:00 2001 From: Sergio Costas Rodriguez Date: Tue, 7 May 2024 17:18:36 +0200 Subject: [PATCH 2/2] Fix style --- docking.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docking.js b/docking.js index 64dece309..d758a792b 100644 --- a/docking.js +++ b/docking.js @@ -1663,7 +1663,7 @@ const WorkspaceIsolation = class DashToDockWorkspaceIsolation { export class DockManager { _restoreLock() { - Main.screenShield.__proto__.lock = this._oldLock; + Object.getPrototypeOf(Main.screenShield).lock = this._oldLock; Main.overview.disconnect(this._lockHiddenID); this._lockHiddenID = 0; } @@ -1673,17 +1673,16 @@ export class DockManager { // to ensure that trying to lock the screen in Overview mode will return first // to normal mode. This is needed to avoid https://github.com/micheleg/dash-to-dock/issues/2214 // until a definitive fix is sent. - let oldLock = Main.screenShield.__proto__.lock; + const oldLock = Object.getPrototypeOf(Main.screenShield).lock; this._oldLock = oldLock; - this._lockHiddenID = Main.overview.connect("hidden", () => { + this._lockHiddenID = Main.overview.connect('hidden', () => { if (this._lockAfterHide) { this._lockAfterHide = false; - if (!Main.overview.visible) { + if (!Main.overview.visible) oldLock.bind(Main.screenShield)(this._lockAnimate); - } } }); - Main.screenShield.__proto__.lock = function(animate) { + Object.getPrototypeOf(Main.screenShield).lock = function (animate) { if (!Main.overview.visible) { oldLock.bind(Main.screenShield)(animate); return; @@ -1693,6 +1692,7 @@ export class DockManager { Main.overview.hide(); }.bind(this); } + constructor(extension) { if (DockManager._singleton) throw new Error('DashToDock has been already initialized');