summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-09-07 13:42:02 +0200
committerQt by Nokia <qt-info@nokia.com>2012-09-11 12:09:47 +0200
commitf957370206fb88b40c354f2ca57ecfd315e3ac29 (patch)
tree6615aafd06caf8b1b96f4333cb180d3d4b1f76d6 /src
parentaab15782e21bf0aaea7f2211278e9aa9fc78c6d7 (diff)
Close popups when switching applications on Windows.
Bring back code from 4.8 (Note that ALT-TAB is not received as key event). Task-number: QTBUG-27146 Change-Id: I6dd2e9c88fdc4c89d26dfaa8ab47deb2be451f25 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qapplication.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 7e672f4725..fe95f58c0b 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2934,6 +2934,16 @@ bool QApplicationPrivate::shouldQuit()
return QGuiApplicationPrivate::shouldQuit();
}
+static inline void closeAllPopups()
+{
+ // Close all popups: In case some popup refuses to close,
+ // we give up after 1024 attempts (to avoid an infinite loop).
+ int maxiter = 1024;
+ QWidget *popup;
+ while ((popup = QApplication::activePopupWidget()) && maxiter--)
+ popup->close();
+}
+
/*! \reimp
*/
bool QApplication::notify(QObject *receiver, QEvent *e)
@@ -3006,9 +3016,13 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
}
#endif // QT_NO_GESTURES
- // User input and window activation makes tooltips sleep
switch (e->type()) {
- case QEvent::Wheel:
+ case QEvent::ApplicationDeactivate:
+ // Close all popups (triggers when switching applications
+ // by pressing ALT-TAB on Windows, which is not receive as key event.
+ closeAllPopups();
+ break;
+ case QEvent::Wheel: // User input and window activation makes tooltips sleep
case QEvent::ActivationChange:
case QEvent::KeyPress:
case QEvent::KeyRelease: