diff options
author | Andy Shaw <andy.shaw@digia.com> | 2015-03-30 14:07:22 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@digia.com> | 2015-04-17 07:18:40 +0000 |
commit | 50ce5a68301dee2fd00b7c6ccc615257a2353098 (patch) | |
tree | 3c7ec6187399308afa77aec7bf15a0fb251c76b9 | |
parent | 5ce567c536fde6b7cb93657d14df404f3e270119 (diff) |
Cocoa: Handle the event passed into the global monitor correctly
When the global monitor was used it did not get the right position for
the mouse event and as a result it caused context menus to appear and
disappear instantly when right clicking over a non active window. This
ensures that the events are sent correctly with the right position and
button information.
Task-number: QTBUG-45015
Change-Id: I9b17a725e656c716c4e22117b4513e64c357b266
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 2adea0f493..0f9c2c1c86 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -680,8 +680,10 @@ void QCocoaWindow::setVisible(bool visible) && [m_nsWindow isKindOfClass:[NSPanel class]]) { [(NSPanel *)m_nsWindow setWorksWhenModal:YES]; if (!(parentCocoaWindow && window()->transientParent()->isActive()) && window()->type() == Qt::Popup) { - monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask|NSRightMouseDownMask|NSOtherMouseDown handler:^(NSEvent *) { - QWindowSystemInterface::handleMouseEvent(window(), QPointF(-1, -1), QPointF(window()->framePosition() - QPointF(1, 1)), Qt::LeftButton); + monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask|NSRightMouseDownMask|NSOtherMouseDownMask|NSMouseMovedMask handler:^(NSEvent *e) { + QPointF localPoint = qt_mac_flipPoint([NSEvent mouseLocation]); + QWindowSystemInterface::handleMouseEvent(window(), window()->mapFromGlobal(localPoint.toPoint()), localPoint, + cocoaButton2QtButton([e buttonNumber])); }]; } } |