[gnome-shell/T27795: 100/138] workspaceMonitor: Animate transition to desktop when minimizing the last window



commit 410b8181446da5a67fd12fe8afbca62333d8bca9
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Wed Jun 14 18:16:16 2017 +0100

    workspaceMonitor: Animate transition to desktop when minimizing the last window
    
    When minimizing the last window (or when closing the side component with no
    windows open) we run a animation to transition from the desaturated state
    of the icon grid to the solid one. Similarly, for consistency, we also run
    the "opposite" animation when unmimizing the first window.
    
    https://phabricator.endlessm.com/T17662
    https://phabricator.endlessm.com/T19824
    https://phabricator.endlessm.com/T20661

 js/ui/layout.js           | 27 +++++++++++++++++++++++++++
 js/ui/windowManager.js    |  4 ++++
 js/ui/workspaceMonitor.js | 19 +++++++++++++++++++
 3 files changed, 50 insertions(+)
---
diff --git a/js/ui/layout.js b/js/ui/layout.js
index 78f8f6a131..d8ccf53514 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -4,6 +4,7 @@
 const { Clutter, Gdk, Gio, GLib, GObject, Meta, Shell, St } = imports.gi;
 const Signals = imports.signals;
 
+const AppDisplay = imports.ui.appDisplay;
 const Background = imports.ui.background;
 const BackgroundMenu = imports.ui.backgroundMenu;
 const LoginManager = imports.misc.loginManager;
@@ -352,6 +353,32 @@ var LayoutManager = GObject.registerClass({
         this._backgroundGroup.add_child(this._viewsClone);
     }
 
+    _animateViewsClone(targetOpacity, targetSaturation) {
+        if (!this._viewsClone)
+            return;
+
+        // Don't unnecessarily tween the clone's saturation & opacity.
+        if (this._viewsClone.opacity == targetOpacity && this._viewsClone.saturation == targetSaturation)
+            return;
+
+        this._viewsClone.ease({
+            opacity: targetOpacity,
+            saturation: targetSaturation,
+            duration: 250,
+            transition: AppDisplay.EOS_ACTIVE_GRID_TRANSITION,
+        });
+    }
+
+    prepareToEnterOverview() {
+        this._animateViewsClone(AppDisplay.EOS_ACTIVE_GRID_OPACITY,
+                                AppDisplay.EOS_ACTIVE_GRID_SATURATION);
+    }
+
+    prepareToLeaveOverview() {
+        this._animateViewsClone(AppDisplay.EOS_INACTIVE_GRID_OPACITY,
+                                AppDisplay.EOS_INACTIVE_GRID_SATURATION);
+    }
+
     _addBackgroundMenu(bgManager) {
         let clickAction = new Clutter.ClickAction();
         bgManager.backgroundActor.add_action(clickAction);
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 9b538580bc..49da6be262 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -980,6 +980,7 @@ var WindowManager = class {
         // The desktop overlay needs to replicate the background's functionality;
         // when clicked, we animate the side component out before emitting "background-clicked".
         this._desktopOverlay.connect('clicked', () => {
+            Main.layoutManager.prepareToEnterOverview();
             this._slideSideComponentOut(this._shellwm,
                                         this._desktopOverlay.overlayActor,
                                         () => Main.layoutManager.emit('background-clicked'));
@@ -1666,6 +1667,7 @@ var WindowManager = class {
         }
 
         this._unminimizing.push(actor);
+        Main.layoutManager.prepareToLeaveOverview();
 
         if (actor.meta_window.is_monitor_sized()) {
             actor.opacity = 0;
@@ -2164,6 +2166,8 @@ var WindowManager = class {
             if (!this._showDesktopOnDestroyDone && SideComponent.shouldHideOtherWindows(actor.meta_window)) {
                 // reveal other windows while we slide out the side component
                 this._showOtherWindows(actor, true);
+            } else if (this._showDesktopOnDestroyDone) {
+                Main.layoutManager.prepareToEnterOverview();
             }
 
             return;
diff --git a/js/ui/workspaceMonitor.js b/js/ui/workspaceMonitor.js
index 0e8b77cdd4..d89eed99a9 100644
--- a/js/ui/workspaceMonitor.js
+++ b/js/ui/workspaceMonitor.js
@@ -8,7 +8,9 @@ const ViewSelector = imports.ui.viewSelector;
 var WorkspaceMonitor = class {
     constructor() {
         this._shellwm = global.window_manager;
+        this._shellwm.connect('minimize', this._windowDisappearing.bind(this));
         this._shellwm.connect('minimize-completed', this._windowDisappeared.bind(this));
+        this._shellwm.connect('destroy', this._windowDisappearing.bind(this));
         this._shellwm.connect('destroy-completed', this._windowDisappeared.bind(this));
 
         this._windowTracker = Shell.WindowTracker.get_default();
@@ -32,6 +34,23 @@ var WorkspaceMonitor = class {
         }
     }
 
+    _windowDisappearing(shellwm, actor) {
+        function _isLastWindow(apps, win) {
+            if (apps.length == 0)
+                return true;
+
+            if (apps.length > 1)
+                return false;
+
+            let windows = apps[0].get_windows();
+            return (windows.length == 1) && (windows[0] == win);
+        };
+
+        let visibleApps = this._getVisibleApps();
+        if (_isLastWindow(visibleApps, actor.meta_window))
+            Main.layoutManager.prepareToEnterOverview();
+    }
+
     _updateOverview() {
         let visibleApps = this._getVisibleApps();
         if (visibleApps.length == 0) {


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