[gnome-shell] Only show windows from the primary monitor on the overview workspace



commit cdd1209b55a9f1fd2374457a3ec7e014a009f624
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Mar 1 09:14:56 2011 +0100

    Only show windows from the primary monitor on the overview workspace
    
    This means a bunch of windows will not be visible at all in the overview.
    Those will be added back with per-screen workspaces on the non-primary
    monitors.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=609258

 js/ui/workspace.js      |   58 ++++++++++++++++++++++++++++++++++++++--------
 js/ui/workspacesView.js |    6 +++-
 2 files changed, 52 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 82dbcb0..049cc74 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -543,12 +543,12 @@ const WindowPositionFlags = {
 /**
  * @metaWorkspace: a #Meta.Workspace
  */
-function Workspace(metaWorkspace) {
-    this._init(metaWorkspace);
+function Workspace(metaWorkspace, monitorIndex) {
+    this._init(metaWorkspace, monitorIndex);
 }
 
 Workspace.prototype = {
-    _init : function(metaWorkspace) {
+    _init : function(metaWorkspace, monitorIndex) {
         // When dragging a window, we use this slot for reserve space.
         this._reservedSlot = null;
         this.metaWorkspace = metaWorkspace;
@@ -557,6 +557,8 @@ Workspace.prototype = {
         this._width = 0;
         this._height = 0;
 
+        this.monitorIndex = monitorIndex;
+        this._monitor = global.get_monitors()[this.monitorIndex];
         this._windowOverlaysGroup = new Clutter.Group();
         // Without this the drop area will be overlapped.
         this._windowOverlaysGroup.set_size(0, 0);
@@ -572,7 +574,7 @@ Workspace.prototype = {
 
         this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
 
-        let windows = Main.getWindowActorsForWorkspace(this.metaWorkspace.index());
+        let windows = global.get_window_actors().filter(this._isMyWindow, this);
 
         // Create clones for windows that should be
         // visible in the Overview
@@ -589,6 +591,10 @@ Workspace.prototype = {
                                                           Lang.bind(this, this._windowAdded));
         this._windowRemovedId = this.metaWorkspace.connect('window-removed',
                                                             Lang.bind(this, this._windowRemoved));
+        this._windowEnteredMonitorId = global.screen.connect('window-entered-monitor',
+                                                           Lang.bind(this, this._windowEnteredMonitor));
+        this._windowLeftMonitorId = global.screen.connect('window-left-monitor',
+                                                           Lang.bind(this, this._windowLeftMonitor));
         this._repositionWindowsId = 0;
 
         this.leavingOverview = false;
@@ -1036,7 +1042,7 @@ Workspace.prototype = {
         this._windowOverlaysGroup.hide();
     },
 
-    _windowRemoved : function(metaWorkspace, metaWin) {
+    _doRemoveWindow : function(metaWin) {
         let win = metaWin.get_compositor_private();
 
         // find the position of the window in our list
@@ -1045,6 +1051,10 @@ Workspace.prototype = {
         if (index == -1)
             return;
 
+        // Check if window still should be here
+        if (win && this._isMyWindow(win))
+            return;
+
         let clone = this._windows[index];
 
         this._windows.splice(index, 1);
@@ -1088,7 +1098,7 @@ Workspace.prototype = {
             Lang.bind(this, this._delayedWindowRepositioning));
     },
 
-    _windowAdded : function(metaWorkspace, metaWin) {
+    _doAddWindow : function(metaWin) {
         if (this.leavingOverview)
             return;
 
@@ -1100,13 +1110,18 @@ Workspace.prototype = {
             Mainloop.idle_add(Lang.bind(this,
                                         function () {
                                             if (this.actor && metaWin.get_compositor_private())
-                                                this._windowAdded(metaWorkspace, metaWin);
+                                                this._doAddWindow(metaWin);
                                             return false;
                                         }));
             return;
         }
 
-        if (!this._isOverviewWindow(win))
+        // We might have the window in our list already if it was on all workspaces and
+        // now was moved to this workspace
+        if (this._lookupIndex (metaWin) != -1)
+            return;
+
+        if (!this._isMyWindow(win) || !this._isOverviewWindow(win))
             return;
 
         let clone = this._addWindowClone(win);
@@ -1131,6 +1146,26 @@ Workspace.prototype = {
         this.positionWindows(WindowPositionFlags.ANIMATE);
     },
 
+    _windowAdded : function(metaWorkspace, metaWin) {
+        this._doAddWindow(metaWin);
+    },
+
+    _windowRemoved : function(metaWorkspace, metaWin) {
+        this._doRemoveWindow(metaWin);
+    },
+
+    _windowEnteredMonitor : function(metaScreen, monitorIndex, metaWin) {
+        if (monitorIndex == this.monitorIndex) {
+            this._doAddWindow(metaWin);
+        }
+    },
+
+    _windowLeftMonitor : function(metaScreen, monitorIndex, metaWin) {
+        if (monitorIndex == this.monitorIndex) {
+            this._doRemoveWindow(metaWin);
+        }
+    },
+
     // check for maximized windows on the workspace
     hasMaximizedWindows: function() {
         for (let i = 0; i < this._windows.length; i++) {
@@ -1213,6 +1248,8 @@ Workspace.prototype = {
 
         this.metaWorkspace.disconnect(this._windowAddedId);
         this.metaWorkspace.disconnect(this._windowRemovedId);
+        global.screen.disconnect(this._windowEnteredMonitorId);
+        global.screen.disconnect(this._windowLeftMonitorId);
 
         if (this._repositionWindowsId > 0)
             Mainloop.source_remove(this._repositionWindowsId);
@@ -1231,9 +1268,10 @@ Workspace.prototype = {
         this.leavingOverview = false;
     },
 
-    // Tests if @win belongs to this workspaces
+    // Tests if @win belongs to this workspaces and monitor
     _isMyWindow : function (win) {
-        return Main.isWindowActorDisplayedOnWorkspace(win, this.metaWorkspace.index());
+        return Main.isWindowActorDisplayedOnWorkspace(win, this.metaWorkspace.index()) &&
+            (!win.get_meta_window() || win.get_meta_window().get_monitor() == this.monitorIndex);
     },
 
     // Tests if @win should be shown in the Overview
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 2d63ed1..d163102 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -549,6 +549,8 @@ WorkspacesDisplay.prototype = {
         controls.connect('scroll-event',
                          Lang.bind(this, this._onScrollEvent));
 
+        this._monitorIndex = global.get_primary_monitor_index();
+        this._monitor = global.get_monitors()[this._monitorIndex];
 
         this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
         controls.add_actor(this._thumbnailsBox.actor);
@@ -577,7 +579,7 @@ WorkspacesDisplay.prototype = {
         this._workspaces = [];
         for (let i = 0; i < global.screen.n_workspaces; i++) {
             let metaWorkspace = global.screen.get_workspace_by_index(i);
-            this._workspaces[i] = new Workspace.Workspace(metaWorkspace);
+            this._workspaces[i] = new Workspace.Workspace(metaWorkspace, this._monitorIndex);
         }
 
         if (this.workspacesView)
@@ -763,7 +765,7 @@ WorkspacesDisplay.prototype = {
             // Assume workspaces are only added at the end
             for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
                 let metaWorkspace = global.screen.get_workspace_by_index(w);
-                this._workspaces[w] = new Workspace.Workspace(metaWorkspace);
+                this._workspaces[w] = new Workspace.Workspace(metaWorkspace, this._monitorIndex);
             }
 
             this._thumbnailsBox.addThumbnails(oldNumWorkspaces, newNumWorkspaces - oldNumWorkspaces);



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