[gnome-shell/gnome-3-38] iconGrid/iconGrid: Wait for icon sizes before running spring animation
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-38] iconGrid/iconGrid: Wait for icon sizes before running spring animation
- Date: Wed, 2 Dec 2020 23:03:51 +0000 (UTC)
commit f3da1d0fa6c34d5ce325beab93c546ebd73738bf
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Dec 2 17:43:13 2020 -0300
iconGrid/iconGrid: Wait for icon sizes before running spring animation
To run the spring animation, IconGrid uses the transformed position and size
of the icons. This works okay when IconGridLayout doesn't need to update the
icon sizes, but looks bad when IconGridLayout selects a different icon size.
Wait for the icon sizes to be recalculated, and the icons beallocated, before
running the spring animation. If no icon size update is pending, run the spring
animation directly.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1518>
(cherry picked from commit b730875012cabc4cf4ffecb869266b8a76ea64cc)
js/ui/iconGrid.js | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 4d7f4333a8..ee70abee74 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -387,6 +387,9 @@ var IconGridLayout = GObject.registerClass({
this._containerDestroyedId = 0;
this._updateIconSizesLaterId = 0;
+
+ this._resolveOnIdleId = 0;
+ this._iconSizeUpdateResolveCbs = [];
}
_findBestIconSize() {
@@ -697,11 +700,28 @@ var IconGridLayout = GObject.registerClass({
return isRtl ? rowAlign * -1 : rowAlign;
}
+ _runPostAllocation() {
+ if (this._iconSizeUpdateResolveCbs.length > 0 &&
+ this._resolveOnIdleId === 0) {
+ this._resolveOnIdleId = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+ this._iconSizeUpdateResolveCbs.forEach(cb => cb());
+ this._iconSizeUpdateResolveCbs = [];
+ this._resolveOnIdleId = 0;
+ return GLib.SOURCE_REMOVE;
+ });
+ }
+ }
+
_onDestroy() {
if (this._updateIconSizesLaterId >= 0) {
Meta.later_remove(this._updateIconSizesLaterId);
this._updateIconSizesLaterId = 0;
}
+
+ if (this._resolveOnIdleId > 0) {
+ GLib.source_remove(this._resolveOnIdleId);
+ delete this._resolveOnIdleId;
+ }
}
vfunc_set_container(container) {
@@ -812,6 +832,8 @@ var IconGridLayout = GObject.registerClass({
});
this._pageSizeChanged = false;
+
+ this._runPostAllocation();
}
/**
@@ -956,6 +978,14 @@ var IconGridLayout = GObject.registerClass({
return itemData.pageIndex;
}
+ ensureIconSizeUpdated() {
+ if (this._updateIconSizesLaterId === 0)
+ return Promise.resolve();
+
+ return new Promise(
+ resolve => this._iconSizeUpdateResolveCbs.push(resolve));
+ }
+
adaptToSize(pageWidth, pageHeight) {
if (this._pageWidth === pageWidth && this._pageHeight === pageHeight)
return;
@@ -1609,7 +1639,7 @@ var IconGrid = GObject.registerClass({
this.layout_manager.adaptToSize(width, height);
}
- animateSpring(animationDirection, sourceActor) {
+ async animateSpring(animationDirection, sourceActor) {
this._resetAnimationActors();
let actors = this._getChildrenToAnimate();
@@ -1618,6 +1648,8 @@ var IconGrid = GObject.registerClass({
return;
}
+ await this.layout_manager.ensureIconSizeUpdated();
+
let [sourceX, sourceY] = sourceActor.get_transformed_position();
let [sourceWidth, sourceHeight] = sourceActor.get_size();
// Get the center
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]