From f35afe3eeaa460cb5e96171fb8a43fdf52c8761c Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 14 Jul 2020 20:09:57 +0200 Subject: Move event delivery from QQWindow to QQuickDeliveryAgent QQuickWindow owns QQuickRootItem which owns QQuickDeliveryAgent, so for every window there's an object responsible for event delivery, while the window itself is mainly responsible for rendering (separation of concerns). However, QQuickRootItem and QQuickDeliveryAgent can now be used in cases where the scene doesn't directly belong to a window, such as when a Qt Quick sub-scene is mapped somewhere into a Qt Quick 3D scene. In that case, we must remember which delivery agent was in use at the time when a QEventPoint is grabbed and deliver subsequent updates via the same DA. There's also a QQuickDeliveryAgent::Transform abstraction which subscene-management code (such as QQuick3DViewport) can implement, to provide a formula to map the window's scene coordinates to subscene coordinates; if defined, it will be used during delivery of subsequent updates to existing grabbers. Task-number: QTBUG-84870 Change-Id: I70b433f7ebb05d2e60214ff3192e05da0aa84a42 Reviewed-by: Andy Nichols (cherry picked from commit 68c103225f4e8bd6c1b18ef547108fd60f398c0f) Reviewed-by: Volker Hilsheimer --- src/quick/items/qquickflickable.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/quick/items/qquickflickable.cpp') diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 62bc078f4d..b02840208d 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1341,9 +1341,9 @@ void QQuickFlickablePrivate::handleMoveEvent(QPointerEvent *event) QVector2D velocity = event->point(0).velocity(); if (q->yflick()) - overThreshold |= QQuickWindowPrivate::dragOverThreshold(deltas.y(), Qt::YAxis, firstPoint); + overThreshold |= QQuickDeliveryAgentPrivate::dragOverThreshold(deltas.y(), Qt::YAxis, firstPoint); if (q->xflick()) - overThreshold |= QQuickWindowPrivate::dragOverThreshold(deltas.x(), Qt::XAxis, firstPoint); + overThreshold |= QQuickDeliveryAgentPrivate::dragOverThreshold(deltas.x(), Qt::XAxis, firstPoint); drag(currentTimestamp, event->type(), pos, deltas, overThreshold, false, false, velocity); } @@ -1518,7 +1518,7 @@ void QQuickFlickable::touchEvent(QTouchEvent *event) auto &firstPoint = event->point(0); if (auto grabber = qmlobject_cast(event->exclusiveGrabber(firstPoint))) { const auto localPos = grabber->mapFromScene(firstPoint.scenePosition()); - QScopedPointer localizedEvent(QQuickWindowPrivate::clonePointerEvent(event, localPos)); + QScopedPointer localizedEvent(QQuickDeliveryAgentPrivate::clonePointerEvent(event, localPos)); QCoreApplication::sendEvent(window(), localizedEvent.data()); } @@ -1762,7 +1762,7 @@ void QQuickFlickablePrivate::captureDelayedPress(QQuickItem *item, QPointerEvent if (!isInnermostPressDelay(item)) return; - delayedPressEvent = QQuickWindowPrivate::clonePointerEvent(event); + delayedPressEvent = QQuickDeliveryAgentPrivate::clonePointerEvent(event); delayedPressEvent->setAccepted(false); delayedPressTimer.start(pressDelay, q); qCDebug(lcReplay) << "begin press delay" << pressDelay << "ms with" << delayedPressEvent; @@ -1789,8 +1789,8 @@ void QQuickFlickablePrivate::replayDelayedPress() // If we have the grab, release before delivering the event if (QQuickWindow *window = q->window()) { - QQuickWindowPrivate *wpriv = QQuickWindowPrivate::get(window); - wpriv->allowChildEventFiltering = false; // don't allow re-filtering during replay + auto da = deliveryAgentPrivate(); + da->allowChildEventFiltering = false; // don't allow re-filtering during replay replayingPressEvent = true; auto &firstPoint = event->point(0); // At first glance, it's weird for delayedPressEvent to already have a grabber; @@ -1813,7 +1813,7 @@ void QQuickFlickablePrivate::replayDelayedPress() // We're done with replay, go back to normal delivery behavior replayingPressEvent = false; - wpriv->allowChildEventFiltering = true; + da->allowChildEventFiltering = true; } } } @@ -2577,7 +2577,7 @@ bool QQuickFlickable::filterPointerEvent(QQuickItem *receiver, QPointerEvent *ev bool stealThisEvent = d->stealMouse; bool receiverKeepsGrab = receiver && (receiver->keepMouseGrab() || receiver->keepTouchGrab()); if ((stealThisEvent || contains(localPos)) && (!receiver || !receiverKeepsGrab || receiverDisabled)) { - QScopedPointer localizedEvent(QQuickWindowPrivate::clonePointerEvent(event, localPos)); + QScopedPointer localizedEvent(QQuickDeliveryAgentPrivate::clonePointerEvent(event, localPos)); localizedEvent->setAccepted(false); switch (firstPoint.state()) { case QEventPoint::State::Updated: -- cgit v1.2.3