[gnome-shell/wip/paging] Fixed bad relayout of the grid when we change resolution and the number of pages remain the same, bu



commit e75932bf28a8fe8f159158d13cdc575c0eb88ef2
Author: Carlos Soriano <carlos soriano89 gmail com>
Date:   Wed Jul 24 14:50:28 2013 +0200

    Fixed bad relayout of the grid when we change resolution and the number
    of pages remain the same, but not the height of the page, which causes
    that if we not take that case into account, grid allocate fine, but the
    parent of the grid doesn't give it the needed heigth (and the view is
    bad displayed in the last page)
    Also always start at 0 when opening overview

 js/ui/appDisplay.js |   25 ++++++++++++++++---------
 js/ui/iconGrid.js   |    6 +++++-
 2 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index bcf7989..9477da9 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -443,9 +443,14 @@ const PaginationScrollView = new Lang.Class({
         
         this._verticalAdjustment.page_size = availHeight;
         this._verticalAdjustment.upper = this._stack.height;
-        
-        if(this.invalidatePagination)
-            this.goToPage(0);
+        if(this.invalidatePagination) {
+            // we can modify our adjustment, so we do that to show the first page, but we can't modify the 
indicators,
+            // so we modify it before redraw (we won't see too much flickering at all)
+            if(this._pages.nPages() > 1) {
+                this.goToPage(0);
+                Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() 
{this._parent.goToPage(0);}));
+            }
+        }
         this.invalidatePagination = false;
     },
 
@@ -678,7 +683,6 @@ const PaginationIndicator = new Lang.Class({
         let [minWidth, natWidth] = children[0].get_preferred_width(natHeight);
         let widthPerChild = natWidth + this._spacing * 2;
         let firstPosition = [this._spacing, availHeight / 2 - totalUsedHeight / 2];
-        global.log(" Indicator availL HEIGHT " + availHeight);
         for(let i = 0; i < this._nPages; i++) {
             let childBox = new Clutter.ActorBox();
             childBox.x1 = 0;
@@ -703,10 +707,10 @@ const AllView = new Lang.Class({
    
     _init: function() {
         let paginationScrollViewParams = {style_class: 'all-apps'};
-        this._paginationView = new PaginationScrollView(this, paginationScrollViewParams);
-
         this._paginationIndicator = new PaginationIndicator({style_class: 'pages-indicator'});
         this._paginationIndicator._nPages = 0;
+        this._paginationView = new PaginationScrollView(this, paginationScrollViewParams);
+
         let layout = new Clutter.BinLayout();
         this.actor = new St.Widget({ layout_manager: layout, 
                                      x_expand:true, y_expand:true });
@@ -725,12 +729,13 @@ const AllView = new Lang.Class({
         }
 
         this._paginationView._pages._grid.connect('n-pages-changed', Lang.bind(this, this._updatedNPages));
+        // Always start at page 0 when we enter and wuit overview
+        Main.overview.connect('shown', Lang.bind(this, function() {this.goToPage(0);}));
     },
     
     _updatedNPages: function(iconGrid, nPages) {
         // We don't need a relayout because we already done it at iconGrid
         // when pages are calculated (and then the signal is emitted before that)");
-        global.log("Update n pages " + nPages);
         this._paginationIndicator._nPages = nPages;
         this._paginationView.invalidatePagination = true;
     },
@@ -764,10 +769,12 @@ const AllView = new Lang.Class({
     },
     
     goToPage: function(index, action) {
+        if(!this._paginationView.nPages())
+            return;
         // Since it can happens after a relayout, we have to ensure that all is unchecked
         let indicators = this._paginationIndicator.actor.get_children();
-        for(let index in indicators)
-            indicators[index].set_checked(false);
+        for(let i in indicators)
+            indicators[i].set_checked(false);
         this._paginationView.goToPage(index, action);
         
this._paginationIndicator.actor.get_child_at_index(this._paginationView.currentPage()).set_checked(true);
     },
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index e2977a5..2148ff8 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -309,9 +309,13 @@ const IconGrid = new Lang.Class({
                 nRows = 0;
             if (this._rowLimit)
                 nRows = Math.min(nRows, this._rowLimit);
+            let oldHeightUsedPerPage = this.usedHeightPerPage();
             let oldNPages = this._nPages;
             this._calculatePaginationValues(availHeightPerPage, nColumns, nRows);
-            if(oldNPages != this._nPages) {
+            // Take into account when the number of pages changed (then the height of the entire grid 
changed for sure)
+            // and also when the spacing is changed, sure the hegiht per page changed and the entire grid 
height changes, althougt
+            // maybe the number of pages doesn't change
+            if(oldNPages != this._nPages || oldHeightUsedPerPage != this.usedHeightPerPage()) {
                 this.emit('n-pages-changed', this._nPages);
                 Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
                     global.log("Put a relayout " + this._nPages);


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