From c21313dd341c70b7e0ba14c565a97ed37e33c087 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 17 Jan 2022 21:23:03 +0100 Subject: [PATCH] :wrench: Do not try to fix #49 on GS 3.36 --- extension.js | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/extension.js b/extension.js index 63e20fe..c8dcc3b 100644 --- a/extension.js +++ b/extension.js @@ -13,17 +13,17 @@ 'use strict'; -const {Clutter, Gio, Meta} = imports.gi; - -const Workspace = imports.ui.workspace.Workspace; -const WindowManager = imports.ui.windowManager.WindowManager; -const WindowPreview = imports.ui.windowPreview.WindowPreview; -const WINDOW_REPOSITIONING_DELAY = imports.ui.workspace.WINDOW_REPOSITIONING_DELAY; - const ExtensionUtils = imports.misc.extensionUtils; const Me = imports.misc.extensionUtils.getCurrentExtension(); const utils = Me.imports.src.utils; +const {Clutter, Gio, Meta} = imports.gi; + +const Workspace = imports.ui.workspace.Workspace; +const WindowManager = imports.ui.windowManager.WindowManager; +const WindowPreview = + utils.shellVersionIsAtLeast(3, 38) ? imports.ui.windowPreview.WindowPreview : null; + // New effects must be registered here and in prefs.js. const ALL_EFFECTS = [ Me.imports.src.EnergizeA.EnergizeA, @@ -65,7 +65,6 @@ class Extension { this._origDoRemoveWindow = Workspace.prototype._doRemoveWindow; this._origAddWindowClone = Workspace.prototype._addWindowClone; this._origShouldAnimateActor = WindowManager.prototype._shouldAnimateActor; - this._origDeleteAll = WindowPreview.prototype._deleteAll; // We will use extensionThis to refer to the extension inside the patched methods of // the WorkspacesView. @@ -73,11 +72,15 @@ class Extension { // Do not attempt to close windows twice. Due to the animation in the overview, the // close button can be clicked twice which normally would lead to a crash. - WindowPreview.prototype._deleteAll = function() { - if (!this._closeRequested) { - extensionThis._origDeleteAll.apply(this); - } - }; + if (WindowPreview) { + this._origDeleteAll = WindowPreview.prototype._deleteAll; + + WindowPreview.prototype._deleteAll = function() { + if (!this._closeRequested) { + extensionThis._origDeleteAll.apply(this); + } + }; + } // On GNOME 3.36, the window clone's 'destroy' handler only calls _removeWindowClone // but not _doRemoveWindow. The latter is required to trigger the repositioning of the @@ -196,7 +199,10 @@ class Extension { Workspace.prototype._doRemoveWindow = this._origDoRemoveWindow; Workspace.prototype._addWindowClone = this._origAddWindowClone; WindowManager.prototype._shouldAnimateActor = this._origShouldAnimateActor; - WindowPreview.prototype._deleteAll = this._origDeleteAll; + + if (WindowPreview) { + WindowPreview.prototype._deleteAll = this._origDeleteAll; + } this._settings = null; }