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>
This commit is contained in:
Timur Pocheptsov 2015-09-21 12:21:15 +02:00
parent 59956ec905
commit aed7540d45
2 changed files with 13 additions and 1 deletions

View File

@ -275,6 +275,7 @@ protected:
void syncWindowState(Qt::WindowState newState);
void reinsertChildWindow(QCocoaWindow *child);
void removeChildWindow(QCocoaWindow *child);
bool isNativeWindowTypeInconsistent();
// private:
public: // for QNSView

View File

@ -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)