From b3358aeed7690ec385211bd40fb6bdb3f2c48334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 19 Mar 2012 23:40:48 +0100 Subject: [PATCH] dnd: Improve special-handling of St.Button To avoid messing up St.Buttons' internal state with a pointer grab, we wait for the pointer to leave the actor before starting the drag operation manually. This works generally fine, but makes starting a drag operation harder than necessary. To fix, enforce a reasonable button state when starting the drag, rather than special-casing buttons before the drag. https://bugzilla.gnome.org/show_bug.cgi?id=637103 --- js/ui/dnd.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/js/ui/dnd.js b/js/ui/dnd.js index 04149cce8..76a86afc1 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -120,13 +120,7 @@ const _Draggable = new Lang.Class({ return false; this._buttonDown = true; - // special case St.Button: grabbing the pointer would mess up the - // internal state, so we start the drag manually on hover change - if (this.actor instanceof St.Button) - this.actor.connect('notify::hover', - Lang.bind(this, this._onButtonHoverChanged)); - else - this._grabActor(); + this._grabActor(); let [stageX, stageY] = event.get_coords(); this._dragStartX = stageX; @@ -135,15 +129,6 @@ const _Draggable = new Lang.Class({ return false; }, - _onButtonHoverChanged: function(button) { - if (button.hover || !button.pressed) - 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', @@ -232,6 +217,13 @@ const _Draggable = new Lang.Class({ currentDraggable = this; this._dragInProgress = true; + // Special-case St.Button: the pointer grab messes with the internal + // state, so force a reset to a reasonable state here + if (this.actor instanceof St.Button) { + this.actor.fake_release(); + this.actor.hover = false; + } + this.emit('drag-begin', time); if (this._onEventId) this._ungrabActor();