[gnome-shell] AppWellMenu: Remove window filtering



commit c2ae95f912f6b36d04a3259fc8f5b0f56b7190f8
Author: Adel Gadllah <adel gadllah gmail com>
Date:   Sat Feb 12 20:03:44 2011 +0100

    AppWellMenu: Remove window filtering
    
    Don't filter and highlight windows when opening the menu
    as this turned out to be distracting and confusing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=642189

 js/ui/appDisplay.js     |  102 +--------------------------------------
 js/ui/workspace.js      |  124 ++++------------------------------------------
 js/ui/workspacesView.js |   64 ------------------------
 3 files changed, 12 insertions(+), 278 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index cd51aab..e39d399 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -433,18 +433,12 @@ AppWellIcon.prototype = {
 
         if (!this._menu) {
             this._menu = new AppIconMenu(this);
-            this._menu.connect('highlight-window', Lang.bind(this, function (menu, window) {
-                this.highlightWindow(window);
-            }));
             this._menu.connect('activate-window', Lang.bind(this, function (menu, window) {
                 this.activateWindow(window);
             }));
             this._menu.connect('popup', Lang.bind(this, function (menu, isPoppedUp) {
-                if (isPoppedUp) {
-                    this._onMenuPoppedUp();
-                } else {
+                if (!isPoppedUp)
                     this._onMenuPoppedDown();
-                }
             }));
 
             this._menuManager.addMenu(this._menu);
@@ -455,45 +449,16 @@ AppWellIcon.prototype = {
         return false;
     },
 
-    highlightWindow: function(metaWindow) {
-        if (this._didActivateWindow)
-            return;
-        if (!this._getRunning())
-            return;
-        Main.overview.getWorkspacesForWindow(metaWindow).setHighlightWindow(metaWindow);
-    },
-
     activateWindow: function(metaWindow) {
         if (metaWindow) {
-            this._didActivateWindow = true;
             Main.activateWindow(metaWindow);
         } else {
             Main.overview.hide();
         }
     },
 
-    _onMenuPoppedUp: function() {
-        if (this._getRunning()) {
-            Main.overview.getWorkspacesForWindow(null).setApplicationWindowSelection(this.app.get_id());
-            this._setWindowSelection = true;
-            this._didActivateWindow = false;
-        }
-    },
-
     _onMenuPoppedDown: function() {
         this.actor.sync_hover();
-
-        if (this._didActivateWindow)
-            return;
-        if (!this._setWindowSelection)
-            return;
-
-        Main.overview.getWorkspacesForWindow(null).setApplicationWindowSelection(null);
-        this._setWindowSelection = false;
-    },
-
-    _getRunning: function() {
-        return this.app.state != Shell.AppState.STOPPED;
     },
 
     _onActivate: function (event) {
@@ -509,11 +474,6 @@ AppWellIcon.prototype = {
         Main.overview.hide();
     },
 
-    // called by this._menuManager when it has the grab
-    menuEventFilter: function(event) {
-        return this._menu.menuEventFilter(event);
-    },
-
     shellWorkspaceLaunch : function(params) {
         params = Params.parse(params, { workspace: null,
                                         timestamp: null });
@@ -549,7 +509,6 @@ AppIconMenu.prototype = {
 
         this._source = source;
 
-        this.connect('active-changed', Lang.bind(this, this._onActiveChanged));
         this.connect('activate', Lang.bind(this, this._onActivate));
         this.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged));
 
@@ -596,7 +555,6 @@ AppIconMenu.prototype = {
         this._toggleFavoriteMenuItem = this._appendMenuItem(isFavorite ? _("Remove from Favorites")
                                                                     : _("Add to Favorites"));
 
-        this._highlightedItem = null;
     },
 
     _appendSeparator: function () {
@@ -620,68 +578,10 @@ AppIconMenu.prototype = {
         if (open) {
             this.emit('popup', true);
         } else {
-            this._updateHighlight(null);
             this.emit('popup', false);
         }
     },
 
-    // called by this._menuManager when it has the grab
-    menuEventFilter: function(event) {
-        let eventType = event.type();
-
-        // Check if the user is interacting with a window representation
-        // rather than interacting with the menu
-
-        if (eventType == Clutter.EventType.BUTTON_RELEASE) {
-            let metaWindow = this._findMetaWindowForActor(event.get_source());
-            if (metaWindow)
-                this.emit('activate-window', metaWindow);
-        } else if (eventType == Clutter.EventType.ENTER) {
-            let metaWindow = this._findMetaWindowForActor(event.get_source());
-            if (metaWindow)
-                this._selectMenuItemForWindow(metaWindow, true);
-        } else if (eventType == Clutter.EventType.LEAVE) {
-            let metaWindow = this._findMetaWindowForActor(event.get_source());
-            if (metaWindow)
-                this._selectMenuItemForWindow(metaWindow, false);
-        }
-
-        return false;
-    },
-
-    _findMetaWindowForActor: function (actor) {
-        if (actor._delegate.metaWindow)
-            return actor._delegate.metaWindow;
-        else if (actor.get_meta_window)
-            return actor.get_meta_window();
-        return null;
-    },
-
-    _updateHighlight: function (item) {
-        if (this._highlightedItem)
-            this.emit('highlight-window', null);
-        this._highlightedItem = item;
-        if (this._highlightedItem) {
-            let window = this._highlightedItem._window;
-            if (window)
-                this.emit('highlight-window', window);
-        }
-    },
-
-    _selectMenuItemForWindow: function (metaWindow, selected) {
-        let items = this.getMenuItems();
-        for (let i = 0; i < items.length; i++) {
-            let item = items[i];
-            let menuMetaWindow = item._window;
-            if (menuMetaWindow == metaWindow)
-                item.setActive(selected);
-        }
-    },
-
-    _onActiveChanged: function (menu, child) {
-        this._updateHighlight(child);
-    },
-
     _onActivate: function (actor, child) {
         if (child._window) {
             let metaWindow = child._window;
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 0904913..83bd914 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -564,9 +564,6 @@ Workspace.prototype = {
             }
         }
 
-        // A filter for what windows we display
-        this._showOnlyWindows = null;
-
         // Track window changes
         this._windowAddedId = this.metaWorkspace.connect('window-added',
                                                           Lang.bind(this, this._windowAdded));
@@ -597,18 +594,6 @@ Workspace.prototype = {
             new_parent.add_actor(this._windowOverlaysGroup);
     },
 
-    /**
-     * lookupCloneForMetaWindow:
-     * @metaWindow: A #MetaWindow
-     *
-     * Given a #MetaWindow instance, find the WindowClone object
-     * which represents it in the workspaces display.
-     */
-    lookupCloneForMetaWindow: function (metaWindow) {
-        let index = this._lookupIndex (metaWindow);
-        return index < 0 ? null : this._windows[index];
-    },
-
     containsMetaWindow: function (metaWindow) {
         return this._lookupIndex(metaWindow) >= 0;
     },
@@ -617,48 +602,6 @@ Workspace.prototype = {
         return this._windows.length == 0;
     },
 
-    setShowOnlyWindows: function(showOnlyWindows, reposition) {
-        this._showOnlyWindows = showOnlyWindows;
-        this._resetCloneVisibility();
-        if (reposition)
-            this.positionWindows(WindowPositionFlags.ANIMATE);
-    },
-
-    /**
-     * setLightboxMode:
-     * @showLightbox: If true, dim background and allow highlighting a specific window
-     *
-     * This function also resets the highlighted window state.
-     */
-    setLightboxMode: function (showLightbox) {
-        if (!this._lightbox)
-            this._lightbox = new Lightbox.Lightbox(this.actor,
-                                                   { fadeTime: LIGHTBOX_FADE_TIME });
-
-        if (showLightbox)
-            this._lightbox.show();
-        else
-            this._lightbox.hide();
-    },
-
-    /**
-     * setHighlightWindow:
-     * @metaWindow: A #MetaWindow
-     *
-     * Draw the user's attention to the given window @metaWindow.
-     */
-    setHighlightWindow: function (metaWindow) {
-        if (!this._lightbox)
-            return;
-
-        let actor;
-        if (metaWindow != null) {
-            let clone = this.lookupCloneForMetaWindow(metaWindow);
-            actor = clone.actor;
-        }
-        this._lightbox.highlight(actor);
-    },
-
     /**
      * setReactive:
      * @reactive: %true iff the workspace should be reactive
@@ -669,47 +612,6 @@ Workspace.prototype = {
         this.actor.reactive = reactive;
     },
 
-    _isCloneVisible: function(clone) {
-        return this._showOnlyWindows == null || (clone.metaWindow in this._showOnlyWindows);
-    },
-
-    /**
-     * _getVisibleClones:
-     *
-     * Returns a list WindowClone objects where the clone isn't filtered
-     * out by any application filter.
-     * The returned array will always be newly allocated; it is not in any
-     * defined order, and thus it's convenient to call .sort() with your
-     * choice of sorting function.
-     */
-    _getVisibleClones: function() {
-        let visible = [];
-
-        for (let i = 0; i < this._windows.length; i++) {
-            let clone = this._windows[i];
-
-            if (!this._isCloneVisible(clone))
-                continue;
-
-            visible.push(clone);
-        }
-        return visible;
-    },
-
-    _resetCloneVisibility: function () {
-        for (let i = 0; i < this._windows.length; i++) {
-            let clone = this._windows[i];
-            let overlay = this._windowOverlays[i];
-
-            if (!this._isCloneVisible(clone)) {
-                clone.actor.hide();
-                overlay.hide();
-            } else {
-                clone.actor.show();
-            }
-        }
-    },
-
     // Only use this for n <= 20 say
     _factorial: function(n) {
         let result = 1;
@@ -948,25 +850,23 @@ Workspace.prototype = {
             this._repositionWindowsId = 0;
         }
 
-        let totalVisible = 0;
-
-        let visibleClones = this._getVisibleClones();
+        let clones = this._windows.slice();
         if (this._reservedSlot)
-            visibleClones.push(this._reservedSlot);
+            clones.push(this._reservedSlot);
 
         let workspaceZooming = flags & WindowPositionFlags.ZOOM;
         let animate = flags & WindowPositionFlags.ANIMATE;
 
         // Start the animations
-        let slots = this._computeAllWindowSlots(visibleClones.length);
-        visibleClones = this._orderWindowsByMotionAndStartup(visibleClones, slots);
+        let slots = this._computeAllWindowSlots(clones.length);
+        clones = this._orderWindowsByMotionAndStartup(clones, slots);
 
         let currentWorkspace = global.screen.get_active_workspace();
         let isOnCurrentWorkspace = this.metaWorkspace == currentWorkspace;
 
-        for (let i = 0; i < visibleClones.length; i++) {
+        for (let i = 0; i < clones.length; i++) {
             let slot = slots[i];
-            let clone = visibleClones[i];
+            let clone = clones[i];
             let metaWindow = clone.metaWindow;
             let mainIndex = this._lookupIndex(metaWindow);
             let overlay = this._windowOverlays[mainIndex];
@@ -1022,16 +922,16 @@ Workspace.prototype = {
     },
 
     syncStacking: function(stackIndices) {
-        let visibleClones = this._getVisibleClones();
-        visibleClones.sort(function (a, b) { return stackIndices[a.metaWindow.get_stable_sequence()] - stackIndices[b.metaWindow.get_stable_sequence()]; });
+        let clones = this._windows.slice();
+        clones.sort(function (a, b) { return stackIndices[a.metaWindow.get_stable_sequence()] - stackIndices[b.metaWindow.get_stable_sequence()]; });
 
-        for (let i = 0; i < visibleClones.length; i++) {
-            let clone = visibleClones[i];
+        for (let i = 0; i < clones.length; i++) {
+            let clone = clones[i];
             let metaWindow = clone.metaWindow;
             if (i == 0) {
                 clone.setStackAbove(null);
             } else {
-                let previousClone = visibleClones[i - 1];
+                let previousClone = clones[i - 1];
                 clone.setStackAbove(previousClone.actor);
             }
         }
@@ -1068,8 +968,6 @@ Workspace.prototype = {
         for (let i = 0; i < this._windows.length; i++) {
             let clone = this._windows[i];
             let overlay = this._windowOverlays[i];
-            if (this._showOnlyWindows != null && !(clone.metaWindow in this._showOnlyWindows))
-                continue;
             this._showWindowOverlay(clone, overlay, this.metaWorkspace == currentWorkspace);
         }
     },
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 32f5e2c..85ec1f7 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -94,9 +94,6 @@ WorkspacesView.prototype = {
 
         this._timeoutId = 0;
 
-        this._windowSelectionAppId = null;
-        this._highlightWindow = null;
-
         this._switchWorkspaceNotifyId =
             global.window_manager.connect('switch-workspace',
                                           Lang.bind(this, this._activeWorkspaceChanged));
@@ -121,76 +118,15 @@ WorkspacesView.prototype = {
         return null;
     },
 
-    setHighlightWindow: function (metaWindow) {
-        // Looping over all workspaces is easier than keeping track of the last
-        // highlighted window while trying to handle the window or workspace possibly
-        // going away.
-        for (let i = 0; i < this._workspaces.length; i++) {
-            this._workspaces[i].setHighlightWindow(null);
-        }
-        if (metaWindow != null) {
-            let workspace = this._lookupWorkspaceForMetaWindow(metaWindow);
-            workspace.setHighlightWindow(metaWindow);
-        }
-    },
-
     getActiveWorkspace: function() {
         let active = global.screen.get_active_workspace_index();
         return this._workspaces[active];
     },
 
-    _clearApplicationWindowSelection: function(reposition) {
-        if (this._windowSelectionAppId == null)
-            return;
-        this._windowSelectionAppId = null;
-
-        for (let i = 0; i < this._workspaces.length; i++) {
-            this._workspaces[i].setLightboxMode(false);
-            this._workspaces[i].setShowOnlyWindows(null, reposition);
-        }
-    },
-
-    /**
-     * setApplicationWindowSelection:
-     * @appid: Application identifier string
-     *
-     * Enter a mode which shows only the windows owned by the
-     * given application, and allow highlighting of a specific
-     * window with setHighlightWindow().
-     */
-    setApplicationWindowSelection: function (appId) {
-        if (appId == null) {
-            this._clearApplicationWindowSelection(true);
-            return;
-        }
-
-        if (appId == this._windowSelectionAppId)
-            return;
-
-        this._windowSelectionAppId = appId;
-
-        let appSys = Shell.AppSystem.get_default();
-
-        let showOnlyWindows = {};
-        let app = appSys.get_app(appId);
-        let windows = app.get_windows();
-        for (let i = 0; i < windows.length; i++) {
-            showOnlyWindows[windows[i]] = 1;
-        }
-
-        for (let i = 0; i < this._workspaces.length; i++) {
-            this._workspaces[i].setLightboxMode(true);
-            this._workspaces[i].setShowOnlyWindows(showOnlyWindows, true);
-        }
-    },
-
     hide: function() {
         let activeWorkspaceIndex = global.screen.get_active_workspace_index();
         let activeWorkspace = this._workspaces[activeWorkspaceIndex];
 
-        if (this._windowSelectionAppId != null)
-            this._clearApplicationWindowSelection(false);
-
         activeWorkspace.actor.raise_top();
 
         for (let w = 0; w < this._workspaces.length; w++)



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