[gnome-shell/wip/message-tray: 3/22] messageTray: Move the windows up/down when the tray is toggled



commit 1f3a10ffb75d9465d0c7d1c209cc795e350cdb6d
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Jul 14 13:10:40 2012 +0200

    messageTray: Move the windows up/down when the tray is toggled
    
    Only the windows on the primary monitor are moved because the
    secondary does not have a message tray.
    
    Fixes: https://bugzilla.gnome.org/677215

 js/ui/messageTray.js |   85 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 83 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index d7b7647..82f6398 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -21,6 +21,8 @@ const Params = imports.misc.params;
 const Tweener = imports.ui.tweener;
 const Util = imports.misc.util;
 
+const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings';
+
 const ANIMATION_TIME = 0.2;
 const NOTIFICATION_TIMEOUT = 4;
 const SUMMARY_TIMEOUT = 1;
@@ -1547,6 +1549,8 @@ const MessageTray = new Lang.Class({
         this._notificationRemoved = false;
         this._reNotifyAfterHideNotification = null;
         this._inFullscreen = false;
+        this._tweening = 0;
+        this._windowsShifted = 0;
 
         this._corner = new Clutter.Rectangle({ width: 1,
                                                height: 1,
@@ -1590,6 +1594,11 @@ const MessageTray = new Lang.Class({
         this._isScreenLocked = false;
         Main.screenShield.connect('lock-status-changed', Lang.bind(this, this._onScreenLockStatusChanged));
 
+        global.display.add_keybinding('toggle-message-tray',
+                                      new Gio.Settings({ schema: SHELL_KEYBINDINGS_SCHEMA }),
+                                      Meta.KeyBindingFlags.NONE,
+                                      Lang.bind(this, this.toggle));
+
         this._summaryItems = [];
         // We keep a list of new summary items that were added to the summary since the last
         // time it was shown to the user. We automatically show the summary to the user if there
@@ -2243,19 +2252,91 @@ const MessageTray = new Lang.Class({
     },
 
     _showTray: function() {
+        // Bail out if we are in the middle of tweening the tray or the
+        // windows.
+        if (this._tweening != 0)
+            return;
+
         this._tween(this.actor, '_trayState', State.SHOWN,
                     { y: -this.actor.height,
                       time: ANIMATION_TIME,
-                      transition: 'easeOutQuad'
+                      transition: 'easeOutQuad',
+                      onComplete:
+                      { apply: Lang.bind(this, function() {
+                            this._tweening--;
+                        })
+                      }
                     });
+        this._tweening++;
+
+        // Don't move the windows up if we are in the overview.
+        if (this._overviewVisible)
+            return;
+
+        let actors = global.get_window_actors();
+        for (let i = 0; i < actors.length; i++) {
+            let window = actors[i].metaWindow;
+            if (!window.is_on_primary_monitor())
+                continue;
+
+            Tweener.addTween(actors[i],
+                             { y: actors[i].y - this.actor.height,
+                               time: ANIMATION_TIME,
+                               transition: 'easeOutQuad',
+                               onComplete: Lang.bind(this, function() {
+                                   let rect = window.get_outer_rect();
+                                   window.move_frame(true, rect.x, rect.y - this.actor.height);
+                                   this._tweening--;
+                               })
+                             });
+            this._windowsShifted++;
+            this._tweening++;
+        }
     },
 
     _hideTray: function() {
+        // Bail out if we are in the middle of tweening the tray or the
+        // windows.
+        if (this._tweening != 0)
+            return;
+
         this._tween(this.actor, '_trayState', State.HIDDEN,
                     { y: 0,
                       time: ANIMATION_TIME,
-                      transition: 'easeOutQuad'
+                      transition: 'easeOutQuad',
+                      onComplete:
+                      { apply: Lang.bind(this, function() {
+                            this._tweening--;
+                        })
+                      }
                     });
+        this._tweening++;
+
+        // Don't move the windows down if had not moved them up. We can't use
+        // this._overviewVisible to check whether we were in the overview
+        // because it gets unset before this method is invoked.
+        if (this._windowsShifted == 0)
+            return;
+
+        let actors = global.get_window_actors();
+        for (let i = 0; i < actors.length; i++) {
+            let window = actors[i].metaWindow;
+            if (!window.is_on_primary_monitor())
+                continue;
+
+            Tweener.addTween(actors[i],
+                             { y: actors[i].y + this.actor.height,
+                               time: ANIMATION_TIME,
+                               transition: 'easeOutQuad',
+                               onComplete: Lang.bind(this, function() {
+                                   let rect = window.get_outer_rect();
+                                   window.move_frame(true, rect.x, rect.y + this.actor.height);
+                                   this._windowsShifted--;
+                                   this._tweening--;
+                               })
+                             });
+            this._tweening++;
+        }
     },
 
     _onIdleMonitorWatch: function(monitor, id, userBecameIdle) {



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