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 m_xcbEventSource =
reinterpret_cast<XcbEventSource *>(source);
76 m_xcbEventSource->dispatcher =
this;
77 m_xcbEventSource->dispatcher_p = d_func();
78 m_xcbEventSource->connection = connection;
80 d->attachSource(source,
"[Qt] XcbEventSource");
83QXcbGlibEventDispatcherPrivate::QXcbGlibEventDispatcherPrivate()
87QXcbGlibEventDispatcher::~QXcbGlibEventDispatcher()
89 Q_D(QXcbGlibEventDispatcher);
90 d->destroySource(&m_xcbEventSource->source);
93bool QXcbGlibEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
96 return QEventDispatcherGlib::processEvents(m_flags);
104 if (qEnvironmentVariableIsEmpty(
"QT_NO_GLIB") && QEventDispatcherGlib::versionSupported()) {
105 qCDebug(lcQpaXcb,
"using glib dispatcher");
106 return new QXcbGlibEventDispatcher(connection);
110 qCDebug(lcQpaXcb,
"using unix dispatcher");
111 return new QXcbUnixEventDispatcher(connection);
117#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.
Combined button and popup list for selecting options.