summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2013-10-15 20:11:37 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-16 17:10:15 +0200
commitb271ddebfcda26839a02705f17e287a4686f36fb (patch)
treedb8e643903c45315fbc742e6707c60659db64a70 /src/plugins
parent66e3e1f75b9698a8aaa92efeebff89f83afc83c4 (diff)
Ensure that context menus show even if the window is not active on Mac
When using the mouse to show a context menu on Mac then even if the window is not active then it will show the menu for native applications. So this ensures that this is respected for context menus in Qt too. Task-number: QTBUG-31497 Change-Id: Ibfcb4b893b0e31d4ce36926a83c9214d130d8fa2 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm17
2 files changed, 14 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 05bf657c1f..6598bf393e 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -204,6 +204,7 @@ public: // for QNSView
static const int NoAlertRequest;
NSInteger m_alertRequest;
+ id monitor;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index bee6d635ec..522b48a61e 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -213,6 +213,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_registerTouchCount(0)
, m_resizableTransientParent(false)
, m_alertRequest(NoAlertRequest)
+ , monitor(nil)
{
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
qDebug() << "QCocoaWindow::QCocoaWindow" << this;
@@ -367,6 +368,11 @@ void QCocoaWindow::setVisible(bool visible)
if ((window()->type() == Qt::Popup || window()->type() == Qt::Dialog || window()->type() == Qt::Tool)
&& [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);
+ }];
+ }
}
}
}
@@ -403,6 +409,10 @@ void QCocoaWindow::setVisible(bool visible)
} else {
[m_contentView setHidden:YES];
}
+ if (monitor && window()->type() == Qt::Popup) {
+ [NSEvent removeMonitor:monitor];
+ monitor = nil;
+ }
if (parentCocoaWindow && window()->type() == Qt::Popup) {
parentCocoaWindow->m_activePopupWindow = 0;
if (m_resizableTransientParent
@@ -849,10 +859,9 @@ NSWindow * QCocoaWindow::createNSWindow()
// before the window is shown and needs a proper window.).
if ((type & Qt::Popup) == Qt::Popup)
[window setHasShadow:YES];
- else {
- setWindowShadow(flags);
- [window setHidesOnDeactivate: NO];
- }
+ else
+ setWindowShadow(flags);
+ [window setHidesOnDeactivate: NO];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {