From dafd1ffa2c6fb8823b8e582d7cc75a050e14a80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 26 Jun 2014 15:15:56 +0200 Subject: QPA: Flush window system events with flags. Add a QEventLoop::ProcessEventsFlags argument to flushWindowSystemEvents(). This gives the platform plugins more control over which events to flush. Task-number: QTBUG-39842 Change-Id: Id9c01948b22e297b22503d38ec4e726f9f880fd5 Reviewed-by: Laszlo Agocs Reviewed-by: Jonathan Liu --- src/gui/kernel/qguiapplication.cpp | 5 +++-- src/gui/kernel/qwindowsysteminterface.cpp | 10 +++++----- src/gui/kernel/qwindowsysteminterface.h | 4 ++-- src/gui/kernel/qwindowsysteminterface_p.h | 4 +++- 4 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 5233d76d7b..59bcd37251 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1628,8 +1628,9 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv QWindowSystemInterfacePrivate::ApplicationStateChangedEvent * changeEvent = static_cast(e); QGuiApplicationPrivate::setApplicationState(changeEvent->newState, changeEvent->forcePropagate); } break; - case QWindowSystemInterfacePrivate::FlushEvents: - QWindowSystemInterface::deferredFlushWindowSystemEvents(); + case QWindowSystemInterfacePrivate::FlushEvents: { + QWindowSystemInterfacePrivate::FlushEventsEvent *flushEventsEvent = static_cast(e); + QWindowSystemInterface::deferredFlushWindowSystemEvents(flushEventsEvent->flags); } break; case QWindowSystemInterfacePrivate::Close: QGuiApplicationPrivate::processCloseEvent( diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index bd95a8614f..722a695481 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -526,16 +526,16 @@ void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion ®i QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } -void QWindowSystemInterface::deferredFlushWindowSystemEvents() +void QWindowSystemInterface::deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags) { Q_ASSERT(QThread::currentThread() == QGuiApplication::instance()->thread()); QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex); - flushWindowSystemEvents(); + flushWindowSystemEvents(flags); QWindowSystemInterfacePrivate::eventsFlushed.wakeOne(); } -void QWindowSystemInterface::flushWindowSystemEvents() +void QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags) { const int count = QWindowSystemInterfacePrivate::windowSystemEventQueue.count(); if (!count) @@ -549,11 +549,11 @@ void QWindowSystemInterface::flushWindowSystemEvents() } if (QThread::currentThread() != QGuiApplication::instance()->thread()) { QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex); - QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(); + QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(flags); QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex); } else { - sendWindowSystemEvents(QEventLoop::AllEvents); + sendWindowSystemEvents(flags); } } diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 9784757d3a..30c236b51f 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -208,8 +208,8 @@ public: // For event dispatcher implementations static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags); static void setSynchronousWindowsSystemEvents(bool enable); - static void flushWindowSystemEvents(); - static void deferredFlushWindowSystemEvents(); + static void flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents); + static void deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags); static int windowSystemEventsQueued(); }; diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index f48c75a027..c3f41da835 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -178,9 +178,11 @@ public: class FlushEventsEvent : public WindowSystemEvent { public: - FlushEventsEvent() + FlushEventsEvent(QEventLoop::ProcessEventsFlags f = QEventLoop::AllEvents) : WindowSystemEvent(FlushEvents) + , flags(f) { } + QEventLoop::ProcessEventsFlags flags; }; class UserEvent : public WindowSystemEvent { -- cgit v1.2.3