[gnome-shell-extensions/gnome-3-38] workspace-indicator: Use overlap to determine preview visibility



commit d7a824f35fcdf078c0c8f4a20f5bcddd5abfae5c
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Oct 21 20:43:46 2020 +0200

    workspace-indicator: Use overlap to determine preview visibility
    
    In order to better reflect the actual workspace, show any preview
    that is at least partially located on the monitor, not only those
    that have the major part on that monitor.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/142>
    
    (cherry picked from commit 50d3ee57037ccea173c2a48fa324eb8b0acc3730)

 extensions/workspace-indicator/extension.js | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js
index d10e13e..76b35df 100644
--- a/extensions/workspace-indicator/extension.js
+++ b/extensions/workspace-indicator/extension.js
@@ -32,13 +32,12 @@ class WindowPreview extends St.Button {
         this._sizeChangedId = this._window.connect('size-changed',
             () => this.queue_relayout());
         this._positionChangedId = this._window.connect('position-changed',
-            () => this.queue_relayout());
+            () => {
+                this._updateVisible();
+                this.queue_relayout();
+            });
         this._minimizedChangedId = this._window.connect('notify::minimized',
             this._updateVisible.bind(this));
-        this._monitorEnteredId = global.display.connect('window-entered-monitor',
-            this._updateVisible.bind(this));
-        this._monitorLeftId = global.display.connect('window-left-monitor',
-            this._updateVisible.bind(this));
 
         this._focusChangedId = global.display.connect('notify::focus-window',
             this._onFocusChanged.bind(this));
@@ -54,8 +53,6 @@ class WindowPreview extends St.Button {
         this._window.disconnect(this._sizeChangedId);
         this._window.disconnect(this._positionChangedId);
         this._window.disconnect(this._minimizedChangedId);
-        global.display.disconnect(this._monitorEnteredId);
-        global.display.disconnect(this._monitorLeftId);
         global.display.disconnect(this._focusChangedId);
     }
 
@@ -67,8 +64,9 @@ class WindowPreview extends St.Button {
     }
 
     _updateVisible() {
-        let monitor = Main.layoutManager.findIndexForActor(this);
-        this.visible = monitor === this._window.get_monitor() &&
+        const monitor = Main.layoutManager.findIndexForActor(this);
+        const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor);
+        this.visible = this._window.get_frame_rect().overlap(workArea) &&
             this._window.window_type !== Meta.WindowType.DESKTOP &&
             this._window.showing_on_its_workspace();
     }


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