[gnome-shell-extensions] window-list: Move messageTray patching to the WindowList class



commit 5c2d13ec51a9651834f9c739dae4be6bac70c541
Author: Sylvain Pasche <sylvain pasche gmail com>
Date:   Mon Nov 10 21:37:22 2014 +0100

    window-list: Move messageTray patching to the WindowList class
    
    Move messageTray patching form the Extension object to the WindowList
    class. Moreover, only do the patching if the window list is on the bottom
    monitor. This refactoring will make it easier to have several instances
    of WindowList (one on each monitor).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737486

 extensions/window-list/extension.js |   58 +++++++++++++++++++++--------------
 1 files changed, 35 insertions(+), 23 deletions(-)
---
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
index 718af9d..1de04a4 100644
--- a/extensions/window-list/extension.js
+++ b/extensions/window-list/extension.js
@@ -840,6 +840,24 @@ const WindowList = new Lang.Class({
                 this._updateKeyboardAnchor();
                 this._updateMessageTrayAnchor();
             }));
+
+        this._isOnBottomMonitor = Main.layoutManager.primaryIndex == Main.layoutManager.bottomIndex;
+
+        if (this._isOnBottomMonitor) {
+            let actor = this.actor;
+            this._bottomHoverChangedId =
+                actor.connect('notify::hover', Lang.bind(Main.messageTray,
+                    function() {
+                        this._pointerInNotification = actor.hover;
+                        this._updateState();
+                    }));
+
+            this._notificationParent = Main.messageTray._notificationWidget.get_parent();
+            Main.messageTray._notificationWidget.hide();
+            Main.messageTray._notificationWidget.reparent(this.actor);
+            Main.messageTray._notificationWidget.show();
+        }
+
         this._updateMessageTrayAnchor();
 
         this._fullscreenChangedId =
@@ -975,8 +993,10 @@ const WindowList = new Lang.Class({
     },
 
     _updateMessageTrayAnchor: function() {
-        let sameMonitor = Main.layoutManager.primaryIndex == Main.layoutManager.bottomIndex;
-        let anchorY = this.actor.visible && sameMonitor ? this.actor.height : 0;
+        if (!this._isOnBottomMonitor)
+            return;
+
+        let anchorY = this.actor.visible ? this.actor.height : 0;
 
         Main.messageTray.actor.anchor_y = anchorY;
         Main.messageTray._notificationWidget.anchor_y = -anchorY;
@@ -1157,8 +1177,19 @@ const WindowList = new Lang.Class({
         global.window_manager.disconnect(this._switchWorkspaceId);
         this._switchWorkspaceId = 0;
 
-        Main.messageTray.actor.anchor_y = 0;
-        Main.messageTray._notificationWidget.anchor_y = 0;
+        if (this._bottomHoverChangedId)
+            this.actor.disconnect(this._bottomHoverChangedId);
+        this._bottomHoverChangedId = 0;
+
+        if (this._notificationParent) {
+            Main.messageTray._notificationWidget.reparent(this._notificationParent);
+            this._notificationParent = null;
+        }
+
+        if (this._isOnBottomMonitor) {
+            Main.messageTray.actor.anchor_y = 0;
+            Main.messageTray._notificationWidget.anchor_y = 0;
+        }
 
         Main.overview.disconnect(this._overviewShowingId);
         Main.overview.disconnect(this._overviewHidingId);
@@ -1182,29 +1213,16 @@ const Extension = new Lang.Class({
     _init: function() {
         this._windowList = null;
         this._injections = {};
-        this._notificationParent = null;
     },
 
     enable: function() {
         this._windowList = new WindowList();
-        let windowListActor = this._windowList.actor;
-
-        windowListActor.connect('notify::hover', Lang.bind(Main.messageTray,
-            function() {
-                this._pointerInNotification = windowListActor.hover;
-                this._updateState();
-            }));
 
         this._injections['_trayDwellTimeout'] =
             MessageTray.MessageTray.prototype._trayDwellTimeout;
         MessageTray.MessageTray.prototype._trayDwellTimeout = function() {
             return false;
         };
-
-        this._notificationParent = Main.messageTray._notificationWidget.get_parent();
-        Main.messageTray._notificationWidget.hide();
-        Main.messageTray._notificationWidget.reparent(windowListActor);
-        Main.messageTray._notificationWidget.show();
     },
 
     disable: function() {
@@ -1212,12 +1230,6 @@ const Extension = new Lang.Class({
             return;
 
         this._windowList.actor.hide();
-
-        if (this._notificationParent) {
-            Main.messageTray._notificationWidget.reparent(this._notificationParent);
-            this._notificationParent = null;
-        }
-
         this._windowList.actor.destroy();
         this._windowList = null;
 


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