Bug 1455235 [gtk] Don't start moving window before mousemove event, r?dao draft
authorJan Horak <jhorak@redhat.com>
Thu, 19 Apr 2018 12:39:57 +0200
changeset 784991 3e762197e92eef52d1f4b15134edff7b65968110
parent 782895 6276ec7ebbf33e3484997b189f20fc1511534187
push id107088
push userbmo:jhorak@redhat.com
push dateThu, 19 Apr 2018 12:00:23 +0000
reviewersdao
bugs1455235
milestone61.0a1
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
toolkit/modules/WindowDraggingUtils.jsm
--- 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;