Blame SOURCES/more-spurious-allocation-warnings.patch

5731ec
From 4926a9b8f958617d67d603622b1382c17fe4037c Mon Sep 17 00:00:00 2001
5731ec
From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl>
5731ec
Date: Wed, 20 May 2020 12:05:04 +0200
5731ec
Subject: [PATCH 1/2] workspacesView: Avoid setting invalid geometries on views
5731ec
5731ec
The fullGeometry and the actualGeometry of the WorkspacesDisplay are set
5731ec
from the allocation of the overviews ControlsManager and the
5731ec
WorkspacesDisplay, that means they're only valid after those actors got
5731ec
their allocations during Clutters allocation cycle.
5731ec
5731ec
Since WorkspacesDisplay._updateWorkspacesViews() is already called while
5731ec
showing/mapping the WorkspacesDisplay, that allocation cycle didn't
5731ec
happen yet and we end up either setting the geometries of the views to
5731ec
null (in case of the fullGeometry) or to something wrong (a 0-sized
5731ec
allocation in case of the actualGeometry).
5731ec
5731ec
So avoid setting invalid geometries on the views by initializing both
5731ec
the fullGeometry and the actualGeometry to null, and then only updating
5731ec
the geometries of the views after they're set to a correct value.
5731ec
5731ec
Note that this means we won't correctly animate the overview the first
5731ec
time we open it since the animation depends on the geometries being set,
5731ec
but is being started from show(), which means no allocations have
5731ec
happened yet. In practice this introduces no regression though since
5731ec
before this change we simply used incorrect geometries (see the 0-sized
5731ec
allocation mentioned above) on the initial opening and the animation
5731ec
didn't work either.
5731ec
5731ec
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1119
5731ec
---
5731ec
 js/ui/workspacesView.js | 28 +++++++++++++++++-----------
5731ec
 1 file changed, 17 insertions(+), 11 deletions(-)
5731ec
5731ec
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
5731ec
index e302296a6..02baddc6e 100644
5731ec
--- a/js/ui/workspacesView.js
5731ec
+++ b/js/ui/workspacesView.js
5731ec
@@ -521,6 +521,7 @@ var WorkspacesDisplay = class {
5731ec
         this._scrollEventId = 0;
5731ec
         this._keyPressEventId = 0;
5731ec
 
5731ec
+        this._actualGeometry = null;
5731ec
         this._fullGeometry = null;
5731ec
     }
5731ec
 
5731ec
@@ -675,8 +676,10 @@ var WorkspacesDisplay = class {
5731ec
 
5731ec
         this._workspacesViews.forEach(v => v.actor.show());
5731ec
 
5731ec
-        this._updateWorkspacesFullGeometry();
5731ec
-        this._updateWorkspacesActualGeometry();
5731ec
+        if (this._fullGeometry)
5731ec
+            this._syncWorkspacesFullGeometry();
5731ec
+        if (this._actualGeometry)
5731ec
+            this._syncWorkspacesActualGeometry();
5731ec
     }
5731ec
 
