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
--- 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);