From 00ae1e6b7bf6efa5f5e57d37844e44d521604fb6 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 19 Sep 2018 11:40:31 +0200 Subject: xcb: respect QEventLoop::ExcludeUserInputEvents in native event handlers This was a regression from Qt 4. Before this patch, we supported filtering events only at QWindowSystemInterface level, but to properly support filtering in QAbstractEventDispatcher::filterNativeEvent, we have to filter the events earlier. Now it is possible to enable/disable this feature for platforms that support native event filtering. The mapping of which events are user input events were taken from QWindowSystemInterfacePrivate::EventType. Task-number: QTBUG-69687 Change-Id: I9a5fb9f999451c47abcdc83fdcc129b5eeb55447 Reviewed-by: Paul Wicking Reviewed-by: Allan Sandfeld Jensen --- src/gui/kernel/qwindowsysteminterface.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/gui/kernel/qwindowsysteminterface.cpp') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 07ece5689e..67e1283462 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE QElapsedTimer QWindowSystemInterfacePrivate::eventTime; bool QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = false; +bool QWindowSystemInterfacePrivate::platformFiltersEvents = false; bool QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse = true; QWaitCondition QWindowSystemInterfacePrivate::eventsFlushed; QMutex QWindowSystemInterfacePrivate::flushEventMutex; @@ -1047,10 +1048,15 @@ bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFla int nevents = 0; while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) { - QWindowSystemInterfacePrivate::WindowSystemEvent *event = - (flags & QEventLoop::ExcludeUserInputEvents) ? - QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent() : - QWindowSystemInterfacePrivate::getWindowSystemEvent(); + QWindowSystemInterfacePrivate::WindowSystemEvent *event = nullptr; + + if (QWindowSystemInterfacePrivate::platformFiltersEvents) { + event = QWindowSystemInterfacePrivate::getWindowSystemEvent(); + } else { + event = flags & QEventLoop::ExcludeUserInputEvents ? + QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent() : + QWindowSystemInterfacePrivate::getWindowSystemEvent(); + } if (!event) break; @@ -1089,6 +1095,21 @@ bool QWindowSystemInterface::nonUserInputEventsQueued() return QWindowSystemInterfacePrivate::nonUserInputEventsQueued(); } +/*! + Platforms that implement UserInputEvent filtering at native event level must + set this property to \c true. The default is \c false, which means that event + filtering logic is handled by QWindowSystemInterface. Doing the filtering in + platform plugins is necessary when supporting AbstractEventDispatcher::filterNativeEvent(), + which should respect flags that were passed to event dispatcher's processEvents() + call. + + \since 5.12 +*/ +void QWindowSystemInterface::setPlatformFiltersEvents(bool enable) +{ + QWindowSystemInterfacePrivate::platformFiltersEvents = enable; +} + // --------------------- QtTestLib support --------------------- // The following functions are used by testlib, and need to be synchronous to avoid -- cgit v1.2.3