Bug 1440413 - Use original mouse event position when checking for doubleclick on titlebar; r?stransky draft
authorJan Horak <jhorak@redhat.com>
Mon, 26 Feb 2018 16:23:34 +0100
changeset 759814 d4d77b281a22a380f23eda1239d44eb221be76f3
parent 759603 7208b6a7b11c3ed8c87a7f17c9c30a8f9583e791
push id100467
push userbmo:jhorak@redhat.com
push dateMon, 26 Feb 2018 16:50:34 +0000
reviewersstransky
bugs1440413
milestone60.0a1
Bug 1440413 - Use original mouse event position when checking for doubleclick on titlebar; r?stransky The DispatchEvent can manipulate with the mRefPoint we're later using to check if the double click happened on the titlebar. We need to save it for later check to avoid unwanted restore/maximize event when mouse event occurs near top border of any widget. Also don't handle doubleclick on titlebar when CSD is not enabled. MozReview-Commit-ID: KjxM1EsT4Lg
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2805,23 +2805,27 @@ nsWindow::OnButtonReleaseEvent(GdkEventB
     WidgetMouseEvent event(true, eMouseUp, this,
                            WidgetMouseEvent::eReal);
     event.button = domButton;
     InitButtonEvent(event, aEvent);
     gdouble pressure = 0;
     gdk_event_get_axis ((GdkEvent*)aEvent, GDK_AXIS_PRESSURE, &pressure);
     event.pressure = pressure ? pressure : mLastMotionPressure;
 
+    // The mRefPoint is manipulated in DispatchInputEvent, we're saving it
+    // to use it for the doubleclick position check.
+    LayoutDeviceIntPoint pos = event.mRefPoint;
+
     nsEventStatus eventStatus = DispatchInputEvent(&event);
 
     bool defaultPrevented = (eventStatus == nsEventStatus_eConsumeNoDefault);
     // Check if mouse position in titlebar and doubleclick happened to
     // trigger restore/maximize.
-    LayoutDeviceIntPoint pos = event.mRefPoint;
     if (!defaultPrevented
+             && mIsCSDEnabled
              && event.button == WidgetMouseEvent::eLeftButton
              && event.mClickCount == 2
              && mDraggableRegion.Contains(pos.x, pos.y)) {
 
         if (mSizeState == nsSizeMode_Maximized) {
             SetSizeMode(nsSizeMode_Normal);
         } else {
             SetSizeMode(nsSizeMode_Maximized);