diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 7ad4f57198..7f25ed76c3 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -141,6 +141,11 @@ int QWindowSystemInterfacePrivate::windowSystemEventsQueued() return windowSystemEventQueue.count(); } +bool QWindowSystemInterfacePrivate::nonUserInputEventsQueued() +{ + return windowSystemEventQueue.nonUserInputEventsQueued(); +} + QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate::getWindowSystemEvent() { return windowSystemEventQueue.takeFirstOrReturnNull(); @@ -955,6 +960,11 @@ int QWindowSystemInterface::windowSystemEventsQueued() return QWindowSystemInterfacePrivate::windowSystemEventsQueued(); } +bool QWindowSystemInterface::nonUserInputEventsQueued() +{ + return QWindowSystemInterfacePrivate::nonUserInputEventsQueued(); +} + // --------------------- QtTestLib support --------------------- // The following functions are used by testlib, and need to be synchronous to avoid diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 253584314c..aadf63782f 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -246,6 +246,7 @@ public: static bool flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents); static void deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags); static int windowSystemEventsQueued(); + static bool nonUserInputEventsQueued(); }; #ifndef QT_NO_DEBUG_STREAM diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 1bcc79552d..0f350fb2d2 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -458,6 +458,14 @@ public: return impl.takeAt(i); return 0; } + bool nonUserInputEventsQueued() + { + const QMutexLocker locker(&mutex); + for (int i = 0; i < impl.size(); ++i) + if (!(impl.at(i)->type & QWindowSystemInterfacePrivate::UserInputEvent)) + return true; + return false; + } void append(WindowSystemEvent *e) { const QMutexLocker locker(&mutex); impl.append(e); } int count() const @@ -488,6 +496,7 @@ public: static WindowSystemEventList windowSystemEventQueue; static int windowSystemEventsQueued(); + static bool nonUserInputEventsQueued(); static WindowSystemEvent *getWindowSystemEvent(); static WindowSystemEvent *getNonUserInputWindowSystemEvent(); static WindowSystemEvent *peekWindowSystemEvent(EventType t); diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp index 4c8a82470b..dc4785071f 100644 --- a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp +++ b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp @@ -46,8 +46,6 @@ #include #include "private/qguiapplication_p.h" -#include - QT_BEGIN_NAMESPACE struct GUserEventSource @@ -56,12 +54,15 @@ struct GUserEventSource QPAEventDispatcherGlib *q; }; -static gboolean userEventSourcePrepare(GSource *s, gint *timeout) +static gboolean userEventSourcePrepare(GSource *source, gint *timeout) { - Q_UNUSED(s) Q_UNUSED(timeout) - - return QWindowSystemInterface::windowSystemEventsQueued() > 0; + GUserEventSource *userEventSource = reinterpret_cast(source); + QPAEventDispatcherGlib *dispatcher = userEventSource->q; + if (dispatcher->m_flags & QEventLoop::ExcludeUserInputEvents) + return QWindowSystemInterface::nonUserInputEventsQueued(); + else + return QWindowSystemInterface::windowSystemEventsQueued() > 0; } static gboolean userEventSourceCheck(GSource *source)