summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qnsview_mouse.mm
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2022-05-16 18:16:04 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2022-05-16 18:16:04 +0300
commit231d3670981a33ec42b91ad1cb33c1fc50551066 (patch)
treeb1ef1096f4e279baaa2ea0d2daf14b5c4185a82f /src/plugins/platforms/cocoa/qnsview_mouse.mm
parentffdd372c7bbda62e9d937f406319f38e3e982774 (diff)
parent8fc1a885d19a2dfb1a3a684aea1cfa41967e041f (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.5' into tqtc/lts-5.15-opensourcev5.15.5-lts-lgpl
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview_mouse.mm')
-rw-r--r--src/plugins/platforms/cocoa/qnsview_mouse.mm23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm
index b42f2d0e7e..8695cfc642 100644
--- a/src/plugins/platforms/cocoa/qnsview_mouse.mm
+++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm
@@ -103,21 +103,14 @@
if (!m_platformWindow)
return;
- // get m_buttons in sync
- // Don't send frme strut events if we are in the middle of a mouse drag.
- if (m_buttons != Qt::NoButton)
- return;
-
switch (theEvent.type) {
case NSEventTypeLeftMouseDown:
- case NSEventTypeLeftMouseDragged:
m_frameStrutButtons |= Qt::LeftButton;
break;
case NSEventTypeLeftMouseUp:
m_frameStrutButtons &= ~Qt::LeftButton;
break;
case NSEventTypeRightMouseDown:
- case NSEventTypeRightMouseDragged:
m_frameStrutButtons |= Qt::RightButton;
break;
case NSEventTypeRightMouseUp:
@@ -132,6 +125,22 @@
break;
}
+ // m_buttons can sometimes get out of sync with the button state in AppKit
+ // E.g if the QNSView where a drag starts is reparented to another window
+ // while the drag is ongoing, it will not get the corresponding mouseUp
+ // call. This will result in m_buttons to be stuck on Qt::LeftButton.
+ // Since we know which buttons was pressed/released directly on the frame
+ // strut, we can rectify m_buttons here so that we at least don't return early
+ // from the drag test underneath because of the faulty m_buttons state.
+ // FIXME: get m_buttons in sync with AppKit/NSEvent all over in QNSView.
+ m_buttons &= ~m_frameStrutButtons;
+
+ if (m_buttons != Qt::NoButton) {
+ // Don't send frame strut events if we are in the middle of
+ // a mouse drag that didn't start on the frame strut.
+ return;
+ }
+
NSWindow *window = [self window];
NSPoint windowPoint = [theEvent locationInWindow];