summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-03-23 17:49:16 +0100
committerAndy Shaw <andy.shaw@qt.io>2018-01-25 06:40:18 +0000
commit965bcca6d4e22788721a9af906adfbd97af9af29 (patch)
treeaf035dbfea0d8788ca7f8f8f2dccf166769bbb5f
parenta5810375bff382b9a578b6b655125cb7714a2bc1 (diff)
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>
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index 35ac7182af..03148c769b 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -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
{