From 58d10c0bd7cff2009edf6183c660b2e149eb9a82 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Thu, 23 Jun 2011 09:05:34 +0200 Subject: Refactor window system event dispatching. Add QWindowSystemInterface::sendWindowSystemEvents, which contains the canonical "empty and send queued window system events" implementation. Make the Cocoa, QPA, and GLIB dispatchers use the new implementation. Cocoa now no longer inherits from QPA. --- src/gui/kernel/qwindowsysteminterface_qpa.cpp | 33 +++++++++++++++++++++++++++ src/gui/kernel/qwindowsysteminterface_qpa.h | 5 ++++ 2 files changed, 38 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index 9df8b1af54..6b2b2d5f19 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -270,4 +270,37 @@ void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion ®i QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } +bool QWindowSystemInterface::sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags) +{ + int nevents = 0; + + // handle gui and posted events + QCoreApplication::sendPostedEvents(); + + while (true) { + QWindowSystemInterfacePrivate::WindowSystemEvent *event; + if (!(flags & QEventLoop::ExcludeUserInputEvents) + && QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0) { + // process a pending user input event + event = QWindowSystemInterfacePrivate::getWindowSystemEvent(); + if (!event) + break; + } else { + break; + } + + if (eventDispatcher->filterEvent(event)) { + delete event; + continue; + } + + nevents++; + + QGuiApplicationPrivate::processWindowSystemEvent(event); + delete event; + } + + return (nevents > 0); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h index 1188ca3439..17d8f83a3f 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa.h @@ -44,10 +44,12 @@ #include #include #include +#include #include #include #include #include +#include QT_BEGIN_HEADER @@ -105,6 +107,9 @@ public: static void handleScreenGeometryChange(int screenIndex); static void handleScreenAvailableGeometryChange(int screenIndex); static void handleScreenCountChange(int count); + + // For event dispatcher implementations + static bool sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags); }; QT_END_NAMESPACE -- cgit v1.2.3