[gnome-shell] altTab: Consider attached modals for window order



commit d4ce51b1b78197def929db329b7e8f4e0d3cec2e
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Oct 6 23:32:08 2016 +0200

    altTab: Consider attached modals for window order
    
    Similar to bug 667552 for the app switcher, attached modal dialogs
    can result in an unexpected window order in the window switcher:
    Selecting a window with an attached dialog will focus the dialog
    instead, but as the dialog itself is ignored in the window list,
    its last-used timestamp is not taken into account for the position
    in the MRU list. Fix this by fetching the list of all NORMAL windows
    and filter out skip-taskbar windows ourselves, while making sure that
    windows appear in the position of their attached modal dialog where
    appropriate.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=747153

 js/ui/altTab.js |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index dfdf9c3..d101335 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -46,6 +46,19 @@ function _createWindowClone(window, size) {
                                y_expand: true });
 };
 
+function getWindows(workspace) {
+    // We ignore skip-taskbar windows in switchers, but if they are attached
+    // to their parent, their position in the MRU list may be more appropriate
+    // than the parent; so start with the complete list ...
+    let windows = global.display.get_tab_list(Meta.TabList.NORMAL_ALL,
+                                              workspace);
+    // ... map windows to their parent where appropriate ...
+    return windows.map(w => {
+        return w.is_attached_dialog() ? w.get_transient_for() : w;
+    // ... and filter out skip-taskbar windows and duplicates
+    }).filter((w, i, a) => !w.skip_taskbar && a.indexOf(w) == i);
+}
+
 const AppSwitcherPopup = new Lang.Class({
     Name: 'AppSwitcherPopup',
     Extends: SwitcherPopup.SwitcherPopup,
@@ -517,7 +530,7 @@ const WindowSwitcherPopup = new Lang.Class({
 
     _getWindowList: function() {
         let workspace = this._settings.get_boolean('current-workspace-only') ? 
global.screen.get_active_workspace() : null;
-        return global.display.get_tab_list(Meta.TabList.NORMAL, workspace);
+        return getWindows(workspace);
     },
 
     _keyPressHandler: function(keysym, action) {
@@ -555,7 +568,7 @@ const WindowCyclerPopup = new Lang.Class({
 
     _getWindows: function() {
         let workspace = this._settings.get_boolean('current-workspace-only') ? 
global.screen.get_active_workspace() : null;
-        return global.display.get_tab_list(Meta.TabList.NORMAL, workspace);
+        return getWindows(workspace);
     },
 
     _keyPressHandler: function(keysym, action) {


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