[gnome-shell/gbsneto/custom-icon-positions: 2/28] appDisplay: Ignore dragging over leeways



commit 8451f3bb207d55b64bc65e0ae89da67d427686aa
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon May 25 16:00:23 2020 -0300

    appDisplay: Ignore dragging over leeways
    
    The leeways are parts of the icon that ignore incoming drag
    events. This is how IconGrid and IconGridLayout treat it, and
    this is how the icons should treat themselves too.
    
    Make AppIcon ignore dragging over the left and right leeways.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284

 js/ui/appDisplay.js | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index db049ac1fb..dc210e9c9b 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -2175,24 +2175,37 @@ var AppIcon = GObject.registerClass({
         return DND.DragMotionResult.CONTINUE;
     }
 
-    handleDragOver(source) {
+    _withinLeeways(x) {
+        return x < IconGrid.LEFT_DIVIDER_LEEWAY ||
+            x > this.width - IconGrid.RIGHT_DIVIDER_LEEWAY;
+    }
+
+    handleDragOver(source, _actor, x) {
         if (source == this)
             return DND.DragMotionResult.NO_DROP;
 
         if (!this._canAccept(source))
             return DND.DragMotionResult.CONTINUE;
 
+        if (this._withinLeeways(x)) {
+            this._setHoveringByDnd(false);
+            return DND.DragMotionResult.CONTINUE;
+        }
+
         this._setHoveringByDnd(true);
 
         return DND.DragMotionResult.MOVE_DROP;
     }
 
-    acceptDrop(source) {
+    acceptDrop(source, _actor, x) {
         this._setHoveringByDnd(false);
 
         if (!this._canAccept(source))
             return false;
 
+        if (this._withinLeeways(x))
+            return false;
+
         let view = _getViewFromIcon(this);
         let apps = [this.id, source.id];
 


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