From 1dfffdbc4e5f0e6242cf0ba913cc199e635b1828 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 13 Jun 2011 10:37:10 -0400 Subject: [PATCH] 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 --- js/ui/layout.js | 30 +++++++++++++++++++++++++++++- js/ui/messageTray.js | 24 ++++++++++++------------ 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/js/ui/layout.js b/js/ui/layout.js index 0fd0eb596..37a8bb7bf 100644 --- a/js/ui/layout.js +++ b/js/ui/layout.js @@ -38,8 +38,22 @@ LayoutManager.prototype = { for (let i = 0; i < nMonitors; 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.bottomMonitor = this.monitors[this.bottomIndex]; }, _updateHotCorners: function() { @@ -103,6 +117,20 @@ LayoutManager.prototype = { 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() { let screen = global.screen; let display = screen.get_display(); diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index a1b99bf61..e6be84c6b 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -1293,20 +1293,20 @@ MessageTray.prototype = { }, _setSizePosition: function() { - let primary = Main.layoutManager.primaryMonitor; - this.actor.x = primary.x; - this.actor.y = primary.y + primary.height - 1; - this.actor.width = primary.width; + let monitor = Main.layoutManager.bottomMonitor; + this.actor.x = monitor.x; + this.actor.y = monitor.y + monitor.height - 1; + this.actor.width = monitor.width; this._notificationBin.x = 0; - this._notificationBin.width = primary.width; + this._notificationBin.width = monitor.width; this._summaryBin.x = 0; - this._summaryBin.width = primary.width; + this._summaryBin.width = monitor.width; if (this._pointerBarrier) global.destroy_pointer_barrier(this._pointerBarrier); this._pointerBarrier = - global.create_pointer_barrier(primary.x + primary.width, primary.y + primary.height - this.actor.height, - primary.x + primary.width, primary.y + primary.height, + global.create_pointer_barrier(monitor.x + monitor.width, monitor.y + monitor.height - this.actor.height, + monitor.x + monitor.width, monitor.y + monitor.height, 4 /* BarrierNegativeX */); @@ -1867,18 +1867,18 @@ MessageTray.prototype = { }, _showTray: function() { - let primary = Main.layoutManager.primaryMonitor; + let monitor = Main.layoutManager.bottomMonitor; 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, transition: 'easeOutQuad' }); }, _hideTray: function() { - let primary = Main.layoutManager.primaryMonitor; + let monitor = Main.layoutManager.bottomMonitor; this._tween(this.actor, '_trayState', State.HIDDEN, - { y: primary.y + primary.height - 1, + { y: monitor.y + monitor.height - 1, time: ANIMATION_TIME, transition: 'easeOutQuad' });