[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
This commit is contained in:
parent
c6f84cfa59
commit
04200a4281
23
js/ui/dnd.js
23
js/ui/dnd.js
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const Clutter = imports.gi.Clutter;
|
const Clutter = imports.gi.Clutter;
|
||||||
const Gtk = imports.gi.Gtk;
|
const Gtk = imports.gi.Gtk;
|
||||||
|
const St = imports.gi.St;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
const Tweener = imports.ui.tweener;
|
const Tweener = imports.ui.tweener;
|
||||||
@ -61,13 +62,20 @@ _Draggable.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onButtonPress : function (actor, event) {
|
_onButtonPress : function (actor, event) {
|
||||||
// FIXME: we should make sure it's button 1, but we can't currently
|
if (event.get_button() != 1)
|
||||||
// check that from JavaScript
|
return false;
|
||||||
|
|
||||||
if (Tweener.getTweenCount(actor))
|
if (Tweener.getTweenCount(actor))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this._buttonDown = true;
|
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();
|
let [stageX, stageY] = event.get_coords();
|
||||||
this._dragStartX = stageX;
|
this._dragStartX = stageX;
|
||||||
@ -76,6 +84,15 @@ _Draggable.prototype = {
|
|||||||
return false;
|
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() {
|
_grabActor: function() {
|
||||||
Clutter.grab_pointer(this.actor);
|
Clutter.grab_pointer(this.actor);
|
||||||
this._onEventId = this.actor.connect('event',
|
this._onEventId = this.actor.connect('event',
|
||||||
|
Loading…
Reference in New Issue
Block a user