[gnome-shell] windowManager: Add unminimize effect



commit c9bcb411fc964e2edfbfcb1c91ea30181f4e1fb0
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 27 12:13:26 2015 +0100

    windowManager: Add unminimize effect
    
    The effect was added to mutter a while ago, but never implemented
    in the shell. Just do the reverse of the minimize animation ...
    
    https://bugzilla.gnome.org/show_bug.cgi?id=702662

 js/ui/windowManager.js   |   80 ++++++++++++++++++++++++++++++++++++++++++++++
 src/gnome-shell-plugin.c |   12 +++++++
 src/shell-wm-private.h   |    2 +
 src/shell-wm.c           |   30 +++++++++++++++++
 src/shell-wm.h           |    2 +
 5 files changed, 126 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index e0bf007..2691cdb 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -616,6 +616,7 @@ const WindowManager = new Lang.Class({
         this._shellwm =  global.window_manager;
 
         this._minimizing = [];
+        this._unminimizing = [];
         this._maximizing = [];
         this._unmaximizing = [];
         this._mapping = [];
@@ -641,6 +642,7 @@ const WindowManager = new Lang.Class({
         this._shellwm.connect('hide-tile-preview', Lang.bind(this, this._hideTilePreview));
         this._shellwm.connect('show-window-menu', Lang.bind(this, this._showWindowMenu));
         this._shellwm.connect('minimize', Lang.bind(this, this._minimizeWindow));
+        this._shellwm.connect('unminimize', Lang.bind(this, this._unminimizeWindow));
         this._shellwm.connect('maximize', Lang.bind(this, this._maximizeWindow));
         this._shellwm.connect('unmaximize', Lang.bind(this, this._unmaximizeWindow));
         this._shellwm.connect('map', Lang.bind(this, this._mapWindow));
@@ -1072,6 +1074,84 @@ const WindowManager = new Lang.Class({
         }
     },
 
+    _unminimizeWindow : function(shellwm, actor) {
+        let types = [Meta.WindowType.NORMAL,
+                     Meta.WindowType.MODAL_DIALOG,
+                     Meta.WindowType.DIALOG];
+        if (!this._shouldAnimateActor(actor, types)) {
+            shellwm.completed_unminimize(actor);
+            return;
+        }
+
+        this._unminimizing.push(actor);
+
+        if (actor.meta_window.is_monitor_sized()) {
+            actor.opacity = 0;
+            actor.set_scale(1.0, 1.0);
+            Tweener.addTween(actor,
+                         { opacity: 255,
+                           time: MINIMIZE_WINDOW_ANIMATION_TIME,
+                           transition: 'easeOutQuad',
+                           onComplete: this._unminimizeWindowDone,
+                           onCompleteScope: this,
+                           onCompleteParams: [shellwm, actor],
+                           onOverwrite: this._unminimizeWindowOverwritten,
+                           onOverwriteScope: this,
+                           onOverwriteParams: [shellwm, actor]
+                         });
+        } else {
+            let [success, geom] = actor.meta_window.get_icon_geometry();
+            if (success) {
+                actor.set_position(geom.x, geom.y);
+                actor.set_scale(geom.width / actor.width,
+                                geom.height / actor.height);
+            } else {
+                let monitor = Main.layoutManager.monitors[actor.meta_window.get_monitor()];
+                actor.set_position(monitor.x, monitor.y);
+                if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
+                    actor.x += monitor.width;
+                actor.set_scale(0, 0);
+            }
+
+            let rect = actor.meta_window.get_frame_rect();
+            let [xDest, yDest] = [rect.x, rect.y];
+
+            actor.show();
+            Tweener.addTween(actor,
+                             { scale_x: 1.0,
+                               scale_y: 1.0,
+                               x: xDest,
+                               y: yDest,
+                               time: MINIMIZE_WINDOW_ANIMATION_TIME,
+                               transition: 'easeInExpo',
+                               onComplete: this._unminimizeWindowDone,
+                               onCompleteScope: this,
+                               onCompleteParams: [shellwm, actor],
+                               onOverwrite: this._unminimizeWindowOverwritten,
+                               onOverwriteScope: this,
+                               onOverwriteParams: [shellwm, actor]
+                             });
+        }
+    },
+
+    _unminimizeWindowDone : function(shellwm, actor) {
+        if (this._removeEffect(this._unminimizing, actor)) {
+            Tweener.removeTweens(actor);
+            actor.set_scale(1.0, 1.0);
+            actor.set_opacity(255);
+            actor.set_pivot_point(0, 0);
+
+            shellwm.completed_unminimize(actor);
+        }
+    },
+
+    _unminimizeWindowOverwritten : function(shellwm, actor) {
+        if (this._removeEffect(this._unminimizing, actor)) {
+            shellwm.completed_unminimize(actor);
+        }
+    },
+
+
     _maximizeWindow : function(shellwm, actor, targetX, targetY, targetWidth, targetHeight) {
         shellwm.completed_maximize(actor);
     },
diff --git a/src/gnome-shell-plugin.c b/src/gnome-shell-plugin.c
index 9c52a63..a7266ef 100644
--- a/src/gnome-shell-plugin.c
+++ b/src/gnome-shell-plugin.c
@@ -40,6 +40,8 @@
 static void gnome_shell_plugin_start            (MetaPlugin          *plugin);
 static void gnome_shell_plugin_minimize         (MetaPlugin          *plugin,
                                                  MetaWindowActor     *actor);
+static void gnome_shell_plugin_unminimize       (MetaPlugin          *plugin,
+                                                 MetaWindowActor     *actor);
 static void gnome_shell_plugin_maximize         (MetaPlugin          *plugin,
                                                  MetaWindowActor     *actor,
                                                  gint                 x,
@@ -131,6 +133,7 @@ gnome_shell_plugin_class_init (GnomeShellPluginClass *klass)
   plugin_class->start            = gnome_shell_plugin_start;
   plugin_class->map              = gnome_shell_plugin_map;
   plugin_class->minimize         = gnome_shell_plugin_minimize;
+  plugin_class->unminimize       = gnome_shell_plugin_unminimize;
   plugin_class->maximize         = gnome_shell_plugin_maximize;
   plugin_class->unmaximize       = gnome_shell_plugin_unmaximize;
   plugin_class->destroy          = gnome_shell_plugin_destroy;
@@ -269,6 +272,15 @@ gnome_shell_plugin_minimize (MetaPlugin         *plugin,
 }
 
 static void
+gnome_shell_plugin_unminimize (MetaPlugin         *plugin,
+                               MetaWindowActor    *actor)
+{
+  _shell_wm_unminimize (get_shell_wm (),
+                      actor);
+
+}
+
+static void
 gnome_shell_plugin_maximize (MetaPlugin         *plugin,
                              MetaWindowActor    *actor,
                              gint                x,
diff --git a/src/shell-wm-private.h b/src/shell-wm-private.h
index 9e44b33..de260f2 100644
--- a/src/shell-wm-private.h
+++ b/src/shell-wm-private.h
@@ -10,6 +10,8 @@ G_BEGIN_DECLS
 
 void _shell_wm_minimize   (ShellWM         *wm,
                            MetaWindowActor *actor);
+void _shell_wm_unminimize (ShellWM         *wm,
+                           MetaWindowActor *actor);
 void _shell_wm_maximize   (ShellWM         *wm,
                            MetaWindowActor *actor,
                            gint             x,
diff --git a/src/shell-wm.c b/src/shell-wm.c
index 67d03b8..4b58df6 100644
--- a/src/shell-wm.c
+++ b/src/shell-wm.c
@@ -19,6 +19,7 @@ struct _ShellWM {
 enum
 {
   MINIMIZE,
+  UNMINIMIZE,
   MAXIMIZE,
   UNMAXIMIZE,
   MAP,
@@ -65,6 +66,14 @@ shell_wm_class_init (ShellWMClass *klass)
                   NULL, NULL, NULL,
                   G_TYPE_NONE, 1,
                   META_TYPE_WINDOW_ACTOR);
+  shell_wm_signals[UNMINIMIZE] =
+    g_signal_new ("unminimize",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 1,
+                  META_TYPE_WINDOW_ACTOR);
   shell_wm_signals[MAXIMIZE] =
     g_signal_new ("maximize",
                   G_TYPE_FROM_CLASS (klass),
@@ -198,6 +207,20 @@ shell_wm_completed_minimize (ShellWM         *wm,
 }
 
 /**
+ * shell_wm_completed_unminimize:
+ * @wm: the ShellWM
+ * @actor: the MetaWindowActor actor
+ *
+ * The plugin must call this when it has completed a window unminimize effect.
+ **/
+void
+shell_wm_completed_unminimize (ShellWM         *wm,
+                               MetaWindowActor *actor)
+{
+  meta_plugin_unminimize_completed (wm->plugin, actor);
+}
+
+/**
  * shell_wm_completed_maximize:
  * @wm: the ShellWM
  * @actor: the MetaWindowActor actor
@@ -329,6 +352,13 @@ _shell_wm_minimize (ShellWM         *wm,
 }
 
 void
+_shell_wm_unminimize (ShellWM         *wm,
+                      MetaWindowActor *actor)
+{
+  g_signal_emit (wm, shell_wm_signals[UNMINIMIZE], 0, actor);
+}
+
+void
 _shell_wm_maximize (ShellWM         *wm,
                     MetaWindowActor *actor,
                     int              target_x,
diff --git a/src/shell-wm.h b/src/shell-wm.h
index 778af52..7cd8948 100644
--- a/src/shell-wm.h
+++ b/src/shell-wm.h
@@ -29,6 +29,8 @@ ShellWM *shell_wm_new                        (MetaPlugin      *plugin);
 
 void     shell_wm_completed_minimize         (ShellWM         *wm,
                                               MetaWindowActor *actor);
+void     shell_wm_completed_unminimize       (ShellWM         *wm,
+                                              MetaWindowActor *actor);
 void     shell_wm_completed_maximize         (ShellWM         *wm,
                                               MetaWindowActor *actor);
 void     shell_wm_completed_unmaximize       (ShellWM         *wm,


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