5731ec
     _scrollValueChanged() {
5731ec
@@ -739,10 +742,10 @@ var WorkspacesDisplay = class {
5731ec
     // the sliding controls were never slid in at all.
5731ec
     setWorkspacesFullGeometry(geom) {
5731ec
         this._fullGeometry = geom;
5731ec
-        this._updateWorkspacesFullGeometry();
5731ec
+        this._syncWorkspacesFullGeometry();
5731ec
     }
5731ec
 
5731ec
-    _updateWorkspacesFullGeometry() {
5731ec
+    _syncWorkspacesFullGeometry() {
5731ec
         if (!this._workspacesViews.length)
5731ec
             return;
5731ec
 
5731ec
@@ -754,18 +757,21 @@ var WorkspacesDisplay = class {
5731ec
     }
5731ec
 
5731ec
     _updateWorkspacesActualGeometry() {
5731ec
+        const [x, y] = this.actor.get_transformed_position();
5731ec
+        const width = this.actor.allocation.get_width();
5731ec
+        const height = this.actor.allocation.get_height();
5731ec
+
5731ec
+        this._actualGeometry = { x, y, width, height };
5731ec
+        this._syncWorkspacesActualGeometry();
5731ec
+    }
5731ec
+
5731ec
+    _syncWorkspacesActualGeometry() {
5731ec
         if (!this._workspacesViews.length)
5731ec
             return;
5731ec
 
5731ec
-        let [x, y] = this.actor.get_transformed_position();
5731ec
-        let allocation = this.actor.allocation;
5731ec
-        let width = allocation.x2 - allocation.x1;
5731ec
-        let height = allocation.y2 - allocation.y1;
5731ec
-        let primaryGeometry = { x: x, y: y, width: width, height: height };
5731ec
-
5731ec
         let monitors = Main.layoutManager.monitors;
5731ec
         for (let i = 0; i < monitors.length; i++) {
5731ec
-            let geometry = (i == this._primaryIndex) ? primaryGeometry : monitors[i];
5731ec
+            let geometry = i === this._primaryIndex ? this._actualGeometry : monitors[i];
5731ec
             this._workspacesViews[i].setActualGeometry(geometry);
5731ec
         }
5731ec
     }
5731ec
-- 
5731ec
2.26.2
5731ec
5731ec
5731ec
From 4671eebccf4e6afce8c0a869d63095b39aa7e163 Mon Sep 17 00:00:00 2001
5731ec
From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl>
5731ec
Date: Wed, 20 May 2020 13:39:11 +0200
5731ec
Subject: [PATCH 2/2] workspacesView: Only animate on show() when geometries
5731ec
 are already set
5731ec
5731ec
Animating the window clones of the overview requires the fullGeometry
5731ec
and the actualGeometry to be set, which they won't be when showing the
5731ec
overview for the first time. So don't even try to animate the window
5731ec
clones in that case because the geometries will still be null and
5731ec
accessing them in workspace.js will throw errors.
5731ec
5731ec
The workspace views will still get the correct layout as soon as the
5731ec
allocations happen because syncing the geometries will trigger updating
5731ec
the window positions. Since animations are disabled for position changes
5731ec
when syncing the geometry though, we won't get an animation and the
5731ec
clones will jump into place. That's not a regression though since before
5731ec
this change we also didn't animate in that case because the geometries
5731ec
used were simply wrong (the actualGeometry was 0-sized as explained in
5731ec
the last commit).
5731ec
5731ec
If we wanted to fix the initial animation of the overview, we'd have to
5731ec
always enable animations of the window clones when syncing geometries,
5731ec
but that would break the animation of the workspace when hovering the
5731ec
workspaceThumbnail slider, because right now those animations are "glued
5731ec
together" using the actualGeometry, so they would get out of sync.
5731ec
5731ec
The reason there are no errors happening in workspace.js with the
5731ec
existing code is that due to a bug in Clutter the fullGeometry of
5731ec
WorkspacesDisplay gets set very early while mapping the WorkspacesViews
5731ec
(because the overviews ControlsManager gets an allocation during the
5731ec
resource scale calculation of a ClutterClone, see
5731ec
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1181), so it
5731ec
won't be set to null anymore when calling
5731ec
WorkspacesView.animateToOverview().
5731ec
5731ec
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1119
5731ec
---
5731ec
 js/ui/workspacesView.js | 17 ++++++++++-------
5731ec
 1 file changed, 10 insertions(+), 7 deletions(-)
5731ec
5731ec
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
5731ec
index 02baddc6e..3e9d77655 100644
5731ec
--- a/js/ui/workspacesView.js
5731ec
+++ b/js/ui/workspacesView.js
5731ec
@@ -589,13 +589,16 @@ var WorkspacesDisplay = class {
5731ec
 
5731ec
     show(fadeOnPrimary) {
5731ec
         this._updateWorkspacesViews();
5731ec
-        for (let i = 0; i < this._workspacesViews.length; i++) {
5731ec
-            let animationType;
5731ec
-            if (fadeOnPrimary && i == this._primaryIndex)
5731ec
-                animationType = AnimationType.FADE;
5731ec
-            else
5731ec
-                animationType = AnimationType.ZOOM;
5731ec
-            this._workspacesViews[i].animateToOverview(animationType);
5731ec
+
5731ec
+        if (this._actualGeometry && this._fullGeometry) {
5731ec
+            for (let i = 0; i < this._workspacesViews.length; i++) {
5731ec
+                let animationType;
5731ec
+                if (fadeOnPrimary && i == this._primaryIndex)
5731ec
+                    animationType = AnimationType.FADE;
5731ec
+                else
5731ec
+                    animationType = AnimationType.ZOOM;
5731ec
+                this._workspacesViews[i].animateToOverview(animationType);
5731ec
+            }
5731ec
         }
5731ec
 
5731ec
         this._restackedNotifyId =
5731ec
-- 
5731ec
2.26.2
5731ec