qpa: Let platform plugins report old state for window state changes
The previous logic relied on QPlatformWindow::setWindowState() being synchronous and delivering the QPA event before returning to QWindow, in which case window->windowState() would still refer to the old state. Async platforms can now report the previous state correctly. Change-Id: Ib9148fe23fb62be55b7e3a0ccf63d32c71dc2ad3 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>bb10
parent
1037eebc0b
commit
54e4735f89
|
|
@ -2162,7 +2162,7 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
|
|||
void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse)
|
||||
{
|
||||
if (QWindow *window = wse->window.data()) {
|
||||
QWindowStateChangeEvent e(window->windowState());
|
||||
QWindowStateChangeEvent e(wse->oldState);
|
||||
window->d_func()->windowState = wse->newState;
|
||||
QGuiApplication::sendSpontaneousEvent(window, &e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,10 +241,14 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowActivated, QWindow *window, Qt::Fo
|
|||
QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
|
||||
}
|
||||
|
||||
QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowStateChanged, QWindow *window, Qt::WindowState newState)
|
||||
QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowStateChanged, QWindow *window, Qt::WindowState newState, int oldState)
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
if (oldState < Qt::WindowNoState)
|
||||
oldState = window->windowState();
|
||||
|
||||
QWindowSystemInterfacePrivate::WindowStateChangedEvent *e =
|
||||
new QWindowSystemInterfacePrivate::WindowStateChangedEvent(window, newState);
|
||||
new QWindowSystemInterfacePrivate::WindowStateChangedEvent(window, newState, Qt::WindowState(oldState));
|
||||
QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public:
|
|||
static void handleWindowActivated(QWindow *window, Qt::FocusReason r = Qt::OtherFocusReason);
|
||||
|
||||
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
|
||||
static void handleWindowStateChanged(QWindow *window, Qt::WindowState newState);
|
||||
static void handleWindowStateChanged(QWindow *window, Qt::WindowState newState, int oldState = -1);
|
||||
static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen);
|
||||
|
||||
static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false);
|
||||
|
|
|
|||
|
|
@ -168,12 +168,13 @@ public:
|
|||
|
||||
class WindowStateChangedEvent : public WindowSystemEvent {
|
||||
public:
|
||||
WindowStateChangedEvent(QWindow *_window, Qt::WindowState _newState)
|
||||
: WindowSystemEvent(WindowStateChanged), window(_window), newState(_newState)
|
||||
WindowStateChangedEvent(QWindow *_window, Qt::WindowState _newState, Qt::WindowState _oldState)
|
||||
: WindowSystemEvent(WindowStateChanged), window(_window), newState(_newState), oldState(_oldState)
|
||||
{ }
|
||||
|
||||
QPointer<QWindow> window;
|
||||
Qt::WindowState newState;
|
||||
Qt::WindowState oldState;
|
||||
};
|
||||
|
||||
class WindowScreenChangedEvent : public WindowSystemEvent {
|
||||
|
|
|
|||
Loading…
Reference in New Issue