[gnome-shell/wip/carlosg/tablet-dnd-on-chrome: 3/4] dnd: Avoid breaking drag state on cancellation



commit 51414054df392d4ef9d09c7b07b6dc4d77071d5f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Sep 10 14:24:57 2018 +0200

    dnd: Avoid breaking drag state on cancellation
    
    In the case where the draggable has an actor of its own, state could be
    left broken when dragging on a place that would not accept the DnD op.
    After button release, drag state is set to "cancelled" and the animation
    begins. After the animation is finished, the drag actor would be destroyed
    before disconnecting from its destroy handler.
    
    Within the destroy handler, the grab would be undone but drag state would
    be left on "cancelled" state for subsequent operations. This results in
    DnD oddities and stuck grabs.
    
    In order to fix this, undo the grab first after the animation finishes, so
    destroying the actor doesn't trigger paths meant to catch cases where
    destruction happens while DnD is ongoing.
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/540

 js/ui/dnd.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index 0b6816dcc..7f9bc65ff 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -657,6 +657,9 @@ var _Draggable = new Lang.Class({
     },
 
     _onAnimationComplete(dragActor, eventTime) {
+        this.emit('drag-end', eventTime, false);
+        this._finishAnimation();
+
         if (this._dragOrigParent) {
             Main.uiGroup.remove_child(this._dragActor);
             this._dragOrigParent.add_actor(this._dragActor);
@@ -665,9 +668,6 @@ var _Draggable = new Lang.Class({
         } else {
             dragActor.destroy();
         }
-
-        this.emit('drag-end', eventTime, false);
-        this._finishAnimation();
     },
 
     _dragComplete() {


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