[gnome-shell] workspaceThumbnail: clear the drop placeholder on pointer leave



commit f59018f2d7609eb323a0aacaa5bc819efb4cd03e
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Sun Nov 27 16:23:17 2011 +0100

    workspaceThumbnail: clear the drop placeholder on pointer leave
    
    We add a drag monitor to check whether the pointer is inside
    the workspace selector, and update the visibility of the drop
    placeholder consequently.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=664201

 js/ui/workspaceThumbnail.js |   53 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index 9c00654..b482899 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -528,6 +528,59 @@ const ThumbnailsBox = new Lang.Class({
             this._stateCounts[ThumbnailState[key]] = 0;
 
         this._thumbnails = [];
+
+        Main.overview.connect('item-drag-begin',
+                              Lang.bind(this, this._onDragBegin));
+        Main.overview.connect('item-drag-end',
+                              Lang.bind(this, this._onDragEnd));
+        Main.overview.connect('item-drag-cancelled',
+                              Lang.bind(this, this._onDragCancelled));
+        Main.overview.connect('window-drag-begin',
+                              Lang.bind(this, this._onDragBegin));
+        Main.overview.connect('window-drag-end',
+                              Lang.bind(this, this._onDragEnd));
+        Main.overview.connect('window-drag-cancelled',
+                              Lang.bind(this, this._onDragCancelled));
+    },
+
+    _onDragBegin: function() {
+        this._dragCancelled = false;
+        this._dragMonitor = {
+            dragMotion: Lang.bind(this, this._onDragMotion)
+        };
+        DND.addDragMonitor(this._dragMonitor);
+    },
+
+    _onDragEnd: function() {
+        if (this._dragCancelled)
+            return;
+
+        this._endDrag();
+    },
+
+    _onDragCancelled: function() {
+        this._dragCancelled = true;
+        this._endDrag();
+    },
+
+    _endDrag: function() {
+        this._clearDragPlaceholder();
+        DND.removeDragMonitor(this._dragMonitor);
+    },
+
+    _onDragMotion: function(dragEvent) {
+        if (!this.actor.contains(dragEvent.targetActor))
+            this._onLeave();
+        return DND.DragMotionResult.CONTINUE;
+    },
+
+    _onLeave: function() {
+        this._clearDragPlaceholder();
+    },
+
+    _clearDragPlaceholder: function() {
+        this._dropPlaceholderPos = -1;
+        this.actor.queue_relayout();
     },
 
     // Draggable target interface



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