Commit 8d3a9101 authored by Jan Arve Sæther's avatar Jan Arve Sæther
Browse files

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: default avatarShawn Rutledge <shawn.rutledge@qt.io>
parent a1c91787
......@@ -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
......
......@@ -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;
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment