[gnome-shell/gbsneto/folder-dialog-improvements: 9/18] appDisplay: Redirect DnD to AppDisplay



commit 7c14c76b69d17e9192a2b2e7caf16f2da541ca96
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Jun 4 22:32:14 2020 -0300

    appDisplay: Redirect DnD to AppDisplay
    
    So that we're still able to drag icons out of folders.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1301

 js/ui/appDisplay.js | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index f8ba99570a..7aa2a7519d 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1395,7 +1395,8 @@ var FolderIcon = GObject.registerClass({
         if (this._dialog)
             return;
         if (!this._dialog) {
-            this._dialog = new AppFolderDialog(this, this._folder);
+            this._dialog = new AppFolderDialog(this, this._folder,
+                this._parentView);
             this._parentView.addFolderDialog(this._dialog);
             this._dialog.connect('open-state-changed', (popup, isOpen) => {
                 if (!isOpen)
@@ -1410,7 +1411,7 @@ var AppFolderDialog = GObject.registerClass({
         'open-state-changed': { param_types: [GObject.TYPE_BOOLEAN] },
     },
 }, class AppFolderDialog extends St.Bin {
-    _init(source, folder) {
+    _init(source, folder, appDisplay) {
         super._init({
             visible: false,
             x_expand: true,
@@ -1437,6 +1438,8 @@ var AppFolderDialog = GObject.registerClass({
         this._source = source;
         this._folder = folder;
         this._view = source.view;
+        this._appDisplay = appDisplay;
+        this._delegate = this;
 
         this._isOpen = false;
         this.parentOffset = 0;
@@ -1738,6 +1741,26 @@ var AppFolderDialog = GObject.registerClass({
         return this.navigate_focus(null, direction, false);
     }
 
+    _withinDialog(x, y) {
+        const childAllocation = this.child.allocation;
+        return x > childAllocation.x1 &&
+            x < childAllocation.x2 &&
+            y > childAllocation.y1 &&
+            y < childAllocation.y2;
+    }
+
+    handleDragOver(source, actor, x, y, timestamp) {
+        if (this._withinDialog(x, y))
+            return DND.DragMotionResult.NO_DROP;
+        return this._appDisplay.handleDragOver(source, actor, x, y, timestamp);
+    }
+
+    acceptDrop(source, actor, x, y, timestamp) {
+        if (this._withinDialog(x, y))
+            return false;
+        return this._appDisplay.acceptDrop(source, actor, x, y, timestamp);
+    }
+
     toggle() {
         if (this._isOpen)
             this.popdown();


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