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