summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2018-09-04 10:30:53 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2018-10-12 10:21:32 +0000
commit8315acfb16ebc0c8788255965f73eb9d3557f027 (patch)
treef752944eadddd655cd143c02c411a7e2119f1231
parent466d65cd5b62caa1359b8e64e7e369a35390ac2d (diff)
Revert "glib dispatcher: ensure all window system events are flushed"
This reverts commit 341bfcd1eaa9116c143e3b7d3219ef04c7b8a0cb. As it turns out there might be use cases where we want to have proper windowing system event integration with glib dispatcher via g_source_attach(). For example with gtk_dialog_run, where GTK blocks in a recursive main loop. We want to continue dispatcing our windowing system events during this nested event loop. Not having a proper glib integration can result in rendering issues, e.g. when resizing parent window via mouse while GTK-based dialog is shown. Can be seen on examples/widgets/richtext/textedit/ -> Format (from menu) -> "Color..." The issue from 341bfcd1eaa actually should be fixed inside XCB platform plugin, by improving integration with event dispatcher. That is handled in follow-up patches. Change-Id: Icabc6d841a554aefbdd460765a3165d22e65f651 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp56
-rw-r--r--src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h3
2 files changed, 57 insertions, 2 deletions
diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
index 06f0aa6747..dc4785071f 100644
--- a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
+++ b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
@@ -48,26 +48,78 @@
QT_BEGIN_NAMESPACE
+struct GUserEventSource
+{
+ GSource source;
+ QPAEventDispatcherGlib *q;
+};
+
+static gboolean userEventSourcePrepare(GSource *source, gint *timeout)
+{
+ Q_UNUSED(timeout)
+ GUserEventSource *userEventSource = reinterpret_cast<GUserEventSource *>(source);
+ QPAEventDispatcherGlib *dispatcher = userEventSource->q;
+ if (dispatcher->m_flags & QEventLoop::ExcludeUserInputEvents)
+ return QWindowSystemInterface::nonUserInputEventsQueued();
+ else
+ return QWindowSystemInterface::windowSystemEventsQueued() > 0;
+}
+
+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;
+ 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
diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h b/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h
index 5930dc68e7..085a1c52f3 100644
--- a/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h
+++ b/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h
@@ -71,11 +71,14 @@ public:
QEventLoop::ProcessEventsFlags m_flags;
};
+struct GUserEventSource;
+
class QPAEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate
{
Q_DECLARE_PUBLIC(QPAEventDispatcherGlib)
public:
QPAEventDispatcherGlibPrivate(GMainContext *context = 0);
+ GUserEventSource *userEventSource;
};