workspace: Animate window clones using translation properties

Instead of position x/y properties. This reduces CPU-intensive relayouts
in JavaScript (`vfunc_allocate` etc).

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1271
since the other fix required already landed in 4c4846e9.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/936
This commit is contained in:
Daniel van Vugt 2020-01-16 18:42:50 +08:00 committed by Florian Müllner
parent 881eab7669
commit 8929c89d1f

View File

@ -155,8 +155,7 @@ var WindowClone = GObject.registerClass({
this._updateAttachedDialogs();
this._computeBoundingBox();
this.x = this._boundingBox.x;
this.y = this._boundingBox.y;
this.set_translation(this._boundingBox.x, this._boundingBox.y, 0);
this._computeWindowCenter();
@ -1364,8 +1363,8 @@ class Workspace extends St.Widget {
if (!clone.positioned) {
// This window appeared after the overview was already up
// Grow the clone from the center of the slot
clone.x = x + cloneWidth / 2;
clone.y = y + cloneHeight / 2;
clone.translation_x = x + cloneWidth / 2;
clone.translation_y = y + cloneHeight / 2;
clone.scale_x = 0;
clone.scale_y = 0;
clone.positioned = true;
@ -1380,8 +1379,8 @@ class Workspace extends St.Widget {
clone.opacity = 0;
clone.scale_x = 0;
clone.scale_y = 0;
clone.x = x;
clone.y = y;
clone.translation_x = x;
clone.translation_y = y;
}
clone.ease({
@ -1395,7 +1394,7 @@ class Workspace extends St.Widget {
} else {
// cancel any active tweens (otherwise they might override our changes)
clone.remove_all_transitions();
clone.set_position(x, y);
clone.set_translation(x, y, 0);
clone.set_scale(scale, scale);
clone.set_opacity(255);
clone.overlay.relayout(false);
@ -1425,7 +1424,8 @@ class Workspace extends St.Widget {
_animateClone(clone, overlay, x, y, scale) {
clone.ease({
x, y,
translation_x: x,
translation_y: y,
scale_x: scale,
scale_y: scale,
duration: Overview.ANIMATION_TIME,
@ -1570,7 +1570,7 @@ class Workspace extends St.Widget {
clone.slot = [x, y, clone.width * scale, clone.height * scale];
clone.positioned = true;
clone.set_position(x, y);
clone.set_translation(x, y, 0);
clone.set_scale(scale, scale);
clone.overlay.relayout(false);
}
@ -1725,8 +1725,8 @@ class Workspace extends St.Widget {
let [origX, origY] = clone.getOriginalPosition();
clone.scale_x = 1;
clone.scale_y = 1;
clone.x = origX;
clone.y = origY;
clone.translation_x = origX;
clone.translation_y = origY;
clone.ease({
opacity,
duration,
@ -1776,8 +1776,8 @@ class Workspace extends St.Widget {
if (clone.metaWindow.showing_on_its_workspace()) {
let [origX, origY] = clone.getOriginalPosition();
clone.ease({
x: origX,
y: origY,
translation_x: origX,
translation_y: origY,
scale_x: 1,
scale_y: 1,
opacity: 255,