diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-09-15 09:58:27 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-09-15 17:49:34 +0200 |
commit | 276943c8b791ba5897dcdb1ecfda780ac33a090b (patch) | |
tree | e56ba5476bc2f65ceba992262983140934e4f5ae /src/widgets/kernel/qapplication.cpp | |
parent | 62b658ee8e1d2b46caaecef8f13c9031178a57f8 (diff) |
Make the closeAllPopup helper virtual in QGuiApplication
QPA plugins might have to close popups for events that are not delivered
to QWindow or QWidget instances. For instance, the Cocoa plugin has to
explicilty close popups when the user clicks into the window frame.
Expose this functionality through a virtual in QGuiApplicationPrivate,
and move the QApplication implementation from a static helper into the
override.
Task-number: QTBUG-96450
Change-Id: I52be5710c8d7515b9ae2e4bbadb069df4b3ed546
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index de450923ff..9069b9005d 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2628,16 +2628,6 @@ bool QApplicationPrivate::shouldQuit() return QGuiApplicationPrivate::shouldQuitInternal(processedWindows); } -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) @@ -2711,7 +2701,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) // Close all popups (triggers when switching applications // by pressing ALT-TAB on Windows, which is not receive as key event. // triggers when the screen rotates.) - closeAllPopups(); + d->closeAllPopups(); break; case QEvent::Wheel: // User input and window activation makes tooltips sleep case QEvent::ActivationChange: @@ -3444,6 +3434,17 @@ extern QWidget *qt_popup_down; extern bool qt_replay_popup_mouse_event; extern bool qt_popup_down_closed; +bool QApplicationPrivate::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(); // this will call QApplicationPrivate::closePopup + return true; +} + void QApplicationPrivate::closePopup(QWidget *popup) { if (!popupWidgets) |