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
This commit is contained in:
parent
a7d4c7d8de
commit
b3358aeed7
24
js/ui/dnd.js
24
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();
|
||||
|
Loading…
Reference in New Issue
Block a user