Cocoa integration - do not make a window key during modal session

It can happen that we create a new window and make it visible during a modal
session. In this case making a window into the new key window looks quite
strange and misleading - since we're in a modal session, this window is completely
inactive/useless. Use orderFront instead.

Change-Id: Ic091e263508b452be4b5adf799a06017b044e441
Task-number: QTBUG-46304
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
This commit is contained in:
Timur Pocheptsov 2015-09-21 15:35:10 +02:00 committed by Frederik Gladhorn
parent 3719245dc3
commit 593ab63860

View File

@ -686,7 +686,16 @@ void QCocoaWindow::setVisible(bool visible)
cocoaEventDispatcherPrivate->beginModalSession(window());
m_hasModalSession = true;
} else if ([m_nsWindow canBecomeKeyWindow]) {
[m_nsWindow makeKeyAndOrderFront:nil];
QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = 0;
if (cocoaEventDispatcher)
cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
if (!(cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->currentModalSession()))
[m_nsWindow makeKeyAndOrderFront:nil];
else
[m_nsWindow orderFront:nil];
foreach (QCocoaWindow *childWindow, m_childWindows)
childWindow->show(true);
} else {