[gnome-shell] layout: Use the mutter functions for doing monitor math



commit 60985b396ae6f993d09ebb7e6f4657b1d9b41402
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Jan 27 23:41:30 2013 -0500

    layout: Use the mutter functions for doing monitor math
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692680

 js/ui/layout.js |   27 ++-------------------------
 1 files changed, 2 insertions(+), 25 deletions(-)
---
diff --git a/js/ui/layout.js b/js/ui/layout.js
index d337aec..a3a32eb 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -634,36 +634,13 @@ const LayoutManager = new Lang.Class({
         }
     },
 
-    _findMonitorForRect: function(x, y, w, h) {
-        // First look at what monitor the center of the rectangle is at
-        let cx = x + w/2;
-        let cy = y + h/2;
-        for (let i = 0; i < this.monitors.length; i++) {
-            let monitor = this.monitors[i];
-            if (cx >= monitor.x && cx < monitor.x + monitor.width &&
-                cy >= monitor.y && cy < monitor.y + monitor.height)
-                return i;
-        }
-        // If the center is not on a monitor, return the first overlapping monitor
-        for (let i = 0; i < this.monitors.length; i++) {
-            let monitor = this.monitors[i];
-            if (x + w > monitor.x && x < monitor.x + monitor.width &&
-                y + h > monitor.y && y < monitor.y + monitor.height)
-                return i;
-        }
-        // otherwise on no monitor
-        return -1;
-    },
-
     // 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) {
         let [x, y] = actor.get_transformed_position();
         let [w, h] = actor.get_transformed_size();
-        let i = this._findMonitorForRect(x, y, w, h);
-        if (i >= 0)
-            return i;
-        return this.primaryIndex; // Not on any monitor, pretend its on the primary
+        let rect = new Meta.Rectangle({ x: x, y: y, width: w, height: h });
+        return global.screen.get_monitor_index_for_rect(rect);
     },
 
     findMonitorForActor: function(actor) {


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