[gnome-shell] workspace: Disable overlay for inactive workspaces too



commit 86cefd906bfc3c5a5d2f7b73830b551a1d5c3ee7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Feb 5 13:39:13 2021 -0300

    workspace: Disable overlay for inactive workspaces too
    
    In addition to disabling the overlay when the state is not 1,
    disable it also when not in the active workspace.
    
    Make the Workspace class track the workspace's active state,
    and resync the overlays when it changes.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1645>

 js/ui/workspace.js | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index b8893357a0..5e3213e4a3 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -406,6 +406,7 @@ var WorkspaceLayout = GObject.registerClass({
         this._spacing = 20;
         this._layoutFrozen = false;
 
+        this._metaWorkspace = metaWorkspace;
         this._monitorIndex = monitorIndex;
         this._workarea = metaWorkspace
             ? metaWorkspace.get_work_area_for_monitor(this._monitorIndex)
@@ -426,8 +427,7 @@ var WorkspaceLayout = GObject.registerClass({
         });
 
         this._stateAdjustment.connect('notify::value', () => {
-            [...this._windows.keys()].forEach(
-                preview => this._syncOverlay(preview));
+            this.syncOverlays();
             this.layout_changed();
         });
     }
@@ -697,7 +697,17 @@ var WorkspaceLayout = GObject.registerClass({
     }
 
     _syncOverlay(preview) {
-        preview.overlay_enabled = this._stateAdjustment.value === 1;
+        const active = this._metaWorkspace?.active ?? true;
+        preview.overlayEnabled = active && this._stateAdjustment.value === 1;
+    }
+
+    /**
+     * syncOverlays:
+     *
+     * Synchronizes the overlay state of all window previews.
+     */
+    syncOverlays() {
+        [...this._windows.keys()].forEach(preview => this._syncOverlay(preview));
     }
 
     /**
@@ -942,6 +952,10 @@ class Workspace extends St.Widget {
         });
 
         this.metaWorkspace = metaWorkspace;
+        this._activeWorkspaceChangedId =
+            this.metaWorkspace?.connect('notify::active', () => {
+                this.layoutManager.syncOverlays();
+            });
 
         this._overviewAdjustment = overviewAdjustment;
         this.monitorIndex = monitorIndex;
@@ -1188,6 +1202,7 @@ class Workspace extends St.Widget {
         if (this.metaWorkspace) {
             this.metaWorkspace.disconnect(this._windowAddedId);
             this.metaWorkspace.disconnect(this._windowRemovedId);
+            this.metaWorkspace.disconnect(this._activeWorkspaceChangedId);
         }
         global.display.disconnect(this._windowEnteredMonitorId);
         global.display.disconnect(this._windowLeftMonitorId);


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