[gnome-shell] Consider workspace when sorting windows in menu.



commit 4798ad5107024e0e661f23a444b23dbbc16dd715
Author: Steve Frécinaux <code istique net>
Date:   Fri Oct 2 01:12:59 2009 +0200

    Consider workspace when sorting windows in menu.
    
    By sorting the windows in the current workspace first, we ensure that
    when using alt+tab to switch windows, we will pick a window on the
    active workspace as the default focused window for the application if
    the application has at least one window on the current workspace (that
    is, if it is on the left of the app switcher separator).
    
    This makes the behaviour of alt+tab more predictable for the user, as
    an user will expect alt+tab to switch to the window he/she can see right
    now rather than the one on the workspace he just left (presumably to do
    something else on the workspace he's currently on).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=590563

 js/ui/appIcon.js |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)
---
diff --git a/js/ui/appIcon.js b/js/ui/appIcon.js
index 7a9df6f..6498d6b 100644
--- a/js/ui/appIcon.js
+++ b/js/ui/appIcon.js
@@ -165,6 +165,15 @@ AppIcon.prototype = {
 
     _resortWindows: function() {
         this.windows.sort(function (a, b) {
+            let activeWorkspace = global.screen.get_active_workspace();
+            let wsA = a.get_workspace() == activeWorkspace;
+            let wsB = b.get_workspace() == activeWorkspace;
+
+            if (wsA && !wsB)
+                return -1;
+            else if (wsB && !wsA)
+                return 1;
+
             let visA = a.showing_on_its_workspace();
             let visB = b.showing_on_its_workspace();
 
@@ -397,20 +406,24 @@ AppIconMenu.prototype = {
             }
         }
 
+        // Display the app windows menu items and the separator between windows
+        // of the current desktop and other windows.
         let activeWorkspace = global.screen.get_active_workspace();
+        let separatorShown = windows[0].get_workspace() != activeWorkspace;
 
-        let currentWorkspaceWindows = windows.filter(function (w) {
-            return w.get_workspace() == activeWorkspace;
-        });
-        let otherWorkspaceWindows = windows.filter(function (w) {
-            return w.get_workspace() != activeWorkspace;
-        });
+        for (let i = 0; i < windows.length; i++) {
+            if (!separatorShown && windows[i].get_workspace() != activeWorkspace) {
+                this._appendSeparator();
+                separatorShown = true;
+            }
 
-        this._appendWindows(currentWorkspaceWindows, iconsDiffer);
-        if (currentWorkspaceWindows.length > 0 && otherWorkspaceWindows.length > 0) {
-            this._appendSeparator();
+            let icon = null;
+            if (iconsDiffer)
+                icon = Shell.TextureCache.get_default().bind_pixbuf_property(windows[i], "mini-icon");
+
+            let box = this._appendMenuItem(icon, windows[i].title);
+            box._window = windows[i];
         }
-        this._appendWindows(otherWorkspaceWindows, iconsDiffer);
 
         if (windows.length > 0)
             this._appendSeparator();
@@ -468,19 +481,6 @@ AppIconMenu.prototype = {
         return box;
     },
 
-    _appendWindows: function (windows, iconsDiffer) {
-        for (let i = 0; i < windows.length; i++) {
-            let metaWindow = windows[i];
-
-            let icon = null;
-            if (iconsDiffer) {
-                icon = Shell.TextureCache.get_default().bind_pixbuf_property(metaWindow, "mini-icon");
-            }
-            let box = this._appendMenuItem(icon, metaWindow.title);
-            box._window = metaWindow;
-        }
-    },
-
     popup: function(activatingButton) {
         let [stageX, stageY] = this._source.actor.get_transformed_position();
         let [stageWidth, stageHeight] = this._source.actor.get_transformed_size();



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