[gnome-shell/gbsneto/custom-icon-positions: 18/28] appDisplay: Restore dragged item's position on drag cancel



commit d65fd5a3a096e6eb06214a7a8a2c756a6c13069d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Jun 23 10:33:22 2020 -0300

    appDisplay: Restore dragged item's position on drag cancel
    
    Otherwise we end up with the grid in an inconsistent state.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284

 js/ui/appDisplay.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 1853fc108b..cb5f5b7450 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -649,6 +649,7 @@ class AppDisplay extends BaseAppView {
 
         Main.overview.connect('item-drag-begin', this._onDragBegin.bind(this));
         Main.overview.connect('item-drag-end', this._onDragEnd.bind(this));
+        Main.overview.connect('item-drag-cancelled', this._onDragCancelled.bind(this));
 
         this.connect('destroy', this._onDestroy.bind(this));
 
@@ -1079,6 +1080,17 @@ class AppDisplay extends BaseAppView {
         this._removeNudge();
     }
 
+    _onDragCancelled(_overview, source) {
+        const view = _getViewFromIcon(source);
+
+        if (view instanceof FolderView)
+            return;
+
+        // At this point, the positions aren't stored yet, thus _redisplay()
+        // will move all items to their original positions
+        this._redisplay();
+    }
+
     _canAccept(source) {
         return source instanceof AppViewItem;
     }


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