[gnome-shell/gnome-3-38] iconGrid/iconGridLayout: Make sure to always update best size



commit b38e3669d55e07e44132b9817a56618ebe27d27e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Nov 30 22:14:17 2020 -0300

    iconGrid/iconGridLayout: Make sure to always update best size
    
    When selecting the best icon size for the available area, we
    iterate from the biggest icon size to the smallest one, and
    stop when finding a size that fits the available area.
    
    However, the 'bestSize' variable is only updated when the
    available area is positive. This is problematic in super bad
    cases like when none of the icon sizes actually fit the availabe
    area, which was hit with a previous iteration of this branch.
    
    Make sure to update the best size while iterating, so that the
    smallest size is selected even in such bad cases.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1510>
    
    (cherry picked from commit 4863c498b29173a7284c60a51b8854b2d2da55e8)

 js/ui/iconGrid.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 72f00e5498..c467d80f74 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -425,10 +425,10 @@ var IconGridLayout = GObject.registerClass({
                 this._pageHeight - usedHeight -  rowSpacingPerPage -
                 this._pagePadding.top - this._pagePadding.bottom;
 
-            if (emptyHSpace >= 0 && emptyVSpace > 0) {
-                bestSize = size;
+            bestSize = size;
+
+            if (emptyHSpace >= 0 && emptyVSpace > 0)
                 break;
-            }
         }
 
         return bestSize;


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