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
This commit is contained in:
Sebastian Keller 2020-07-28 09:02:34 +02:00 committed by Florian Müllner
parent 5dba928154
commit 5fa6996210

View File

@ -1336,6 +1336,10 @@ class FolderView extends BaseAppView {
this._parentView = parentView; this._parentView = parentView;
this._grid._delegate = this; this._grid._delegate = this;
this._relayoutLaterId = 0;
this._oldWidth = null;
this._oldHeight = null;
this._scrollView = new St.ScrollView({ this._scrollView = new St.ScrollView({
overlay_scrollbars: true, overlay_scrollbars: true,
x_expand: true, x_expand: true,
@ -1357,6 +1361,8 @@ class FolderView extends BaseAppView {
action.connect('pan', this._onPan.bind(this)); action.connect('pan', this._onPan.bind(this));
this._scrollView.add_action(action); this._scrollView.add_action(action);
this.connect('destroy', this._onDestroy.bind(this));
this._redisplay(); this._redisplay();
} }
@ -1399,6 +1405,18 @@ class FolderView extends BaseAppView {
return false; 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) { adaptToSize(width, height) {
this._parentAvailableWidth = width; this._parentAvailableWidth = width;
this._parentAvailableHeight = height; this._parentAvailableHeight = height;
@ -1418,6 +1436,16 @@ class FolderView extends BaseAppView {
this._grid.bottomPadding = Math.max(this._grid.bottomPadding, 0); this._grid.bottomPadding = Math.max(this._grid.bottomPadding, 0);
this._grid.leftPadding = Math.max(this._grid.leftPadding, 0); this._grid.leftPadding = Math.max(this._grid.leftPadding, 0);
this._grid.rightPadding = Math.max(this._grid.rightPadding, 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() { _loadApps() {