diff options
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview_mouse.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_mouse.mm | 23 |
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]; |