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



commit e12be80a526cb96277d46e39b19cada32ce2171b
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 3f71f58af..83c8dbd52 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -658,6 +658,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);
@@ -666,9 +669,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]