[gnome-shell/eos3.8: 58/255] Implement the "toggle windows picker" functionality



commit f6c224181822571c1e3af4b332cab11fa8b0e26c
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Wed Feb 14 10:13:20 2018 +0000

    Implement the "toggle windows picker" functionality
    
    This will be invoked via the hot corner, allowing the user to pick one
    of the running applications from a high-level view of clones.
    
    Also, enable toggling the windows picker with the Super+S keybinding

 js/ui/hotCorner.js    |  2 +-
 js/ui/main.js         |  2 +-
 js/ui/overview.js     | 47 ++++++++++++++++++++++++++++++++++++++++++++---
 js/ui/viewSelector.js |  6 +++---
 4 files changed, 49 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/hotCorner.js b/js/ui/hotCorner.js
index 60164b7787..034ec41d9d 100644
--- a/js/ui/hotCorner.js
+++ b/js/ui/hotCorner.js
@@ -49,7 +49,7 @@ class HotCorner extends PanelMenu.SingleIconButton {
              event.type() === Clutter.EventType.BUTTON_PRESS)) {
             let button = event.get_button();
             if (button === Gdk.BUTTON_PRIMARY && Main.overview.shouldToggleByCornerOrButton())
-                Main.overview.toggle();
+                Main.overview.toggleWindows();
             else if (button === Gdk.BUTTON_SECONDARY)
                 this.menu.toggle();
         }
diff --git a/js/ui/main.js b/js/ui/main.js
index 146ea3007e..103ab2badf 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -108,7 +108,7 @@ function _sessionUpdated() {
     wm.setCustomKeybindingHandler('panel-main-menu',
                                   Shell.ActionMode.NORMAL |
                                   Shell.ActionMode.OVERVIEW,
-                                  sessionMode.hasOverview ? overview.toggle.bind(overview) : null);
+                                  sessionMode.hasOverview ? overview.toggleWindows.bind(overview) : null);
     wm.allowKeybinding('overlay-key', Shell.ActionMode.NORMAL |
                                       Shell.ActionMode.OVERVIEW);
 
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 20c8a960b0..431dfd7996 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -196,6 +196,8 @@ var Overview = class {
 
         this._visible = false;          // animating to overview, in overview, animating out
         this._shown = false;            // show() and not hide()
+        this._toggleToHidden = false;   // Whether to hide the overview when either toggle function is called
+        this._targetPage = null;        // do we have a target page to animate to?
         this._modal = false;            // have a modal grab
         this._animationInProgress = false;
         this._visibleTarget = false;
@@ -295,6 +297,8 @@ var Overview = class {
     }
 
     _onPageChanged() {
+        this._toggleToHidden = false;
+
         // SideComponent hooks on this signal but can't connect directly to
         // viewSelector since it won't be created at the time the component
         // is enabled, so rely on the overview and re-issue it from here.
@@ -459,10 +463,12 @@ var Overview = class {
     }
 
     _showOrSwitchPage(page) {
-        if (this.visible)
+        if (this.visible) {
             this.viewSelector.setActivePage(page);
-        else
+        } else {
+            this._targetPage = page;
             this.show();
+        }
     }
 
     showApps() {
@@ -530,6 +536,32 @@ var Overview = class {
         this.hide();
     }
 
+    toggleWindows() {
+        if (this.isDummy)
+            return;
+
+        if (!this.visible ||
+            this.viewSelector.getActivePage() !== ViewSelector.ViewPage.WINDOWS) {
+            this.showWindows();
+            return;
+        }
+
+        if (!this._toggleToHidden) {
+            this.showApps();
+            return;
+        }
+
+        if (!Main.workspaceMonitor.hasVisibleWindows) {
+            // There are active windows but all of them are
+            // hidden, so we get back to show the icons grid.
+            this.showApps();
+            return;
+        }
+
+        // Toggle to the currently open window
+        this.hide();
+    }
+
     // Checks if the Activities button is currently sensitive to
     // clicks. The first call to this function within the
     // OVERVIEW_ACTIVATION_TIMEOUT time of the hot corner being
@@ -603,7 +635,16 @@ var Overview = class {
         this._activationTime = GLib.get_monotonic_time() / GLib.USEC_PER_SEC;
 
         Meta.disable_unredirect_for_display(global.display);
-        this.viewSelector.show();
+
+        if (!this._targetPage)
+            this._targetPage = ViewSelector.ViewPage.WINDOWS;
+
+        this.viewSelector.show(this._targetPage);
+        this._targetPage = null;
+
+        // Since the overview is just becoming visible, we should toggle back
+        // the hidden state
+        this._toggleToHidden = true;
 
         this._overview.opacity = 0;
         this._overview.ease({
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 8dbfa7441e..4b01e66efd 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -228,7 +228,7 @@ var ViewSelector = GObject.registerClass({
                               Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
                               Shell.ActionMode.NORMAL |
                               Shell.ActionMode.OVERVIEW,
-                              Main.overview.toggle.bind(Main.overview));
+                              Main.overview.toggleWindows.bind(Main.overview));
 
         let side;
         if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
@@ -262,11 +262,11 @@ var ViewSelector = GObject.registerClass({
         Main.overview.show();
     }
 
-    show() {
+    show(viewPage) {
         this.reset();
         this._workspacesDisplay.show(true);
 
-        this._showPage(this._appsPage);
+        this._showPage(this._pageFromViewPage(viewPage));
     }
 
     animateFromOverview() {


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