From 18b10527cc14a42a19b5d088845bfd2e96326bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 3 Sep 2020 10:51:01 +0200 Subject: [PATCH 03/19] 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 (cherry picked from commit 8d3a91016506fd0afedb0be535f7c34a4ca762f6) --- src/quick/handlers/qquickhandlerpoint.cpp | 4 ++-- src/quick/handlers/qquicksinglepointhandler.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/quick/handlers/qquickhandlerpoint.cpp b/src/quick/handlers/qquickhandlerpoint.cpp index 72efdfd0f4..6aef3545dd 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_uniqueId = QPointingDeviceUniqueId(); m_position = QPointF(); m_scenePosition = QPointF(); @@ -165,7 +165,7 @@ void QQuickHandlerPoint::reset(const QVector &points) pressureSum += point.pressure(); ellipseDiameterSum += point.ellipseDiameters(); } - m_id = 0; + m_id = -1; m_uniqueId = QPointingDeviceUniqueId(); // all points are required to be from the same event, so pressed buttons and modifiers should be the same m_pressedButtons = points.first().pressedButtons(); 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) -- 2.40.0