Bug 1455235 [gtk] Don't start moving window before mousemove event, r=dao
authorJan Horak <jhorak@redhat.com>
Thu, 19 Apr 2018 12:39:57 +0200
changeset 414637 cc0d7de218cb0c260c8ba0cf6637845ad2222f49
parent 414636 baeab3bff80799a6b1747fb0eef6f556410ce2e6
child 414638 cafdf61a721b265163f6be7802b5457beb254c71
child 414750 d642b603b348dd8a8d69bf983b1b66ecfc9b7cc1
push id33874
push userrgurzau@mozilla.com
push dateFri, 20 Apr 2018 09:11:15 +0000
treeherdermozilla-central@cc0d7de218cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1455235
milestone61.0a1
first release with
nightly linux32
cc0d7de218cb / 61.0a1 / 20180420100056 / files
nightly linux64
cc0d7de218cb / 61.0a1 / 20180420100056 / files
nightly mac
cc0d7de218cb / 61.0a1 / 20180420100056 / files
nightly win32
cc0d7de218cb / 61.0a1 / 20180420100056 / files
nightly win64
cc0d7de218cb / 61.0a1 / 20180420100056 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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;