[gnome-shell] [windowDimmer] handle changing of window_type



commit 61b029207d30b8e4d98228e101162b58df2a9916
Author: Maxim Ermilov <zaspire rambler ru>
Date:   Fri Oct 1 01:09:15 2010 +0400

    [windowDimmer] handle changing of window_type
    
    dim/undim parent window when window_type changed to/from MODAL_DIALOG
    https://bugzilla.gnome.org/show_bug.cgi?id=630363

 js/ui/windowManager.js |   43 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 35 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 9aa9bef..bb8f9aa 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -232,6 +232,22 @@ WindowManager.prototype = {
         return count != 0;
     },
 
+    _markParentWindowAsDimmable: function(actor, animate) {
+        if (Meta.prefs_get_attach_modal_dialogs()) {
+            this._dimmedWindows.push(actor);
+            if (this._shouldAnimate())
+                this._dimParentWindow(actor, animate);
+        }
+    },
+
+    _unmarkParentWindowAsDimmable: function(actor, animate) {
+        if (!Main.overview.visible)
+            this._undimParentWindow(actor, true);
+        this._dimmedWindows = this._dimmedWindows.filter(function(win) {
+            return win != actor;
+        });
+    },
+
     _dimParentWindow: function(actor, animate) {
         let meta = actor.get_meta_window();
         let parent = meta.get_transient_for();
@@ -271,10 +287,22 @@ WindowManager.prototype = {
     },
 
     _mapWindow : function(shellwm, actor) {
+        actor._windowType = actor.meta_window.get_window_type();
+        actor._notifyWindowTypeSignalId = actor.meta_window.connect('notify::window-type', Lang.bind(this, function () {
+            let type = actor.meta_window.get_window_type();
+            if (type == actor._windowType)
+                return;
+            if (type == Meta.WindowType.MODAL_DIALOG)
+                this._markParentWindowAsDimmable(actor, true);
+            else if (actor._windowType == Meta.WindowType.MODAL_DIALOG)
+                this._unmarkParentWindowAsDimmable(actor, true);
+
+            actor._windowType = type;
+        }));
         if (actor.meta_window.get_window_type() == Meta.WindowType.MODAL_DIALOG
             && Meta.prefs_get_attach_modal_dialogs()
             && actor.get_meta_window().get_transient_for()) {
-            this._dimmedWindows.push(actor);
+            this._markParentWindowAsDimmable(actor, true);
             if (this._shouldAnimate()) {
                 actor.set_scale(1.0, 0.0);
                 actor.show();
@@ -291,7 +319,6 @@ WindowManager.prototype = {
                                    onOverwriteScope: this,
                                    onOverwriteParams: [shellwm, actor]
                                  });
-                this._dimParentWindow(actor, true);
                 return;
             }
             shellwm.completed_map(actor);
@@ -335,14 +362,14 @@ WindowManager.prototype = {
     },
 
     _destroyWindow : function(shellwm, actor) {
-        let parent = actor.get_meta_window().get_transient_for();
+        let parent = actor.meta_window.get_transient_for();
+        if (actor._notifyWindowTypeSignalId) {
+            actor.meta_window.disconnect(actor._notifyWindowTypeSignalId);
+            actor._notifyWindowTypeSignalId = 0;
+        }
         while (actor.meta_window.get_window_type() == Meta.WindowType.MODAL_DIALOG
                && parent) {
-            if (!Main.overview.visible)
-                this._undimParentWindow(actor, true);
-            this._dimmedWindows = this._dimmedWindows.filter(function(win) {
-                return win != actor;
-            });
+            this._unmarkParentWindowAsDimmable(actor, true);
             if (!Meta.prefs_get_attach_modal_dialogs()
                 || !this._shouldAnimate())
                 break;



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