diff options
Diffstat (limited to 'src/gui/kernel/qwindowsysteminterface.cpp')
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 01100d8555..8c5a3bc215 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -54,6 +54,8 @@ QT_BEGIN_NAMESPACE QElapsedTimer QWindowSystemInterfacePrivate::eventTime; bool QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents = false; +QWaitCondition QWindowSystemInterfacePrivate::eventsFlushed; +QMutex QWindowSystemInterfacePrivate::flushEventMutex; //------------------------------------------------------------ // @@ -514,9 +516,25 @@ void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion ®i QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } +void QWindowSystemInterface::deferredFlushWindowSystemEvents() +{ + Q_ASSERT(QThread::currentThread() == QGuiApplication::instance()->thread()); + + QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex); + flushWindowSystemEvents(); + QWindowSystemInterfacePrivate::eventsFlushed.wakeOne(); +} + void QWindowSystemInterface::flushWindowSystemEvents() { - sendWindowSystemEventsImplementation(QEventLoop::AllEvents); + if (QThread::currentThread() != QGuiApplication::instance()->thread()) { + QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex); + QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(); + QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex); + } else { + sendWindowSystemEventsImplementation(QEventLoop::AllEvents); + } } bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags) |