[gnome-shell] dnd: Update actor position after scaling even when animations are off
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] dnd: Update actor position after scaling even when animations are off
- Date: Thu, 4 Feb 2021 16:44:08 +0000 (UTC)
commit 96d66def8c004d6a052534af1681d25ccd3fd760
Author: Sebastian Keller <skeller gnome org>
Date: Wed Feb 3 01:59:00 2021 +0100
dnd: Update actor position after scaling even when animations are off
The code to update the actor position based on the cursor and current
scale was run in a 'new-frame' handler. This is working fine when
animations are enabled, but when they are turned off this does not work.
This is because the 'new-frame' signal is emitted before the changes for
that frame are applied. So with animations off the position was only
ever updated with the starting values. As a result the shrunk actor was
not being dragged by the position where it was clicked, but by where it
was clicked in the original size, which is likely not even on the shrunk
actor.
This change now also updates the position in the onComplete handler
which gets run with the final scale, even if the duration is 0.
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1699
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1627>
js/ui/dnd.js | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index f6debef584..6f55241078 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -455,20 +455,29 @@ var _Draggable = class _Draggable {
scale_y: scale * origScale,
duration: SCALE_ANIMATION_TIME,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ onComplete: () => {
+ this._updateActorPosition(origScale,
+ origDragOffsetX, origDragOffsetY, transX, transY);
+ },
});
this._dragActor.get_transition('scale-x').connect('new-frame', () => {
- let currentScale = this._dragActor.scale_x / origScale;
- this._dragOffsetX = currentScale * origDragOffsetX - transX;
- this._dragOffsetY = currentScale * origDragOffsetY - transY;
- this._dragActor.set_position(
- this._dragX + this._dragOffsetX,
- this._dragY + this._dragOffsetY);
+ this._updateActorPosition(origScale,
+ origDragOffsetX, origDragOffsetY, transX, transY);
});
}
}
}
+ _updateActorPosition(origScale, origDragOffsetX, origDragOffsetY, transX, transY) {
+ const currentScale = this._dragActor.scale_x / origScale;
+ this._dragOffsetX = currentScale * origDragOffsetX - transX;
+ this._dragOffsetY = currentScale * origDragOffsetY - transY;
+ this._dragActor.set_position(
+ this._dragX + this._dragOffsetX,
+ this._dragY + this._dragOffsetY);
+ }
+
_maybeStartDrag(event) {
let [stageX, stageY] = event.get_coords();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]