[gnome-shell/gnome-3-36] appDisplay: Schedule relayout after adaptToSize on app folder icon grid



commit 5fa6996210105b525e66ca76af3d1039ece64e43
Author: Sebastian Keller <skeller gnome org>
Date:   Tue Jul 28 09:02:34 2020 +0200

    appDisplay: Schedule relayout after adaptToSize on app folder icon grid
    
    AppFolderDialog was calling adaptToSize from its alloc vfunc, which
    changed the spacing of the icon grid after its size used to calculate
    the adjustment for scrolling had already been determined. This was
    resulting in the app folder not being able to scroll all the way to the
    end the first time it has been opened.
    
    Fix this by scheduling a relayout. This however can not be done
    immediately after the adaptToSize call on the iconGrid, because this is
    called from within an alloc vfunc. So instead use Meta.later_add to
    ensure it gets called after the alloc, but before the next redraw.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2535
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1378

 js/ui/appDisplay.js | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 7654f98a29..1f96a385fa 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1336,6 +1336,10 @@ class FolderView extends BaseAppView {
         this._parentView = parentView;
         this._grid._delegate = this;
 
+        this._relayoutLaterId = 0;
+        this._oldWidth = null;
+        this._oldHeight = null;
+
         this._scrollView = new St.ScrollView({
             overlay_scrollbars: true,
             x_expand: true,
@@ -1357,6 +1361,8 @@ class FolderView extends BaseAppView {
         action.connect('pan', this._onPan.bind(this));
         this._scrollView.add_action(action);
 
+        this.connect('destroy', this._onDestroy.bind(this));
+
         this._redisplay();
     }
 
@@ -1399,6 +1405,18 @@ class FolderView extends BaseAppView {
         return false;
     }
 
+    _onDestroy() {
+        if (this._relayoutLaterId) {
+            Meta.later_remove(this._relayoutLaterId);
+            this._relayoutLaterId = 0;
+        }
+    }
+
+    _relayoutLater() {
+        this._relayoutLaterId = 0;
+        this._grid.queue_relayout();
+    }
+
     adaptToSize(width, height) {
         this._parentAvailableWidth = width;
         this._parentAvailableHeight = height;
@@ -1418,6 +1436,16 @@ class FolderView extends BaseAppView {
         this._grid.bottomPadding = Math.max(this._grid.bottomPadding, 0);
         this._grid.leftPadding = Math.max(this._grid.leftPadding, 0);
         this._grid.rightPadding = Math.max(this._grid.rightPadding, 0);
+
+        if (width !== this._oldWidth || height !== this._oldHeight) {
+            this._oldWidth = width;
+            this._oldHeight = height;
+
+            if (!this._relayoutLaterId) {
+                this._relayoutLaterId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
+                                                       this._relayoutLater.bind(this));
+            }
+        }
     }
 
     _loadApps() {


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