From 1c69380923a7bbb5e7580130cefca010671f64c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20Fr=C3=A9cinaux?= Date: Tue, 29 Sep 2009 19:29:17 +0200 Subject: [PATCH] [AppSwitcher] Put apps with no window on current workspace at the end. Following the idea expressed in bug 590563 by mccann ("Minimized or hidden applications should appear at the end of the list"), we should also put applications that have no visible window in the active workspace at the end of the alt-tab window list, after apps which have minimized windows in the active workspace. --- js/ui/altTab.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/js/ui/altTab.js b/js/ui/altTab.js index ec23fdabc..827ae6fa1 100644 --- a/js/ui/altTab.js +++ b/js/ui/altTab.js @@ -126,6 +126,14 @@ AltTabPopup.prototype = { return true; }, + _hasWindowsOnWorkspace: function(appIcon, workspace) { + for (let i = 0; i < appIcon.windows.length; i++) { + if (appIcon.windows[i].get_workspace() == workspace) + return true; + } + return false; + }, + _hasVisibleWindows : function(appIcon) { for (let i = 0; i < appIcon.windows.length; i++) { if (appIcon.windows[i].showing_on_its_workspace()) @@ -135,6 +143,22 @@ AltTabPopup.prototype = { }, _sortAppIcon : function(appIcon1, appIcon2) { + // We intend to sort the application list so applications appear + // with this order: + // 1. Apps with visible windows on the active workspace; + // 2. Apps with minimized windows on the active workspace; + // 3. Apps with visible windows on any other workspace; + // 4. Other apps. + + let workspace = global.screen.get_active_workspace(); + let ws1 = this._hasWindowsOnWorkspace(appIcon1, workspace); + let ws2 = this._hasWindowsOnWorkspace(appIcon2, workspace); + + if (ws1 && !ws2) + return -1; + else if (ws2 && !ws1) + return 1; + let vis1 = this._hasVisibleWindows(appIcon1); let vis2 = this._hasVisibleWindows(appIcon2);