layout: Ensure that the hotCorners array is always indexable by monitor number

messageTray relies on indexing the hot corners array by monitor number,
so we should make this a guarantee.

https://bugzilla.gnome.org/show_bug.cgi?id=698513
This commit is contained in:
Jasper St. Pierre 2013-03-19 15:50:16 -04:00
parent fdae613b14
commit 64ecfa49eb

View File

@ -283,8 +283,10 @@ const LayoutManager = new Lang.Class({
_updateHotCorners: function() { _updateHotCorners: function() {
// destroy old hot corners // destroy old hot corners
for (let i = 0; i < this.hotCorners.length; i++) this.hotCorners.forEach(function(corner) {
this.hotCorners[i].destroy(); if (corner)
corner.destroy();
});
this.hotCorners = []; this.hotCorners = [];
let size = this.panelBox.height; let size = this.panelBox.height;
@ -295,9 +297,9 @@ const LayoutManager = new Lang.Class({
let cornerX = this._rtl ? monitor.x + monitor.width : monitor.x; let cornerX = this._rtl ? monitor.x + monitor.width : monitor.x;
let cornerY = monitor.y; let cornerY = monitor.y;
if (i != this.primaryIndex) { let haveTopLeftCorner = true;
let haveTopLeftCorner = true;
if (i != this.primaryIndex) {
// Check if we have a top left (right for RTL) corner. // 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) // I.e. if there is no monitor directly above or to the left(right)
let besideX = this._rtl ? monitor.x + 1 : cornerX - 1; let besideX = this._rtl ? monitor.x + 1 : cornerX - 1;
@ -324,14 +326,15 @@ const LayoutManager = new Lang.Class({
break; break;
} }
} }
if (!haveTopLeftCorner)
continue;
} }
let corner = new HotCorner(this, monitor, cornerX, cornerY); if (haveTopLeftCorner) {
corner.setBarrierSize(size); let corner = new HotCorner(this, monitor, cornerX, cornerY);
this.hotCorners.push(corner); corner.setBarrierSize(size);
this.hotCorners.push(corner);
} else {
this.hotCorners.push(null);
}
} }
this.emit('hot-corners-changed'); this.emit('hot-corners-changed');
@ -408,7 +411,8 @@ const LayoutManager = new Lang.Class({
let size = this.panelBox.height; let size = this.panelBox.height;
this.hotCorners.forEach(function(corner) { this.hotCorners.forEach(function(corner) {
corner.setBarrierSize(size); if (corner)
corner.setBarrierSize(size);
}); });
}, },