summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoawindow.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index a7ebf4148c..29b983cd89 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -239,6 +239,9 @@ static bool isMouseEvent(NSEvent *ev)
if (!pw || pw->m_isNSWindowChild)
return NO;
+ if (pw->shouldRefuseKeyWindowAndFirstResponder())
+ return NO;
+
// The default implementation returns NO for title-bar less windows,
// override and return yes here to make sure popup windows such as
// the combobox popup can become the key window.
@@ -316,6 +319,9 @@ static bool isMouseEvent(NSEvent *ev)
if (!pw)
return NO;
+ if (pw->shouldRefuseKeyWindowAndFirstResponder())
+ return NO;
+
// Only tool or dialog windows should become key:
Qt::WindowType type = pw->window()->type();
if (type == Qt::Tool || type == Qt::Dialog)
@@ -368,6 +374,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_windowModality(Qt::NonModal)
, m_windowUnderMouse(false)
, m_inConstructor(true)
+ , m_inSetVisible(false)
#ifndef QT_NO_OPENGL
, m_glContext(0)
#endif
@@ -616,6 +623,8 @@ void QCocoaWindow::setVisible(bool visible)
if (m_isNSWindowChild && m_hiddenByClipping)
return;
+ m_inSetVisible = true;
+
QCocoaAutoReleasePool pool;
QCocoaWindow *parentCocoaWindow = 0;
if (window()->transientParent())
@@ -755,6 +764,8 @@ void QCocoaWindow::setVisible(bool visible)
[parentCocoaWindow->m_nsWindow setStyleMask:[parentCocoaWindow->m_nsWindow styleMask] | NSResizableWindowMask];
}
}
+
+ m_inSetVisible = false;
}
NSInteger QCocoaWindow::windowLevel(Qt::WindowFlags flags)
@@ -1784,6 +1795,23 @@ QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint)
return targetWindow;
}
+bool QCocoaWindow::shouldRefuseKeyWindowAndFirstResponder()
+{
+ // This function speaks up if there's any reason
+ // to refuse key window or first responder state.
+
+ if (window()->flags() & Qt::WindowDoesNotAcceptFocus)
+ return true;
+
+ if (m_inSetVisible) {
+ QVariant showWithoutActivating = window()->property("_q_showWithoutActivating");
+ if (showWithoutActivating.isValid() && showWithoutActivating.toBool())
+ return true;
+ }
+
+ return false;
+}
+
QMargins QCocoaWindow::frameMargins() const
{
NSRect frameW = [m_nsWindow frame];