aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-04-20 10:01:34 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-04-21 13:31:05 +0000
commitdf0649fc57de1276ec1d0eb22af8b1b7dfc81a57 (patch)
tree5ab950d6bf045a6c8adb6569424242940d14bc1f /src/quick/handlers
parentdcc7367997e7241918cdf0c702c7bb8325eb1ad4 (diff)
QQPSingleHandler: don't accept a touchpoint other than the chosen one
This also caused a failure in the new TapHandler test: wantsPointerEvent() can see stationary touchpoints, and they may end up being "candidates" (although not if wantsEventPoint() returns false for all stationary points), but don't get confused by that: we chose a particular point, always the first for which wantsEventPoint() returns true, not any subsequent points for which wantsEventPoint() returns true. It's important to accept only that point, because in other places where we don't have access to the return value from wantsEventPoint(), we treat the accepted state as the _memory_ of what wantsEventPoint() returned. So it must be consistently the same. Change-Id: Ia121bde50d956b45b2cf62eddf326293a5c02274 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers')
-rw-r--r--src/quick/handlers/qquickpointersinglehandler.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/quick/handlers/qquickpointersinglehandler.cpp b/src/quick/handlers/qquickpointersinglehandler.cpp
index 5d61c75fbc..020d3ef7de 100644
--- a/src/quick/handlers/qquickpointersinglehandler.cpp
+++ b/src/quick/handlers/qquickpointersinglehandler.cpp
@@ -98,15 +98,18 @@ bool QQuickPointerSingleHandler::wantsPointerEvent(QQuickPointerEvent *event)
// We have not yet chosen a point; choose the first one for which wantsEventPoint() returns true.
int candidatePointCount = 0;
int c = event->pointCount();
- QQuickEventPoint *p = nullptr;
+ QQuickEventPoint *chosen = nullptr;
for (int i = 0; i < c; ++i) {
- p = event->point(i);
- if (!p->exclusiveGrabber() && wantsEventPoint(p))
+ QQuickEventPoint *p = event->point(i);
+ if (!p->exclusiveGrabber() && wantsEventPoint(p)) {
+ if (!chosen)
+ chosen = p;
++candidatePointCount;
+ }
}
- if (p && candidatePointCount == 1) {
- m_pointId = p->pointId();
- p->setAccepted();
+ if (chosen && candidatePointCount == 1) {
+ m_pointId = chosen->pointId();
+ chosen->setAccepted();
}
}
return m_pointId;