From 04200a428141e5424e620ed8c598f390da2c39ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 27 Mar 2010 02:24:50 +0100 Subject: [PATCH] [dnd] Special-case St.Clickable Currently manual dnd mode is used with St.Clickable to avoid messing up its internal state with a pointer grab. To avoid code duplication, move this special handling into dnd. https://bugzilla.gnome.org/show_bug.cgi?id=610385 --- js/ui/dnd.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/js/ui/dnd.js b/js/ui/dnd.js index 8bf28dff1..213216578 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -2,6 +2,7 @@ const Clutter = imports.gi.Clutter; const Gtk = imports.gi.Gtk; +const St = imports.gi.St; const Lang = imports.lang; const Signals = imports.signals; const Tweener = imports.ui.tweener; @@ -61,13 +62,20 @@ _Draggable.prototype = { }, _onButtonPress : function (actor, event) { - // FIXME: we should make sure it's button 1, but we can't currently - // check that from JavaScript + if (event.get_button() != 1) + return false; + if (Tweener.getTweenCount(actor)) return false; this._buttonDown = true; - this._grabActor(); + // special case St.Clickable: grabbing the pointer would mess up the + // internal state, so we start the drag manually on hover change + if (this.actor instanceof St.Clickable) + this.actor.connect('notify::hover', + Lang.bind(this, this._onClickableHoverChanged)); + else + this._grabActor(); let [stageX, stageY] = event.get_coords(); this._dragStartX = stageX; @@ -76,6 +84,15 @@ _Draggable.prototype = { return false; }, + _onClickableHoverChanged: function(button) { + if (button.hover || !button.held) + return; + + button.fake_release(); + this.startDrag(this._dragStartX, this._dragStartY, + global.get_current_time()); + }, + _grabActor: function() { Clutter.grab_pointer(this.actor); this._onEventId = this.actor.connect('event',