Revert "glib dispatcher: ensure all window system events are flushed"
This reverts commit341bfcd1ea
. 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 from341bfcd1ea
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>
This commit is contained in:
parent
466d65cd5b
commit
8315acfb16
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user