[gnome-shell/gnome-41] workspace: Don't freeze the layout when there's no layout yet



commit d20013318fbf994638dd7e6fde0403ff4bbf7b5e
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Mon Jan 31 21:13:18 2022 +0100

    workspace: Don't freeze the layout when there's no layout yet
    
    On some touchpads/laptops, the swipe gesture to open the overview can be
    performed so fast, that it starts and ends in between two frames. Now
    when this happens, and the gesture ended with too little movement to
    confidently say the user intended to open the overview, we'll close the
    overview again.
    
    While closing the overview, we freeze the layout of the Workspace in
    order to avoid changes to windows messing with the animation. This means
    that in the case described above, we freeze the layout even before the
    first frame of the opening animation happens. No frames being drawn also
    means no allocations happening, and since we create this._layout in
    vfunc_allocate(), this means that on the first allocation cycle of the
    overview we'll see this._layoutFrozen = true, but will also not have
    a this._layout nor this._windowSlots.
    
    This creates an annoying visual glitch where for a split second all
    the windows disappear (overview is visible but no WindowPreviews get
    allocated).
    
    To fix this, force creating a layout on the first allocation cycle, even
    if the layout is currently frozen.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2203>
    (cherry picked from commit ba23279f1fd3820fb81570b1b4a03048e5a7a3bc)

 js/ui/workspace.js | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 1ad403f9f8..afe5a518b6 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -422,6 +422,8 @@ var WorkspaceLayout = GObject.registerClass({
         this._windowSlots = [];
         this._layout = null;
 
+        this._needsLayout = true;
+
         this._stateAdjustment = new St.Adjustment({
             value: 0,
             lower: 0,
@@ -661,9 +663,10 @@ var WorkspaceLayout = GObject.registerClass({
         }
 
         let layoutChanged = false;
-        if (!this._layoutFrozen) {
-            if (this._layout === null) {
+        if (!this._layoutFrozen || this._needsLayout) {
+            if (this._needsLayout) {
                 this._layout = this._createBestLayout(this._workarea);
+                this._needsLayout = false;
                 layoutChanged = true;
             }
 
@@ -785,7 +788,7 @@ var WorkspaceLayout = GObject.registerClass({
         this._windows.set(window, {
             metaWindow,
             sizeChangedId: metaWindow.connect('size-changed', () => {
-                this._layout = null;
+                this._needsLayout = true;
                 this.layout_changed();
             }),
             destroyId: window.connect('destroy', () =>
@@ -805,7 +808,7 @@ var WorkspaceLayout = GObject.registerClass({
         this._syncOverlay(window);
         this._container.add_child(window);
 
-        this._layout = null;
+        this._needsLayout = true;
         this.layout_changed();
     }
 
@@ -840,7 +843,7 @@ var WorkspaceLayout = GObject.registerClass({
         if (window.get_parent() === this._container)
             this._container.remove_child(window);
 
-        this._layout = null;
+        this._needsLayout = true;
         this.layout_changed();
     }
 
@@ -859,7 +862,7 @@ var WorkspaceLayout = GObject.registerClass({
             lastWindow = window;
         }
 
-        this._layout = null;
+        this._needsLayout = true;
         this.layout_changed();
     }
 
@@ -904,7 +907,7 @@ var WorkspaceLayout = GObject.registerClass({
 
         this._spacing = s;
 
-        this._layout = null;
+        this._needsLayout = true;
         this.notify('spacing');
         this.layout_changed();
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]