aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickwindow.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-03-31 13:11:09 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-04-27 12:34:01 +0000
commit822e39df38b20763d2933d7a6d2d6ddf7b9b2639 (patch)
tree414593f26da336abfff57ac4c0a0213bdfc0dd0c /src/quick/items/qquickwindow.cpp
parent926d69a61c50bf970c0f6cc5dddf735e996f502e (diff)
Start over with event delivery when touchpoint presses occur
It was part of the intended design for pointer handlers; omitting this feature has until now prevented some opportunities for handoff from one handler to another. Now if PinchHandler has grabbed, pressing one more point will let something else have a chance again, for example. But this is incomplete in that if we release a point, we should do the same thing, actually. Change-Id: I10f567e7e4388bf0caab54c261178f19db20b14a Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r--src/quick/items/qquickwindow.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 359763bfb4..9c9764005d 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -754,6 +754,9 @@ void QQuickWindowPrivate::setMouseGrabber(QQuickItem *grabber)
qCDebug(DBG_TOUCH_TARGET) << "TP (mouse)" << hex << touchMouseId << "->" << q->mouseGrabberItem();
auto point = touchMouseDevice->pointerEvent()->pointById(touchMouseId);
if (point) {
+ auto originalEvent = point->pointerEvent()->device()->pointerEvent();
+ for (int i = 0; i < originalEvent->pointCount(); ++i)
+ originalEvent->point(i)->cancelExclusiveGrab();
point->setGrabberItem(grabber);
for (auto handler : point->passiveGrabbers())
point->cancelPassiveGrab(handler);
@@ -2362,11 +2365,13 @@ void QQuickWindowPrivate::deliverUpdatedTouchPoints(QQuickPointerTouchEvent *eve
// Deliver newly pressed touch points
bool QQuickWindowPrivate::deliverPressEvent(QQuickPointerEvent *event)
{
- const QVector<QPointF> points = event->unacceptedPressedPointScenePositions();
+ int pointCount = event->pointCount();
QVector<QQuickItem *> targetItems;
bool isTouchEvent = (event->asPointerTouchEvent() != nullptr);
- for (QPointF point: points) {
- QVector<QQuickItem *> targetItemsForPoint = pointerTargets(contentItem, point, !isTouchEvent, isTouchEvent);
+ for (int i = 0; i < pointCount; ++i) {
+ auto point = event->point(i);
+ point->setAccepted(false); // because otherwise touchEventForItem will ignore it
+ QVector<QQuickItem *> targetItemsForPoint = pointerTargets(contentItem, point->scenePos(), !isTouchEvent, isTouchEvent);
if (targetItems.count()) {
targetItems = mergePointerTargets(targetItems, targetItemsForPoint);
} else {
@@ -2458,10 +2463,11 @@ void QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QQuickPo
if (eventAccepted) {
// If the touch was accepted (regardless by whom or in what form),
// update accepted new points.
+ bool isPress = pointerEvent->isPressEvent();
for (auto point: qAsConst(touchEvent->touchPoints())) {
auto pointerEventPoint = ptEvent->pointById(point.id());
pointerEventPoint->setAccepted();
- if (point.state() == Qt::TouchPointPressed)
+ if (isPress)
pointerEventPoint->setGrabberItem(item);
}
} else {