diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2020-09-03 10:51:01 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2020-09-04 19:42:01 +0200 |
commit | 8d3a91016506fd0afedb0be535f7c34a4ca762f6 (patch) | |
tree | cf8a799cf13e03d53850ca81ea3f27f122f914f7 | |
parent | a1c91787264f6f535b5cf094b57ee53058856df4 (diff) |
Fix TapHandler so that it actually registers a tap
This bug caused all quick examples that used the
shared\LauncherList.qml to be broken.
In QtGui, QSinglePointEvent will construct itself with a point id of 0
if there is a valid point, and with a point id of -1 if the point is
invalid (the default constructor does the latter).
However, QQuickSinglePointHandler::wantsPointerEvent() did not agree
with that, because it assumed that a point id of 0 meant
uninitialized/invalid point.
The fix is to change QQuickSinglePointHandler::wantsPointerEvent() and
QQuickHandlerPoint so that it assumes that the id -1 is now an invalid
point, (instead of 0)
Change-Id: I8c9683dfe06ebb77c5342a26f08174b67e7cbd90
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r-- | src/quick/handlers/qquickhandlerpoint.cpp | 4 | ||||
-rw-r--r-- | src/quick/handlers/qquickhandlerpoint_p.h | 2 | ||||
-rw-r--r-- | src/quick/handlers/qquicksinglepointhandler.cpp | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/quick/handlers/qquickhandlerpoint.cpp b/src/quick/handlers/qquickhandlerpoint.cpp index 2e4602affa..2990215719 100644 --- a/src/quick/handlers/qquickhandlerpoint.cpp +++ b/src/quick/handlers/qquickhandlerpoint.cpp @@ -82,7 +82,7 @@ void QQuickHandlerPoint::localize(QQuickItem *item) void QQuickHandlerPoint::reset() { - m_id = 0; + m_id = -1; m_device = QPointingDevice::primaryPointingDevice(); m_uniqueId = QPointingDeviceUniqueId(); m_position = QPointF(); @@ -167,7 +167,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points) pressureSum += point.pressure(); ellipseDiameterSum += point.ellipseDiameters(); } - m_id = 0; + m_id = -1; m_device = nullptr; m_uniqueId = QPointingDeviceUniqueId(); // all points are required to be from the same event, so pressed buttons and modifiers should be the same diff --git a/src/quick/handlers/qquickhandlerpoint_p.h b/src/quick/handlers/qquickhandlerpoint_p.h index 6ba5e3bf28..fd3b365e32 100644 --- a/src/quick/handlers/qquickhandlerpoint_p.h +++ b/src/quick/handlers/qquickhandlerpoint_p.h @@ -100,7 +100,7 @@ public: void reset(const QVector<QQuickHandlerPoint> &points); private: - int m_id = 0; + int m_id = -1; const QPointingDevice *m_device = QPointingDevice::primaryPointingDevice(); QPointingDeviceUniqueId m_uniqueId; Qt::MouseButtons m_pressedButtons = Qt::NoButton; diff --git a/src/quick/handlers/qquicksinglepointhandler.cpp b/src/quick/handlers/qquicksinglepointhandler.cpp index b51f53b74f..89081b4e84 100644 --- a/src/quick/handlers/qquicksinglepointhandler.cpp +++ b/src/quick/handlers/qquicksinglepointhandler.cpp @@ -75,7 +75,7 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event) if (!QQuickPointerDeviceHandler::wantsPointerEvent(event)) return false; - if (d->pointInfo.id()) { + if (d->pointInfo.id() != -1) { // We already know which one we want, so check whether it's there. // It's expected to be an update or a release. // If we no longer want it, cancel the grab. @@ -125,7 +125,7 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event) chosen->setAccepted(); } } - return d->pointInfo.id(); + return d->pointInfo.id() != -1; } void QQuickSinglePointHandler::handlePointerEventImpl(QQuickPointerEvent *event) |