[gnome-shell] layout: Replace uses of find(Monitor|Index)ForWindow with window.get_monitor()



commit d9b33e01ee918a1f5b5c30faa1da4b08bdead0a8
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Jan 28 14:47:51 2013 -0500

    layout: Replace uses of find(Monitor|Index)ForWindow with window.get_monitor()
    
    Mutter already does the math for us, so we shouldn't have to do it.

 js/ui/layout.js        |   23 +++--------------------
 js/ui/windowManager.js |    9 +++------
 2 files changed, 6 insertions(+), 26 deletions(-)
---
diff --git a/js/ui/layout.js b/js/ui/layout.js
index 0adc81f..d337aec 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -355,7 +355,7 @@ const LayoutManager = new Lang.Class({
         } else {
             let focusWindow = global.display.focus_window;
             if (focusWindow)
-                i = this.findIndexForWindow(focusWindow);
+                i = focusWindow.get_monitor();
         }
 
         return i;
@@ -655,14 +655,6 @@ const LayoutManager = new Lang.Class({
         return -1;
     },
 
-    findIndexForWindow: function(window) {
-        let rect = window.get_input_rect();
-        let i = this._findMonitorForRect(rect.x, rect.y, rect.width, rect.height);
-        if (i >= 0)
-            return i;
-        return this.primaryIndex; // Not on any monitor, pretend its on the primary
-    },
-
     // This call guarantees that we return some monitor to simplify usage of it
     // In practice all tracked actors should be visible on some monitor anyway
     findIndexForActor: function(actor) {
@@ -674,15 +666,6 @@ const LayoutManager = new Lang.Class({
         return this.primaryIndex; // Not on any monitor, pretend its on the primary
     },
 
-    findMonitorForWindow: function(window) {
-        let rect = window.get_input_rect();
-        let i = this._findMonitorForRect(rect.x, rect.y, rect.width, rect.height);
-        if (i >= 0)
-            return this.monitors[i];
-        else
-            return null;
-    },
-
     findMonitorForActor: function(actor) {
         return this.monitors[this.findIndexForActor(actor)];
     },
@@ -733,7 +716,7 @@ const LayoutManager = new Lang.Class({
                 continue;
 
             if (layer == Meta.StackLayer.FULLSCREEN) {
-                let monitor = this.findMonitorForWindow(metaWindow);
+                let monitor = this.monitors[metaWindow.get_monitor()];
                 if (monitor)
                     monitor.inFullscreen = true;
             }
@@ -750,7 +733,7 @@ const LayoutManager = new Lang.Class({
                 }
 
                 // Or whether it is monitor sized
-                let monitor = this.findMonitorForWindow(metaWindow);
+                let monitor = this.monitors[metaWindow.get_monitor()];
                 if (monitor &&
                     window.x <= monitor.x &&
                     window.x + window.width >= monitor.x + monitor.width &&
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index b789d97..1b6ccad 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -253,12 +253,9 @@ const WindowManager = new Lang.Class({
             xScale = geom.width / actor.width;
             yScale = geom.height / actor.height;
         } else {
-            /* scale window down to 0x0.  */
-            let monitor = Main.layoutManager.findMonitorForWindow(actor.meta_window);
-            xDest = monitor.x;
-            yDest = monitor.y;
-            xScale = 0.0;
-            yScale = 0.0;
+            let monitor = Main.layoutManager.monitors[actor.meta_window.get_monitor()];
+            let xDest = monitor.x;
+            let yDest = monitor.y;
             if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
                 xDest += monitor.width;
         }


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