[gnome-shell/gbsneto/icon-grid-dnd: 86/96] appDisplay: Close popup when dragging



commit 155dcf67d22a729a9a5bf9336e56b1d172f2bbdb
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Jul 4 16:03:20 2019 -0300

    appDisplay: Close popup when dragging
    
    When a drag starts inside a folder, and the cursor moves to
    outside it, close the currently opened folder popup.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603

 js/ui/appDisplay.js | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index f15231702..44b4f91e5 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -401,6 +401,7 @@ var AllView = class AllView extends BaseAppView {
         Main.overview.connect('item-drag-end', this._onDragEnd.bind(this));
 
         this._nEventBlockerInhibits = 0;
+        this._popdownId = 0;
     }
 
     _refilterApps() {
@@ -786,6 +787,25 @@ var AllView = class AllView extends BaseAppView {
         }
     }
 
+    _schedulePopdown() {
+        if (this._popdownId > 0)
+            return;
+
+        this._popdownId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, () => {
+            if (this._currentPopup)
+                this._currentPopup.popdown();
+            this._popdownId = 0;
+            return GLib.SOURCE_REMOVE;
+        });
+    }
+
+    _unschedulePopdown() {
+        if (this._popdownId > 0) {
+            GLib.source_remove(this._popdownId);
+            this._popdownId = 0;
+        }
+    }
+
     _onDragBegin() {
         this._dragMonitor = {
             dragMotion: this._onDragMotion.bind(this)
@@ -799,8 +819,10 @@ var AllView = class AllView extends BaseAppView {
         // Handle the drag overshoot. When dragging to above the
         // icon grid, move to the page above; when dragging below,
         // move to the page below.
-        if (appIcon.parentView == this)
+        if (!this._currentPopup)
             this._handleDragOvershoot(dragEvent);
+        else
+            this._unschedulePopdown();
 
         return DND.DragMotionResult.CONTINUE;
     }
@@ -824,8 +846,8 @@ var AllView = class AllView extends BaseAppView {
         let [index, dragLocation] = this.canDropAt(x, y);
 
         this.removeNudges();
-        if (source.parentView != this)
-            source.parentView.removeNudges();
+        if (this._currentPopup)
+            this._schedulePopdown();
 
         if (index != -1) {
             if (sourceIndex == -1 || (index != sourceIndex && index != sourceIndex + 1))


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