dnd: fix a case where ungrabEvents wasn't being called
If the drag actor is destroyed as part of a drag target accepting it, we were not calling ungrabEvents, meaning the mouse/keyboard remained grabbed until you clicked somewhere to cancel it. This fixes that without trying to improve the extremely confusing control flow... https://bugzilla.gnome.org/show_bug.cgi?id=635278
This commit is contained in:
parent
b956c6f093
commit
b7c1400eb3
10
js/ui/dnd.js
10
js/ui/dnd.js
@ -100,6 +100,8 @@ _Draggable.prototype = {
|
|||||||
this._buttonDown = false; // The mouse button has been pressed and has not yet been released.
|
this._buttonDown = false; // The mouse button has been pressed and has not yet been released.
|
||||||
this._dragInProgress = false; // The drag has been started, and has not been dropped or cancelled yet.
|
this._dragInProgress = false; // The drag has been started, and has not been dropped or cancelled yet.
|
||||||
this._animationInProgress = false; // The drag is over and the item is in the process of animating to its original position (snapping back or reverting).
|
this._animationInProgress = false; // The drag is over and the item is in the process of animating to its original position (snapping back or reverting).
|
||||||
|
|
||||||
|
this._eventsGrabbed = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
_onButtonPress : function (actor, event) {
|
_onButtonPress : function (actor, event) {
|
||||||
@ -147,13 +149,19 @@ _Draggable.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_grabEvents: function() {
|
_grabEvents: function() {
|
||||||
|
if (!this._eventsGrabbed) {
|
||||||
Clutter.grab_pointer(_getEventHandlerActor());
|
Clutter.grab_pointer(_getEventHandlerActor());
|
||||||
Clutter.grab_keyboard(_getEventHandlerActor());
|
Clutter.grab_keyboard(_getEventHandlerActor());
|
||||||
|
this._eventsGrabbed = true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_ungrabEvents: function() {
|
_ungrabEvents: function() {
|
||||||
|
if (this._eventsGrabbed) {
|
||||||
Clutter.ungrab_pointer();
|
Clutter.ungrab_pointer();
|
||||||
Clutter.ungrab_keyboard();
|
Clutter.ungrab_keyboard();
|
||||||
|
this._eventsGrabbed = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_onEvent: function(actor, event) {
|
_onEvent: function(actor, event) {
|
||||||
@ -476,6 +484,8 @@ _Draggable.prototype = {
|
|||||||
|
|
||||||
if (this._actorDestroyed) {
|
if (this._actorDestroyed) {
|
||||||
global.unset_cursor();
|
global.unset_cursor();
|
||||||
|
if (!this._buttonDown)
|
||||||
|
this._ungrabEvents();
|
||||||
this.emit('drag-end', eventTime, false);
|
this.emit('drag-end', eventTime, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user