Cocoa: Explicitly hide popup windows when the application is hidden

When the application is hidden then Qt will hide the popup
windows associated with it when it has lost the activation
for the application. However, when it gets to this point it
believes the popup windows to be hidden already due to the
fact that the application itself is hidden. As a result,
when the application is restored it causes a problem with
the still visible popup window as it is taking the input
events without responding to them.

Therefore we need to explicitly hide the windows right before the
application is hidden to ensure that they are actually hidden
correctly.

Task-number: QTBUG-58727
Change-Id: I4be1e1c0b1388d0c9ec872e7732185670998b7af
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Andy Shaw 2017-03-23 17:49:16 +01:00
parent a5810375bf
commit 965bcca6d4

View File

@ -328,6 +328,24 @@ QT_END_NAMESPACE
return NO; // Someday qApp->quitOnLastWindowClosed(); when QApp and NSApp work closer together.
}
- (void)applicationWillHide:(NSNotification *)notification
{
if (reflectionDelegate
&& [reflectionDelegate respondsToSelector:@selector(applicationWillHide:)]) {
[reflectionDelegate applicationWillHide:notification];
}
// When the application is hidden Qt will hide the popup windows associated with
// it when it has lost the activation for the application. However, when it gets
// to this point it believes the popup windows to be hidden already due to the
// fact that the application itself is hidden, which will cause a problem when
// the application is made visible again.
const QWindowList topLevelWindows = QGuiApplication::topLevelWindows();
for (QWindow *topLevelWindow : qAsConst(topLevelWindows)) {
if ((topLevelWindow->type() & Qt::Popup) == Qt::Popup && topLevelWindow->isVisible())
topLevelWindow->hide();
}
}
- (void)applicationDidBecomeActive:(NSNotification *)notification
{