[gnome-shell] appDisplay: Mostly remove adaptToSize



commit 083a691a74ab1bcfa5f3f56919789fc8e6c79599
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Jun 8 12:35:30 2022 -0300

    appDisplay: Mostly remove adaptToSize
    
    Back in the day, adaptToSize() contained mad maths to figure out
    icon sizes. Over time, its scope was reduced, to the point where
    we are today where it mostly just redoes some quick maths to
    predict the grid size based on the CSS box model.
    
    Remove adaptToSize() from BaseAppView and child classes. It still
    is an internal detail of the IconGrid class, but it's not exposed
    as a "public" method anymore.
    
    This removal is not perfect, as it doesn't move or compensate for
    any of page indicators and arrows code. This will be done in follow
    up commits introducing a new layout manager for that.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2335>

 js/ui/appDisplay.js | 49 -------------------------------------------------
 js/ui/iconGrid.js   |  9 +++++----
 2 files changed, 5 insertions(+), 53 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 1240caf046..0eebbe9763 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -918,15 +918,6 @@ var BaseAppView = GObject.registerClass({
         this._grid.moveItem(item, newPage, newPosition);
     }
 
-    vfunc_allocate(box) {
-        const width = box.get_width();
-        const height = box.get_height();
-
-        this.adaptToSize(width, height);
-
-        super.vfunc_allocate(box);
-    }
-
     vfunc_map() {
         this._swipeTracker.enabled = true;
         this._connectDnD();
@@ -1011,27 +1002,6 @@ var BaseAppView = GObject.registerClass({
         this._grid.goToPage(pageNumber, animate);
     }
 
-    adaptToSize(width, height) {
-        let box = new Clutter.ActorBox({
-            x2: width,
-            y2: height,
-        });
-        box = this.get_theme_node().get_content_box(box);
-        box = this._scrollView.get_theme_node().get_content_box(box);
-        box = this._grid.get_theme_node().get_content_box(box);
-
-        const availWidth = box.get_width();
-        const availHeight = box.get_height();
-
-        this._grid.adaptToSize(availWidth, availHeight);
-
-        const leftPadding = Math.floor(
-            (availWidth - this._grid.layout_manager.pageWidth) / 2);
-        this._pageIndicatorOffset = leftPadding;
-        this._pageArrowOffset = Math.max(
-            leftPadding - PAGE_PREVIEW_MAX_ARROW_OFFSET, 0);
-    }
-
     _getIndicatorOffset(page, progress, baseOffset) {
         const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
         const translationX =
@@ -1311,14 +1281,6 @@ class AppDisplay extends BaseAppView {
         super._redisplay();
     }
 
-    adaptToSize(width, height) {
-        const [, indicatorHeight] = this._pageIndicators.get_preferred_height(-1);
-        height -= indicatorHeight;
-
-        this._grid.findBestModeForSize(width, height);
-        super.adaptToSize(width, height);
-    }
-
     _savePages() {
         const pages = [];
 
@@ -2013,10 +1975,6 @@ class FolderGrid extends IconGrid.IconGrid {
             page_valign: Clutter.ActorAlign.CENTER,
         });
     }
-
-    adaptToSize(width, height) {
-        this.layout_manager.adaptToSize(width, height);
-    }
 });
 
 var FolderView = GObject.registerClass(
@@ -2149,13 +2107,6 @@ class FolderView extends BaseAppView {
         return false;
     }
 
-    adaptToSize(width, height) {
-        const [, indicatorHeight] = this._pageIndicators.get_preferred_height(-1);
-        height -= indicatorHeight;
-
-        super.adaptToSize(width, height);
-    }
-
     _loadApps() {
         let apps = [];
         let appSys = Shell.AppSystem.get_default();
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 599374fa35..a5f86fc64d 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -1207,6 +1207,11 @@ var IconGrid = GObject.registerClass({
         delete child._iconGridKeyFocusInId;
     }
 
+    vfunc_allocate(box) {
+        this.layout_manager.adaptToSize(...box.get_size());
+        super.vfunc_allocate(box);
+    }
+
     vfunc_style_changed() {
         super.vfunc_style_changed();
 
@@ -1391,10 +1396,6 @@ var IconGrid = GObject.registerClass({
         return this.layout_manager.nPages;
     }
 
-    adaptToSize(width, height) {
-        this.layout_manager.adaptToSize(width, height);
-    }
-
     setGridModes(modes) {
         this._gridModes = modes ? modes : defaultGridModes;
         this.queue_relayout();


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