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 <laszlo.agocs@digia.com>
Reviewed-by: Jonathan Liu <net147@gmail.com>
This commit is contained in:
Morten Johan Sørvig 2014-06-26 15:15:56 +02:00 committed by Jonathan Liu
parent 42bdbed7ce
commit dafd1ffa2c
4 changed files with 13 additions and 10 deletions

View File

@ -1628,8 +1628,9 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
QWindowSystemInterfacePrivate::ApplicationStateChangedEvent * changeEvent = static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e);
QGuiApplicationPrivate::setApplicationState(changeEvent->newState, changeEvent->forcePropagate); }
break;
case QWindowSystemInterfacePrivate::FlushEvents:
QWindowSystemInterface::deferredFlushWindowSystemEvents();
case QWindowSystemInterfacePrivate::FlushEvents: {
QWindowSystemInterfacePrivate::FlushEventsEvent *flushEventsEvent = static_cast<QWindowSystemInterfacePrivate::FlushEventsEvent *>(e);
QWindowSystemInterface::deferredFlushWindowSystemEvents(flushEventsEvent->flags); }
break;
case QWindowSystemInterfacePrivate::Close:
QGuiApplicationPrivate::processCloseEvent(

View File

@ -526,16 +526,16 @@ void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion &regi
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);
}
}

View File

@ -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();
};

View File

@ -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 {