ui: Improve handling being headless
Don't assume there will always be a primary (logical) monitor, or any (logical) monitor at all. This includes not allocating / layouting / styling correctly when being headless. The initial background loading will also be delayed until there are any (logical) monitors connected. https://bugzilla.gnome.org/show_bug.cgi?id=730551
This commit is contained in:
@ -129,6 +129,9 @@ var MonitorConstraint = new Lang.Class({
|
||||
if (!this._primary && this._index < 0)
|
||||
return;
|
||||
|
||||
if (!Main.layoutManager.primaryMonitor)
|
||||
return;
|
||||
|
||||
let index;
|
||||
if (this._primary)
|
||||
index = Main.layoutManager.primaryIndex;
|
||||
@ -189,6 +192,7 @@ var LayoutManager = new Lang.Class({
|
||||
this._topActors = [];
|
||||
this._isPopupWindowVisible = false;
|
||||
this._startingUp = true;
|
||||
this._pendingLoadBackground = false;
|
||||
|
||||
// We don't want to paint the stage background color because either
|
||||
// the SystemBackground we create or the MetaBackgroundActor inside
|
||||
@ -323,7 +327,9 @@ var LayoutManager = new Lang.Class({
|
||||
for (let i = 0; i < nMonitors; i++)
|
||||
this.monitors.push(new Monitor(i, screen.get_monitor_geometry(i)));
|
||||
|
||||
if (nMonitors == 1) {
|
||||
if (nMonitors == 0) {
|
||||
this.primaryIndex = this.bottomIndex = -1;
|
||||
} else if (nMonitors == 1) {
|
||||
this.primaryIndex = this.bottomIndex = 0;
|
||||
} else {
|
||||
// If there are monitors below the primary, then we need
|
||||
@ -337,8 +343,15 @@ var LayoutManager = new Lang.Class({
|
||||
}
|
||||
}
|
||||
}
|
||||
this.primaryMonitor = this.monitors[this.primaryIndex];
|
||||
this.bottomMonitor = this.monitors[this.bottomIndex];
|
||||
if (this.primaryIndex != -1) {
|
||||
this.primaryMonitor = this.monitors[this.primaryIndex];
|
||||
this.bottomMonitor = this.monitors[this.bottomIndex];
|
||||
|
||||
if (this._pendingLoadBackground) {
|
||||
this._loadBackground();
|
||||
this._pendingLoadBackground = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_updateHotCorners: function() {
|
||||
@ -458,6 +471,9 @@ var LayoutManager = new Lang.Class({
|
||||
this.screenShieldGroup.set_position(0, 0);
|
||||
this.screenShieldGroup.set_size(global.screen_width, global.screen_height);
|
||||
|
||||
if (!this.primaryMonitor)
|
||||
return;
|
||||
|
||||
this.panelBox.set_position(this.primaryMonitor.x, this.primaryMonitor.y);
|
||||
this.panelBox.set_size(this.primaryMonitor.width, -1);
|
||||
|
||||
@ -480,6 +496,9 @@ var LayoutManager = new Lang.Class({
|
||||
this._rightPanelBarrier = null;
|
||||
}
|
||||
|
||||
if (!this.primaryMonitor)
|
||||
return;
|
||||
|
||||
if (this.panelBox.height) {
|
||||
let primary = this.primaryMonitor;
|
||||
|
||||
@ -549,6 +568,10 @@ var LayoutManager = new Lang.Class({
|
||||
},
|
||||
|
||||
_loadBackground: function() {
|
||||
if (!this.primaryMonitor) {
|
||||
this._pendingLoadBackground = true;
|
||||
return;
|
||||
}
|
||||
this._systemBackground = new Background.SystemBackground();
|
||||
this._systemBackground.actor.hide();
|
||||
|
||||
|
Reference in New Issue
Block a user