summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp')
-rw-r--r--src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp54
1 files changed, 52 insertions, 2 deletions
diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
index 06f0aa6747..0ccbf01e80 100644
--- a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
+++ b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
@@ -48,26 +48,76 @@
QT_BEGIN_NAMESPACE
+struct GUserEventSource
+{
+ GSource source;
+ QPAEventDispatcherGlib *q;
+ QPAEventDispatcherGlibPrivate *d;
+};
+
+static gboolean userEventSourcePrepare(GSource *source, gint *timeout)
+{
+ Q_UNUSED(timeout)
+ GUserEventSource *userEventSource = reinterpret_cast<GUserEventSource *>(source);
+ return userEventSource->d->wakeUpCalled;
+}
+
+static gboolean userEventSourceCheck(GSource *source)
+{
+ return userEventSourcePrepare(source, 0);
+}
+
+static gboolean userEventSourceDispatch(GSource *source, GSourceFunc, gpointer)
+{
+ GUserEventSource *userEventSource = reinterpret_cast<GUserEventSource *>(source);
+ QPAEventDispatcherGlib *dispatcher = userEventSource->q;
+ QWindowSystemInterface::sendWindowSystemEvents(dispatcher->m_flags);
+ return true;
+}
+
+static GSourceFuncs userEventSourceFuncs = {
+ userEventSourcePrepare,
+ userEventSourceCheck,
+ userEventSourceDispatch,
+ NULL,
+ NULL,
+ NULL
+};
+
QPAEventDispatcherGlibPrivate::QPAEventDispatcherGlibPrivate(GMainContext *context)
: QEventDispatcherGlibPrivate(context)
{
+ Q_Q(QPAEventDispatcherGlib);
+ userEventSource = reinterpret_cast<GUserEventSource *>(g_source_new(&userEventSourceFuncs,
+ sizeof(GUserEventSource)));
+ userEventSource->q = q;
+ userEventSource->d = this;
+ g_source_set_can_recurse(&userEventSource->source, true);
+ g_source_attach(&userEventSource->source, mainContext);
}
+
QPAEventDispatcherGlib::QPAEventDispatcherGlib(QObject *parent)
: QEventDispatcherGlib(*new QPAEventDispatcherGlibPrivate, parent)
, m_flags(QEventLoop::AllEvents)
{
+ Q_D(QPAEventDispatcherGlib);
+ d->userEventSource->q = this;
}
QPAEventDispatcherGlib::~QPAEventDispatcherGlib()
{
+ Q_D(QPAEventDispatcherGlib);
+
+ g_source_destroy(&d->userEventSource->source);
+ g_source_unref(&d->userEventSource->source);
+ d->userEventSource = 0;
}
bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
{
m_flags = flags;
- const bool didSendEvents = QEventDispatcherGlib::processEvents(m_flags);
- return QWindowSystemInterface::sendWindowSystemEvents(m_flags) || didSendEvents;
+ return QEventDispatcherGlib::processEvents(m_flags);
}
QT_END_NAMESPACE