diff options
Diffstat (limited to 'src/gui/kernel/qwindowsysteminterface.cpp')
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 71 |
1 files changed, 61 insertions, 10 deletions
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 6edcdfc255..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; @@ -339,12 +340,12 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleExposeEvent, QWindow *window, const QReg QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } -void QWindowSystemInterface::handleCloseEvent(QWindow *window, bool *accepted) +QT_DEFINE_QPA_EVENT_HANDLER(void, handleCloseEvent, QWindow *window, bool *accepted) { if (window) { QWindowSystemInterfacePrivate::CloseEvent *e = new QWindowSystemInterfacePrivate::CloseEvent(window, accepted); - QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } } @@ -795,14 +796,44 @@ void QWindowSystemInterface::handleThemeChange(QWindow *window) } #if QT_CONFIG(draganddrop) -QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) +#if QT_DEPRECATED_SINCE(5, 11) +QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *window, const QMimeData *dropData, + const QPoint &p, Qt::DropActions supportedActions) +{ + return QGuiApplicationPrivate::processDrag(window, dropData, p, supportedActions, + QGuiApplication::mouseButtons(), + QGuiApplication::keyboardModifiers()); +} + +QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, const QMimeData *dropData, + const QPoint &p, Qt::DropActions supportedActions) +{ + return QGuiApplicationPrivate::processDrop(window, dropData, p, supportedActions, + QGuiApplication::mouseButtons(), + QGuiApplication::keyboardModifiers()); +} +#endif // QT_DEPRECATED_SINCE(5, 11) +/*! + Drag and drop events are sent immediately. + + ### FIXME? Perhaps DnD API should add some convenience APIs that are more + intuitive for the possible DND operations. Here passing nullptr as drop data is used to + indicate that drop was canceled and QDragLeaveEvent should be sent as a result. +*/ +QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *window, const QMimeData *dropData, + const QPoint &p, Qt::DropActions supportedActions, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) { - return QGuiApplicationPrivate::processDrag(window, dropData, QHighDpi::fromNativeLocalPosition(p, window) ,supportedActions); + auto pos = QHighDpi::fromNativeLocalPosition(p, window); + return QGuiApplicationPrivate::processDrag(window, dropData, pos, supportedActions, buttons, modifiers); } -QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) +QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, const QMimeData *dropData, + const QPoint &p, Qt::DropActions supportedActions, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) { - return QGuiApplicationPrivate::processDrop(window, dropData, QHighDpi::fromNativeLocalPosition(p, window),supportedActions); + auto pos = QHighDpi::fromNativeLocalPosition(p, window); + return QGuiApplicationPrivate::processDrop(window, dropData, pos, supportedActions, buttons, modifiers); } #endif // QT_CONFIG(draganddrop) @@ -1017,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; @@ -1059,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 |