[gnome-shell] Only add hot corner for primary and "top left" monitors



commit 70ae7004613e67e8a5f6ac7e87c75dc7ed7ed70e
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Mar 18 14:21:17 2011 +0100

    Only add hot corner for primary and "top left" monitors
    
    To avoid having hot corners that accidentally trigger when e.g. trying
    to hit the panel on the primary monitor we add hot corners only to
    monitors that are "naturally" top left (top right for RTL).
    
    For instance, we'd like a hot corner here:
    
    corner -> +-------------
              |            |
    +---------+            |
    |=========|            |
    |         |            |
    |         |            |
    |         |            |
    +---------+------------+
    
    But not here:
    
              unexpected hot corner
              â??
    +---------+-------+
    |=========|       |
    |         |       |
    |         +-------+
    +---------+
    
    https://bugzilla.gnome.org/show_bug.cgi?id=645116

 js/ui/main.js |   61 ++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 50 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index b558997..47dadef 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -480,28 +480,67 @@ function _getAndClearErrorStack() {
 
 function _relayout() {
     let monitors = global.get_monitors();
-    if (monitors.length != hotCorners.length) {
-        // destroy old corners
-        for (let i = 0; i < hotCorners.length; i++)
-            hotCorners[i].destroy();
-        hotCorners = [];
-        for (let i = 0; i < monitors.length; i++)
-            hotCorners[i] = new Panel.HotCorner();
-    }
+    // destroy old corners
+    for (let i = 0; i < hotCorners.length; i++)
+        hotCorners[i].destroy();
+    hotCorners = [];
 
 
     let primary = global.get_primary_monitor();
     for (let i = 0; i < monitors.length; i++) {
         let monitor = monitors[i];
-        let corner = hotCorners[i];
         let isPrimary = (monitor.x == primary.x &&
                          monitor.y == primary.y &&
                          monitor.width == primary.width &&
                          monitor.height == primary.height);
+
+        let cornerX = monitor.x;
+        let cornerY = monitor.y;
         if (St.Widget.get_default_direction() == St.TextDirection.RTL)
-            corner.actor.set_position(monitor.x + monitor.width, monitor.y);
+            cornerX += monitor.width;
+
+
+        let haveTopLeftCorner = true;
+
+        /* Check if we have a top left (right for RTL) corner.
+         * I.e. if there is no monitor directly above or to the left(right) */
+        let besideX;
+        if (St.Widget.get_default_direction() == St.TextDirection.RTL)
+            besideX = monitor.x + 1;
         else
-            corner.actor.set_position(monitor.x, monitor.y);
+            besideX = cornerX - 1;
+        let besideY = cornerY;
+        let aboveX = cornerX;
+        let aboveY = cornerY - 1;
+
+        for (let j = 0; j < monitors.length; j++) {
+            if (i == j)
+                continue;
+            let otherMonitor = monitors[j];
+            if (besideX >= otherMonitor.x &&
+                besideX < otherMonitor.x + otherMonitor.width &&
+                besideY >= otherMonitor.y &&
+                besideY < otherMonitor.y + otherMonitor.height) {
+                haveTopLeftCorner = false;
+                break;
+            }
+            if (aboveX >= otherMonitor.x &&
+                aboveX < otherMonitor.x + otherMonitor.width &&
+                aboveY >= otherMonitor.y &&
+                aboveY < otherMonitor.y + otherMonitor.height) {
+                haveTopLeftCorner = false;
+                break;
+            }
+        }
+
+        /* We only want hot corners where there is a natural top-left
+         * corner, and on the primary monitor */
+        if (!isPrimary && !haveTopLeftCorner)
+            continue;
+
+        let corner = new Panel.HotCorner();
+        hotCorners.push(corner);
+        corner.actor.set_position(cornerX, cornerY);
         if (isPrimary)
             panel.setHotCorner(corner);
     }



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