Bug 1455235 [gtk] Don't start moving window before mousemove event, r?dao
We need to start moving the window in GTK after mousemove event arrives,
not with mousedown, because the drag area can also process doubleclick
event to restore/maximize window. This also match to the GTK implementation,
see gedit behaviour for example.
MozReview-Commit-ID: WXP3D2wIp0
--- a/toolkit/modules/WindowDraggingUtils.jsm
+++ b/toolkit/modules/WindowDraggingUtils.jsm
@@ -56,36 +56,39 @@ WindowDraggingElement.prototype = {
this._elem.localName == "panel";
},
handleEvent(aEvent) {
let isPanel = this.isPanel();
switch (aEvent.type) {
case "mousedown":
if (!this.shouldDrag(aEvent))
return;
-
- if (/^gtk/i.test(AppConstants.MOZ_WIDGET_TOOLKIT)) {
- // On GTK, there is a toolkit-level function which handles
- // window dragging, which must be used.
- this._window.beginWindowMove(aEvent, isPanel ? this._elem : null);
- break;
- }
- if (isPanel) {
- let screenRect = this._elem.getOuterScreenRect();
- this._deltaX = aEvent.screenX - screenRect.left;
- this._deltaY = aEvent.screenY - screenRect.top;
- } else {
- this._deltaX = aEvent.screenX - this._window.screenX;
- this._deltaY = aEvent.screenY - this._window.screenY;
+ if (!/^gtk/i.test(AppConstants.MOZ_WIDGET_TOOLKIT)) {
+ if (isPanel) {
+ let screenRect = this._elem.getOuterScreenRect();
+ this._deltaX = aEvent.screenX - screenRect.left;
+ this._deltaY = aEvent.screenY - screenRect.top;
+ } else {
+ this._deltaX = aEvent.screenX - this._window.screenX;
+ this._deltaY = aEvent.screenY - this._window.screenY;
+ }
}
this._draggingWindow = true;
this._window.addEventListener("mousemove", this);
this._window.addEventListener("mouseup", this);
break;
case "mousemove":
+ if (/^gtk/i.test(AppConstants.MOZ_WIDGET_TOOLKIT)) {
+ // On GTK, there is a toolkit-level function which handles
+ // window dragging. We want to start moving the window
+ // on the first mousemove event after mousedown.
+ this._window.beginWindowMove(aEvent, isPanel ? this._elem : null);
+ this._window.removeEventListener("mousemove", this);
+ break;
+ }
if (this._draggingWindow) {
let toDrag = this.isPanel() ? this._elem : this._window;
toDrag.moveTo(aEvent.screenX - this._deltaX, aEvent.screenY - this._deltaY);
}
break;
case "mouseup":
if (this._draggingWindow) {
this._draggingWindow = false;