diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-04-27 12:16:20 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-04-27 10:59:05 +0000 |
commit | b7f9f342480c669780a244c237642edaf5b57bc3 (patch) | |
tree | cd77c9390edef85d307a25f4d2b8e7559ad7c2a2 /src/quick | |
parent | 45cfee52e4dd488adc1050dd50fbe1dbecee9a4d (diff) |
QQMultiPointerHandler: don't steal grab if keepMouseGrab/keepTouchGrab
An Item (such as MPTA with onGestureStarted: gesture.grab()) may set
these flags, traditionally to prevent Flickable from stealing the grab.
QQuickMultiPointerHandler (and thus PinchHandler) now respects these
flags too.
Change-Id: Iac3ab796c5aa410be45639d679ecf82b7c44a442
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/handlers/qquickmultipointerhandler.cpp | 15 | ||||
-rw-r--r-- | src/quick/handlers/qquickmultipointerhandler_p.h | 2 | ||||
-rw-r--r-- | src/quick/handlers/qquickpinchhandler.cpp | 4 |
3 files changed, 15 insertions, 6 deletions
diff --git a/src/quick/handlers/qquickmultipointerhandler.cpp b/src/quick/handlers/qquickmultipointerhandler.cpp index 1a5684d80e..016210beff 100644 --- a/src/quick/handlers/qquickmultipointerhandler.cpp +++ b/src/quick/handlers/qquickmultipointerhandler.cpp @@ -238,10 +238,19 @@ void QQuickMultiPointerHandler::acceptPoints(const QVector<QQuickEventPoint *> & point->setAccepted(); } -void QQuickMultiPointerHandler::grabPoints(QVector<QQuickEventPoint *> points) +bool QQuickMultiPointerHandler::grabPoints(QVector<QQuickEventPoint *> points) { - for (QQuickEventPoint* point : points) - setExclusiveGrab(point); + bool canGrab = true; + for (QQuickEventPoint* point : points) { + auto grabber = point->grabberItem(); + if (grabber && (grabber->keepMouseGrab() || grabber->keepTouchGrab())) + canGrab = false; + } + if (canGrab) { + for (QQuickEventPoint* point : points) + setExclusiveGrab(point); + } + return canGrab; } QT_END_NAMESPACE diff --git a/src/quick/handlers/qquickmultipointerhandler_p.h b/src/quick/handlers/qquickmultipointerhandler_p.h index be92a39631..ce014d658c 100644 --- a/src/quick/handlers/qquickmultipointerhandler_p.h +++ b/src/quick/handlers/qquickmultipointerhandler_p.h @@ -98,7 +98,7 @@ protected: QVector<PointData> angles(const QPointF &ref) const; static qreal averageAngleDelta(const QVector<PointData> &old, const QVector<PointData> &newAngles); void acceptPoints(const QVector<QQuickEventPoint *> &points); - void grabPoints(QVector<QQuickEventPoint *> points); + bool grabPoints(QVector<QQuickEventPoint *> points); protected: QVector<QQuickEventPoint *> m_currentPoints; diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp index 67d32cdb18..3af77593e2 100644 --- a/src/quick/handlers/qquickpinchhandler.cpp +++ b/src/quick/handlers/qquickpinchhandler.cpp @@ -232,8 +232,8 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event) // Verify that least one of the points have moved beyond threshold needed to activate the handler for (QQuickEventPoint *point : qAsConst(m_currentPoints)) { if (QQuickWindowPrivate::dragOverThreshold(point)) { - grabPoints(m_currentPoints); - setActive(true); + if (grabPoints(m_currentPoints)) + setActive(true); break; } } |