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
This commit is contained in:
Alexander Larsson 2011-03-18 14:21:17 +01:00
parent b81ad3ed39
commit 70ae700461

View File

@ -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();
}
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);
}