layout: deal better with vertically-stacked monitors

If there is a monitor below the primary monitor, then put the message
tray there, rather than necessarily on the primary.

https://bugzilla.gnome.org/show_bug.cgi?id=636963
This commit is contained in:
Dan Winship 2011-06-13 10:37:10 -04:00
parent 64b2b4a7d4
commit 1dfffdbc4e
2 changed files with 41 additions and 13 deletions

View File

@ -38,8 +38,22 @@ LayoutManager.prototype = {
for (let i = 0; i < nMonitors; i++) for (let i = 0; i < nMonitors; i++)
this.monitors.push(screen.get_monitor_geometry(i)); this.monitors.push(screen.get_monitor_geometry(i));
this.primaryIndex = screen.get_primary_monitor(); if (nMonitors == 1) {
this.primaryIndex = this.bottomIndex = 0;
} else {
// If there are monitors below the primary, then we need
// to split primary from bottom.
this.primaryIndex = this.bottomIndex = screen.get_primary_monitor();
for (let i = 0; i < this.monitors.length; i++) {
let monitor = this.monitors[i];
if (this._isAboveOrBelowPrimary(monitor)) {
if (monitor.y > this.monitors[this.bottomIndex].y)
this.bottomIndex = i;
}
}
}
this.primaryMonitor = this.monitors[this.primaryIndex]; this.primaryMonitor = this.monitors[this.primaryIndex];
this.bottomMonitor = this.monitors[this.bottomIndex];
}, },
_updateHotCorners: function() { _updateHotCorners: function() {
@ -103,6 +117,20 @@ LayoutManager.prototype = {
this.emit('monitors-changed'); this.emit('monitors-changed');
}, },
_isAboveOrBelowPrimary: function(monitor) {
let primary = this.monitors[this.primaryIndex];
let monitorLeft = monitor.x, monitorRight = monitor.x + monitor.width;
let primaryLeft = primary.x, primaryRight = primary.x + primary.width;
if ((monitorLeft >= primaryLeft && monitorLeft <= primaryRight) ||
(monitorRight >= primaryLeft && monitorRight <= primaryRight) ||
(primaryLeft >= monitorLeft && primaryLeft <= monitorRight) ||
(primaryRight >= monitorLeft && primaryRight <= monitorRight))
return true;
return false;
},
get focusIndex() { get focusIndex() {
let screen = global.screen; let screen = global.screen;
let display = screen.get_display(); let display = screen.get_display();

View File

@ -1293,20 +1293,20 @@ MessageTray.prototype = {
}, },
_setSizePosition: function() { _setSizePosition: function() {
let primary = Main.layoutManager.primaryMonitor; let monitor = Main.layoutManager.bottomMonitor;
this.actor.x = primary.x; this.actor.x = monitor.x;
this.actor.y = primary.y + primary.height - 1; this.actor.y = monitor.y + monitor.height - 1;
this.actor.width = primary.width; this.actor.width = monitor.width;
this._notificationBin.x = 0; this._notificationBin.x = 0;
this._notificationBin.width = primary.width; this._notificationBin.width = monitor.width;
this._summaryBin.x = 0; this._summaryBin.x = 0;
this._summaryBin.width = primary.width; this._summaryBin.width = monitor.width;
if (this._pointerBarrier) if (this._pointerBarrier)
global.destroy_pointer_barrier(this._pointerBarrier); global.destroy_pointer_barrier(this._pointerBarrier);
this._pointerBarrier = this._pointerBarrier =
global.create_pointer_barrier(primary.x + primary.width, primary.y + primary.height - this.actor.height, global.create_pointer_barrier(monitor.x + monitor.width, monitor.y + monitor.height - this.actor.height,
primary.x + primary.width, primary.y + primary.height, monitor.x + monitor.width, monitor.y + monitor.height,
4 /* BarrierNegativeX */); 4 /* BarrierNegativeX */);
@ -1867,18 +1867,18 @@ MessageTray.prototype = {
}, },
_showTray: function() { _showTray: function() {
let primary = Main.layoutManager.primaryMonitor; let monitor = Main.layoutManager.bottomMonitor;
this._tween(this.actor, '_trayState', State.SHOWN, this._tween(this.actor, '_trayState', State.SHOWN,
{ y: primary.y + primary.height - this.actor.height, { y: monitor.y + monitor.height - this.actor.height,
time: ANIMATION_TIME, time: ANIMATION_TIME,
transition: 'easeOutQuad' transition: 'easeOutQuad'
}); });
}, },
_hideTray: function() { _hideTray: function() {
let primary = Main.layoutManager.primaryMonitor; let monitor = Main.layoutManager.bottomMonitor;
this._tween(this.actor, '_trayState', State.HIDDEN, this._tween(this.actor, '_trayState', State.HIDDEN,
{ y: primary.y + primary.height - 1, { y: monitor.y + monitor.height - 1,
time: ANIMATION_TIME, time: ANIMATION_TIME,
transition: 'easeOutQuad' transition: 'easeOutQuad'
}); });