[gnome-shell] dnd: Make DND translation-property-aware



commit 881eab766959af1dcf1b73119dd478b891957cdb
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Wed Jan 22 16:40:50 2020 +0800

    dnd: Make DND translation-property-aware
    
    Previously DND only worked properly for actors with zero translation.
    But it only requires a small tweak to `this._dragOffsetX/Y` to support
    non-zero translation values.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/936

 js/ui/dnd.js | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index cc2f360b5f..cb72737f1c 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -411,14 +411,18 @@ var _Draggable = class _Draggable {
         this._snapBackY = this._dragStartY + this._dragOffsetY;
         this._snapBackScale = this._dragActor.scale_x;
 
+        let origDragOffsetX = this._dragOffsetX;
+        let origDragOffsetY = this._dragOffsetY;
+        let [transX, transY] = this._dragActor.get_translation();
+        this._dragOffsetX -= transX;
+        this._dragOffsetY -= transY;
+
         if (this._dragActorMaxSize != undefined) {
             let [scaledWidth, scaledHeight] = this._dragActor.get_transformed_size();
             let currentSize = Math.max(scaledWidth, scaledHeight);
             if (currentSize > this._dragActorMaxSize) {
                 let scale = this._dragActorMaxSize / currentSize;
                 let origScale =  this._dragActor.scale_x;
-                let origDragOffsetX = this._dragOffsetX;
-                let origDragOffsetY = this._dragOffsetY;
 
                 // The position of the actor changes as we scale
                 // around the drag position, but we can't just tween
@@ -435,8 +439,8 @@ var _Draggable = class _Draggable {
 
                 this._dragActor.get_transition('scale-x').connect('new-frame', () => {
                     let currentScale = this._dragActor.scale_x / origScale;
-                    this._dragOffsetX = currentScale * origDragOffsetX;
-                    this._dragOffsetY = currentScale * origDragOffsetY;
+                    this._dragOffsetX = currentScale * origDragOffsetX - transX;
+                    this._dragOffsetY = currentScale * origDragOffsetY - transY;
                     this._dragActor.set_position(
                         this._dragX + this._dragOffsetX,
                         this._dragY + this._dragOffsetY);


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