overview: Protect ::drag-end handlers

These end up emitting item-drag-end/window-drag-end pretty much
without checks. Given the MetaDnd object may end up emitting
::drag-leave as a result of the plugin ending its grab, this
would result on spurious emission of those events and subsequent
warnings.

For extra paranoia, the _inDrag variable has been split into
_inItemDrag/_inWindowDrag so we can't cross the streams.

https://bugzilla.gnome.org/show_bug.cgi?id=784545
This commit is contained in:
Carlos Garnacho 2017-11-16 17:27:12 +01:00
parent c53557b4c6
commit cdc212ff6e

View File

@ -417,7 +417,7 @@ var Overview = new Lang.Class({
beginItemDrag: function(source) { beginItemDrag: function(source) {
this.emit('item-drag-begin'); this.emit('item-drag-begin');
this._inDrag = true; this._inItemDrag = true;
}, },
cancelledItemDrag: function(source) { cancelledItemDrag: function(source) {
@ -425,13 +425,15 @@ var Overview = new Lang.Class({
}, },
endItemDrag: function(source) { endItemDrag: function(source) {
if (!this._inItemDrag)
return;
this.emit('item-drag-end'); this.emit('item-drag-end');
this._inDrag = false; this._inItemDrag = false;
}, },
beginWindowDrag: function(window) { beginWindowDrag: function(window) {
this.emit('window-drag-begin', window); this.emit('window-drag-begin', window);
this._inDrag = true; this._inWindowDrag = true;
}, },
cancelledWindowDrag: function(window) { cancelledWindowDrag: function(window) {
@ -439,8 +441,10 @@ var Overview = new Lang.Class({
}, },
endWindowDrag: function(window) { endWindowDrag: function(window) {
if (!this._inWindowDrag)
return;
this.emit('window-drag-end', window); this.emit('window-drag-end', window);
this._inDrag = false; this._inWindowDrag = false;
}, },
focusSearch: function() { focusSearch: function() {
@ -484,7 +488,7 @@ var Overview = new Lang.Class({
shouldToggleByCornerOrButton: function() { shouldToggleByCornerOrButton: function() {
if (this.animationInProgress) if (this.animationInProgress)
return false; return false;
if (this._inDrag) if (this._inItemDrag || this._inWindowDrag)
return false; return false;
if (this._activationTime == 0 || Date.now() / 1000 - this._activationTime > OVERVIEW_ACTIVATION_TIMEOUT) if (this._activationTime == 0 || Date.now() / 1000 - this._activationTime > OVERVIEW_ACTIVATION_TIMEOUT)
return true; return true;