From 261497c9581472621320072c4f243bcc33d75726 Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Wed, 10 Jun 2015 16:05:41 +0200 Subject: [PATCH 1/2] AllView: prevent accessing a NULL effect In some cases we might be allocated a size such that this._grid.topPadding and this._grid.bottomPadding are both 0 which means that the ScrollView fade effect gets removed. In that case don't try to access the effect since it will be NULL. https://bugzilla.gnome.org/show_bug.cgi?id=750714 --- js/ui/appDisplay.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index ae40f3e..45e5c71 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -738,7 +738,8 @@ const AllView = new Lang.Class({ let fadeOffset = Math.min(this._grid.topPadding, this._grid.bottomPadding); this._scrollView.update_fade_effect(fadeOffset, 0); - this._scrollView.get_effect('fade').fade_edges = true; + if (fadeOffset > 0) + this._scrollView.get_effect('fade').fade_edges = true; if (this._availWidth != availWidth || this._availHeight != availHeight || oldNPages != this._grid.nPages()) { this._adjustment.value = 0; -- 2.5.0 From 2076a96ee5ad7669e050de035aa10c33af76d810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 16 Jul 2015 15:15:41 +0200 Subject: [PATCH 2/2] layout: Handle the no-monitor case --- js/ui/layout.js | 66 ++++++++++++++++++++++++++++++++------------- js/ui/lookingGlass.js | 4 +++ js/ui/messageTray.js | 6 +++-- js/ui/panel.js | 5 +++- js/ui/workspaceThumbnail.js | 3 ++- 5 files changed, 62 insertions(+), 22 deletions(-) diff --git a/js/ui/layout.js b/js/ui/layout.js index e9aab13..d124705 100644 --- a/js/ui/layout.js +++ b/js/ui/layout.js @@ -106,7 +106,10 @@ const MonitorConstraint = new Lang.Class({ return; let monitor; - if (this._primary) { + if (Main.layoutManager.monitors.length == 0) { + monitor = new Meta.Rectangle({ width: global.screen_width, + height: global.screen_height }); + } else if (this._primary) { monitor = Main.layoutManager.primaryMonitor; } else { let index = Math.min(this._index, Main.layoutManager.monitors.length - 1); @@ -297,7 +300,9 @@ const 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 @@ -311,8 +316,10 @@ const LayoutManager = new Lang.Class({ } } } - this.primaryMonitor = this.monitors[this.primaryIndex]; - this.bottomMonitor = this.monitors[this.bottomIndex]; + this.primaryMonitor = this.primaryIndex > -1 ? this.monitors[this.primaryIndex] + : null; + this.bottomMonitor = this.bottomIndex > -1 ? this.monitors[this.bottomIndex] + : null; }, _updateHotCorners: function() { @@ -423,6 +430,10 @@ const LayoutManager = new Lang.Class({ }, _updateKeyboardBox: function() { + this.keyboardBox.visible = this.keyboardMonitor != null; + if (!this.keyboardBox.visible) + return; + this.keyboardBox.set_position(this.keyboardMonitor.x, this.keyboardMonitor.y + this.keyboardMonitor.height); this.keyboardBox.set_size(this.keyboardMonitor.width, -1); @@ -432,17 +443,27 @@ const LayoutManager = new Lang.Class({ this.screenShieldGroup.set_position(0, 0); this.screenShieldGroup.set_size(global.screen_width, global.screen_height); - this.panelBox.set_position(this.primaryMonitor.x, this.primaryMonitor.y); - this.panelBox.set_size(this.primaryMonitor.width, -1); + if (this.primaryMonitor != null) { + this.panelBox.set_position(this.primaryMonitor.x, this.primaryMonitor.y); + this.panelBox.set_size(this.primaryMonitor.width, -1); + } else { + this.panelBox.set_position(0, 0); + this.panelBox.set_size(global.screen_width, -1); + } if (this.keyboardIndex < 0) this.keyboardIndex = this.primaryIndex; else this._updateKeyboardBox(); - this.trayBox.set_position(this.bottomMonitor.x, - this.bottomMonitor.y + this.bottomMonitor.height); - this.trayBox.set_size(this.bottomMonitor.width, -1); + if (this.bottomMonitor != null) { + this.trayBox.set_position(this.bottomMonitor.x, + this.bottomMonitor.y + this.bottomMonitor.height); + this.trayBox.set_size(this.bottomMonitor.width, -1); + } else { + this.trayBox.set_position(0, global.screen_height); + this.trayBox.set_size(global.screen_width, -1); + } }, _panelBoxChanged: function() { @@ -461,9 +482,8 @@ const LayoutManager = new Lang.Class({ this._rightPanelBarrier = null; } - if (this.panelBox.height) { - let primary = this.primaryMonitor; - + let primary = this.primaryMonitor; + if (this.panelBox.height && primary) { this._rightPanelBarrier = new Meta.Barrier({ display: global.display, x1: primary.x + primary.width, y1: primary.y, x2: primary.x + primary.width, y2: primary.y + this.panelBox.height, @@ -486,14 +506,16 @@ const LayoutManager = new Lang.Class({ }, _updateTrayBarrier: function() { - let monitor = this.bottomMonitor; - if (this._trayBarrier) { this._trayPressure.removeBarrier(this._trayBarrier); this._trayBarrier.destroy(); this._trayBarrier = null; } + let monitor = this.bottomMonitor; + if (!monitor) + return; + this._trayBarrier = new Meta.Barrier({ display: global.display, x1: monitor.x, x2: monitor.x + monitor.width, y1: monitor.y + monitor.height, y2: monitor.y + monitor.height, @@ -544,7 +566,7 @@ const LayoutManager = new Lang.Class({ }, get keyboardMonitor() { - return this.monitors[this.keyboardIndex]; + return this.keyboardIndex > -1 ? this.monitors[this.keyboardIndex] : null; }, get focusIndex() { @@ -558,7 +580,7 @@ const LayoutManager = new Lang.Class({ }, get focusMonitor() { - return this.monitors[this.focusIndex]; + return this.focusIndex > -1 ? this.monitors[this.focusIndex] : null; }, set keyboardIndex(v) { @@ -613,7 +635,7 @@ const LayoutManager = new Lang.Class({ reactive: true }); this.addChrome(this._coverPane); - if (Meta.is_restart()) { + if (Meta.is_restart() || global.screen.get_n_monitors() == 0) { // On restart, we don't do an animation } else if (Main.sessionMode.isGreeter) { this.panelBox.translation_y = -this.panelBox.height; @@ -654,7 +676,7 @@ const LayoutManager = new Lang.Class({ }, _startupAnimation: function() { - if (Meta.is_restart()) + if (Meta.is_restart() || global.screen.get_n_monitors() == 0) this._startupAnimationComplete(); else if (Main.sessionMode.isGreeter) this._startupAnimationGreeter(); @@ -885,6 +907,9 @@ const LayoutManager = new Lang.Class({ global.window_group.visible = windowsVisible; global.top_window_group.visible = windowsVisible; + if (global.screen.get_n_monitors() == 0) + return; + for (let i = 0; i < this._trackedActors.length; i++) { let actorData = this._trackedActors[i], visible; if (!actorData.trackFullscreen) @@ -901,6 +926,9 @@ const LayoutManager = new Lang.Class({ }, getWorkAreaForMonitor: function(monitorIndex) { + if (monitorIndex < 0) + return new Meta.Rectangle(); + // Assume that all workspaces will have the same // struts and pick the first one. let ws = global.screen.get_workspace_by_index(0); @@ -1008,6 +1036,8 @@ const LayoutManager = new Lang.Class({ // we don't create a strut for it at all. let side; let primary = this.primaryMonitor; + if (!primary) + continue; if (x1 <= primary.x && x2 >= primary.x + primary.width) { if (y1 <= primary.y) side = Meta.Side.TOP; diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index eb837d8..d5e3353 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -538,6 +538,8 @@ const Inspector = new Lang.Class({ return; let primary = Main.layoutManager.primaryMonitor; + if (!primary) + return; let [minWidth, minHeight, natWidth, natHeight] = this._eventHandler.get_preferred_size(); @@ -1036,6 +1038,8 @@ const LookingGlass = new Lang.Class({ _resize: function() { let primary = Main.layoutManager.primaryMonitor; + if (!primary) + return; let myWidth = primary.width * 0.7; let availableHeight = primary.height - Main.layoutManager.keyboardBox.height; let myHeight = Math.min(primary.height * 0.7, availableHeight * 0.9); diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index f1ce7f2..0be69bc 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -1995,7 +1995,8 @@ const MessageTray = new Lang.Class({ _checkTrayDwell: function(x, y) { let monitor = Main.layoutManager.bottomMonitor; - let shouldDwell = (x >= monitor.x && x <= monitor.x + monitor.width && + let shouldDwell = monitor && + (x >= monitor.x && x <= monitor.x + monitor.width && y == monitor.y + monitor.height - 1); if (shouldDwell) { // We only set up dwell timeout when the user is not hovering over the tray @@ -2434,7 +2435,8 @@ const MessageTray = new Lang.Class({ let shouldShowNotification = (hasNotifications && this._trayState == State.HIDDEN && !this._traySummoned); let nextNotification = this._notificationQueue[0] || null; if (shouldShowNotification && nextNotification) { - let limited = this._busy || Main.layoutManager.bottomMonitor.inFullscreen; + let bottomMonitor = Main.layoutManager.bottomMonitor; + let limited = this._busy || (bottomMonitor && bottomMonitor.inFullscreen); let showNextNotification = (!limited || nextNotification.forFeedback || nextNotification.urgency == Urgency.CRITICAL); if (showNextNotification) { let len = this._notificationQueue.length; diff --git a/js/ui/panel.js b/js/ui/panel.js index dd04601..fedc7cc 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -931,7 +931,10 @@ const Panel = new Lang.Class({ _getPreferredWidth: function(actor, forHeight, alloc) { alloc.min_size = -1; - alloc.natural_size = Main.layoutManager.primaryMonitor.width; + if (Main.layoutManager.primaryMonitor) + alloc.natural_size = Main.layoutManager.primaryMonitor.width; + else + alloc.natural_size = 0; }, _getPreferredHeight: function(actor, forWidth, alloc) { diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js index 3adc327..bb1c8fe 100644 --- a/js/ui/workspaceThumbnail.js +++ b/js/ui/workspaceThumbnail.js @@ -264,7 +264,8 @@ const WorkspaceThumbnail = new Lang.Class({ this._createBackground(); let monitor = Main.layoutManager.primaryMonitor; - this.setPorthole(monitor.x, monitor.y, monitor.width, monitor.height); + if (monitor) + this.setPorthole(monitor.x, monitor.y, monitor.width, monitor.height); let windows = global.get_window_actors().filter(Lang.bind(this, function(actor) { let win = actor.meta_window; -- 2.5.0