qpa: Teach handleApplicationStateChanged about sync/async delivery
Using QWindowSystemInterface::SynchronousDelivery reduces the chance that we are flushing other events before delivering the application state change. Those other events may conclude that the application is still active, while in reality it is not, and do bad things. Change-Id: I738c162fac22d2cd18de1e080bcd2cda78ec3f77 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
53f7c20cb5
commit
68733e307f
@ -265,12 +265,12 @@ void QWindowSystemInterface::handleWindowScreenChanged(QWindow *window, QScreen
|
||||
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
|
||||
}
|
||||
|
||||
void QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate)
|
||||
QT_DEFINE_QPA_EVENT_HANDLER(void, handleApplicationStateChanged, Qt::ApplicationState newState, bool forcePropagate)
|
||||
{
|
||||
Q_ASSERT(QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState));
|
||||
QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e =
|
||||
new QWindowSystemInterfacePrivate::ApplicationStateChangedEvent(newState, forcePropagate);
|
||||
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
|
||||
QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -179,6 +179,7 @@ public:
|
||||
static void handleWindowStateChanged(QWindow *window, Qt::WindowState newState, int oldState = -1);
|
||||
static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen);
|
||||
|
||||
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
|
||||
static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false);
|
||||
|
||||
#ifndef QT_NO_DRAGANDDROP
|
||||
|
@ -39,6 +39,8 @@
|
||||
|
||||
#include "qiosapplicationstate.h"
|
||||
|
||||
#include "qiosglobal.h"
|
||||
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
|
||||
@ -72,8 +74,8 @@ static Qt::ApplicationState qtApplicationState(UIApplicationState uiApplicationS
|
||||
static void handleApplicationStateChanged(UIApplicationState uiApplicationState)
|
||||
{
|
||||
Qt::ApplicationState state = qtApplicationState(uiApplicationState);
|
||||
QWindowSystemInterface::handleApplicationStateChanged(state);
|
||||
QWindowSystemInterface::flushWindowSystemEvents();
|
||||
qCDebug(lcQpaApplication) << "moved to" << state;
|
||||
QWindowSystemInterface::handleApplicationStateChanged<QWindowSystemInterface::SynchronousDelivery>(state);
|
||||
}
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -47,6 +47,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(lcQpaApplication);
|
||||
Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods);
|
||||
|
||||
#if !defined(QT_NO_DEBUG)
|
||||
|
@ -44,6 +44,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_LOGGING_CATEGORY(lcQpaApplication, "qt.qpa.application");
|
||||
Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods");
|
||||
|
||||
bool isQtApplication()
|
||||
|
Loading…
Reference in New Issue
Block a user