diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-07-13 23:55:13 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-07-15 20:53:10 +0200 |
commit | 1204ed14dc11e6343a569646428a7ffddd098f8c (patch) | |
tree | 49ff80392d6ffbb18e6f5b3dbbe5aa366d230ac5 /src/quick/items/qquickflickable.cpp | |
parent | 2967572e129cab889d9c6f89825ef9d77bf1ce63 (diff) |
Begin handling the QEvent refactoring
This is an intermediate step to get Qt Quick working again after
qtbase 4e400369c08db251cd489fec1229398c224d02b4.
- QQuickEventPoint::id() is no longer unique across devices, because now
eventPoint.event.device tells which specific device the event comes from.
(In Qt 5, we could not yet add the device pointer to QInputEvent.)
- However, MultiPointTouchArea's docs say that each pointId is unique,
and so do the HandlerPoint docs (for similar use cases with PointHandler).
So we still need the same hack using a Qt-specific short device ID
to unique-ify the QEventPoint::id(). Now we use the device index
in QInputDevice::devices() as the short ID.
- Otherwise, we trust QInputDevice::systemId() and QEventPoint::id()
more than before.
- Use QMutable* classes from qevent_p.h to continue using setters
that were in QTouchEvent before, etc. But setTouchPoints() is
not there, so we have to make new event instances in a couple of cases.
- QGuiApplicationPrivate::setMouseEventCapsAndVelocity() and
setMouseEventSource() are gone.
- Use (compiler-written) event copy constructors when possible.
Task-number: QTBUG-72173
Change-Id: I3915dc535ae4c5a81cbf333aba9355f01c420c15
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quick/items/qquickflickable.cpp')
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index bd7242e99f..d20f23466b 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQuick module of the Qt Toolkit. @@ -1320,10 +1320,9 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) qint64 currentTimestamp = computeCurrentTime(event); QVector2D deltas = QVector2D(event->position() - pressPos); bool overThreshold = false; - QVector2D velocity = QGuiApplicationPrivate::mouseEventVelocity(event); + QVector2D velocity = event->point(0).velocity(); // TODO guarantee that events always have velocity so that it never needs to be computed here - // TODO use event->device->caps() - if (!(QGuiApplicationPrivate::mouseEventCaps(event) & int(QInputDevice::Capability::Velocity))) { + if (!event->device()->capabilities().testFlag(QInputDevice::Capability::Velocity)) { qint64 lastTimestamp = (lastPos.isNull() ? lastPressTime : lastPosTime); if (currentTimestamp == lastTimestamp) return; // events are too close together: velocity would be infinite @@ -1363,8 +1362,8 @@ void QQuickFlickablePrivate::handleMouseReleaseEvent(QMouseEvent *event) qreal vVelocity = 0; if (elapsed < 100 && vData.velocity != 0.) { - vVelocity = (QGuiApplicationPrivate::mouseEventCaps(event) & int(QInputDevice::Capability::Velocity)) - ? QGuiApplicationPrivate::mouseEventVelocity(event).y() : vData.velocity; + vVelocity = (event->device()->capabilities().testFlag(QInputDevice::Capability::Velocity) + ? event->point(0).velocity().y() : vData.velocity); } if ((vData.atBeginning && vVelocity > 0.) || (vData.atEnd && vVelocity < 0.)) { vVelocity /= 2; @@ -1378,8 +1377,8 @@ void QQuickFlickablePrivate::handleMouseReleaseEvent(QMouseEvent *event) qreal hVelocity = 0; if (elapsed < 100 && hData.velocity != 0.) { - hVelocity = (QGuiApplicationPrivate::mouseEventCaps(event) & int(QInputDevice::Capability::Velocity)) - ? QGuiApplicationPrivate::mouseEventVelocity(event).x() : hData.velocity; + hVelocity = (event->device()->capabilities().testFlag(QInputDevice::Capability::Velocity) + ? event->point(0).velocity().x() : hData.velocity); } if ((hData.atBeginning && hVelocity > 0.) || (hData.atEnd && hVelocity < 0.)) { hVelocity /= 2; |