Close popups on window deactivation and orientation changes in qGuiApp
With the introduction of QQuickPopupWindow in 6.8, much of our popup management had to be moved from QApplication to QGuiApplication. Most of this was done in e4ef0f03e6f1fddc397980fd7fbf6f6b829f16d9, but closing popups on window deactivation and orientation changes, were left in QApplication. This code path was used to close popups when the user clicks outside of a window, on platforms suchs as wayland, were QWindow::setMouseGrabEnabled(true) doesn't work properly. As it turns out QApplication::notify() never calls QGuiapplication::notify(), which is why I'm duplicating the code from QApplication into QGuiApplication, instead of simply moving it. Task-number: QTBUG-121363 Change-Id: I36bebd029a2f8e3ec0cdbab40971682cf948d438 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit 914c2ef4fb926c16e8874c9c3691401f7e22ae22) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
0b89eb6c6f
commit
6a2c2488a1
@ -2033,11 +2033,26 @@ void QGuiApplicationPrivate::captureGlobalModifierState(QEvent *e)
|
||||
*/
|
||||
bool QGuiApplication::notify(QObject *object, QEvent *event)
|
||||
{
|
||||
Q_D(QGuiApplication);
|
||||
if (object->isWindowType()) {
|
||||
if (QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(object), event))
|
||||
return true; // Platform plugin ate the event
|
||||
}
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::ApplicationDeactivate:
|
||||
case QEvent::OrientationChange:
|
||||
// Close all popups (triggers when switching applications
|
||||
// by pressing ALT-TAB on Windows, which is not received as a key event.
|
||||
// triggers when the screen rotates.)
|
||||
// This is also necessary on Wayland, and platforms where
|
||||
// QWindow::setMouseGrabEnabled(true) doesn't work.
|
||||
d->closeAllPopups();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QGuiApplicationPrivate::captureGlobalModifierState(event);
|
||||
|
||||
return QCoreApplication::notify(object, event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user