summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>2015-09-21 12:21:15 +0200
committerTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>2016-06-16 11:15:24 +0000
commitaed7540d45096791d1a824f500694a15426fd94b (patch)
tree84fee02a117523530b30e9259a7b86e36d3241ab
parent59956ec905de1045039544833ebb66b1a294a4a5 (diff)
Cocoa integration - inconsistent window types/styles
NSWindow does not support 'utility window' style, but NSPanel - does. If we first create a normal widget, then later make it a Qt::Tool, we still have NSWindow with (now) invalid 'floating panel' window level (but no 'utility window' style) - it's a window that stays on top even when we switch to a different application. Change-Id: I691bc6f681cdf8bc2a9637444da33e7e6200ee2f Task-number: QTBUG-45938 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm13
2 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index d9e94735ac..6415233250 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -275,6 +275,7 @@ protected:
void syncWindowState(Qt::WindowState newState);
void reinsertChildWindow(QCocoaWindow *child);
void removeChildWindow(QCocoaWindow *child);
+ bool isNativeWindowTypeInconsistent();
// private:
public: // for QNSView
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index f099acf4c4..86df38c583 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -652,7 +652,7 @@ void QCocoaWindow::setVisible(bool visible)
if (visible) {
// We need to recreate if the modality has changed as the style mask will need updating
- if (m_windowModality != window()->modality())
+ if (m_windowModality != window()->modality() || isNativeWindowTypeInconsistent())
recreateWindow(parent());
// Register popup windows. The Cocoa platform plugin will forward mouse events
@@ -1531,6 +1531,17 @@ void QCocoaWindow::removeChildWindow(QCocoaWindow *child)
[m_nsWindow removeChildWindow:child->m_nsWindow];
}
+bool QCocoaWindow::isNativeWindowTypeInconsistent()
+{
+ if (!m_nsWindow)
+ return false;
+
+ const bool isPanel = [m_nsWindow isKindOfClass:[QNSPanel class]];
+ const bool usePanel = shouldUseNSPanel();
+
+ return isPanel != usePanel;
+}
+
void QCocoaWindow::removeMonitor()
{
if (!monitor)