aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@qt.io>2017-03-17 15:39:45 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-03-28 07:55:13 +0000
commit3523b676382db4aa39adeb9126d8bb2185e84403 (patch)
treef4df76feb2bb371a9855e81359840827b03bdb8b /src/quick/handlers
parent0ff3093e32b2534b29d296b5733a6c2849e5b2ac (diff)
DragHandler: restrict dragging to *only* one finger
This means we can do a one-finger drag, then add two fingers to do a 3-finger pinch. Change-Id: I62c0184cfeeb3cc240cba20c6c2238852f68a79a Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/handlers')
-rw-r--r--src/quick/handlers/qquickpointersinglehandler.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/quick/handlers/qquickpointersinglehandler.cpp b/src/quick/handlers/qquickpointersinglehandler.cpp
index 8e00bd419a..6a4c4da7e6 100644
--- a/src/quick/handlers/qquickpointersinglehandler.cpp
+++ b/src/quick/handlers/qquickpointersinglehandler.cpp
@@ -71,8 +71,20 @@ bool QQuickPointerSingleHandler::wantsPointerEvent(QQuickPointerEvent *event)
// 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.
- if (auto point = event->pointById(m_pointId)) {
- if (wantsEventPoint(point)) {
+ int candidatePointCount = 0;
+ QQuickEventPoint *point = nullptr;
+ int c = event->pointCount();
+ for (int i = 0; i < c; ++i) {
+ QQuickEventPoint *p = event->point(i);
+ if (p->pointId() == m_pointId) {
+ point = p;
+ ++candidatePointCount;
+ } else if (wantsEventPoint(p)) {
+ ++candidatePointCount;
+ }
+ }
+ if (point) {
+ if (candidatePointCount == 1) {
point->setAccepted();
return true;
} else {
@@ -85,13 +97,17 @@ bool QQuickPointerSingleHandler::wantsPointerEvent(QQuickPointerEvent *event)
}
} else {
// We have not yet chosen a point; choose the first one for which wantsEventPoint() returns true.
+ int candidatePointCount = 0;
int c = event->pointCount();
- for (int i = 0; i < c && !m_pointId; ++i) {
- QQuickEventPoint *p = event->point(i);
- if (!p->exclusiveGrabber() && wantsEventPoint(p)) {
- m_pointId = p->pointId();
- p->setAccepted();
- }
+ QQuickEventPoint *p = nullptr;
+ for (int i = 0; i < c; ++i) {
+ p = event->point(i);
+ if (!p->exclusiveGrabber() && wantsEventPoint(p))
+ ++candidatePointCount;
+ }
+ if (p && candidatePointCount == 1) {
+ m_pointId = p->pointId();
+ p->setAccepted();
}
}
return m_pointId;