8#include <QtCore/QCoreApplication>
10#include <qpa/qwindowsysteminterface.h>
16 , m_connection(connection)
26 const bool didSendEvents = QEventDispatcherUNIX::processEvents(flags);
27 m_connection->processXcbEvents(flags);
29 return QWindowSystemInterface::sendWindowSystemEvents(flags) || didSendEvents;
36 QXcbGlibEventDispatcher *dispatcher;
37 QXcbGlibEventDispatcherPrivate *dispatcher_p;
38 QXcbConnection *connection =
nullptr;
41static gboolean xcbSourcePrepare(GSource *source, gint *timeout)
44 auto xcbEventSource =
reinterpret_cast<XcbEventSource *>(source);
45 return xcbEventSource->dispatcher_p->wakeUpCalled;
48static gboolean xcbSourceCheck(GSource *source)
50 return xcbSourcePrepare(source,
nullptr);
53static gboolean xcbSourceDispatch(GSource *source, GSourceFunc, gpointer)
55 auto xcbEventSource =
reinterpret_cast<XcbEventSource *>(source);
56 QEventLoop::ProcessEventsFlags flags = xcbEventSource->dispatcher->flags();
57 xcbEventSource->connection->processXcbEvents(flags);
59 QWindowSystemInterface::sendWindowSystemEvents(flags);
63QXcbGlibEventDispatcher::QXcbGlibEventDispatcher(QXcbConnection *connection, QObject *parent)
64 : QEventDispatcherGlib(*
new QXcbGlibEventDispatcherPrivate(), parent)
66 Q_D(QXcbGlibEventDispatcher);
68 m_xcbEventSourceFuncs.prepare = xcbSourcePrepare;
69 m_xcbEventSourceFuncs.check = xcbSourceCheck;
70 m_xcbEventSourceFuncs.dispatch = xcbSourceDispatch;
71 m_xcbEventSourceFuncs.finalize =
nullptr;
73 GSource *source = g_source_new(&m_xcbEventSourceFuncs,
sizeof(XcbEventSource));
74 g_source_set_name(source,
"[Qt] XcbEventSource");
75 m_xcbEventSource =
reinterpret_cast<XcbEventSource *>(source);
77 m_xcbEventSource->dispatcher =
this;
78 m_xcbEventSource->dispatcher_p = d_func();
79 m_xcbEventSource->connection = connection;
81 g_source_set_can_recurse(&m_xcbEventSource->source,
true);
82 g_source_attach(&m_xcbEventSource->source, d->mainContext);
85QXcbGlibEventDispatcherPrivate::QXcbGlibEventDispatcherPrivate()
89QXcbGlibEventDispatcher::~QXcbGlibEventDispatcher()
91 g_source_destroy(&m_xcbEventSource->source);
92 g_source_unref(&m_xcbEventSource->source);
95bool QXcbGlibEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
98 return QEventDispatcherGlib::processEvents(m_flags);
106 if (qEnvironmentVariableIsEmpty(
"QT_NO_GLIB") && QEventDispatcherGlib::versionSupported()) {
107 qCDebug(lcQpaXcb,
"using glib dispatcher");
108 return new QXcbGlibEventDispatcher(connection);
112 qCDebug(lcQpaXcb,
"using unix dispatcher");
113 return new QXcbUnixEventDispatcher(connection);
119#include "moc_qxcbeventdispatcher.cpp"
~QXcbUnixEventDispatcher()
bool processEvents(QEventLoop::ProcessEventsFlags flags) override
Processes pending events that match flags until there are no more events to process.