diff options
author | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2017-03-14 10:33:14 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2017-03-16 12:30:30 +0000 |
commit | c2ca2cbf04071ffb3aee6af8d5ab9084dfa1c091 (patch) | |
tree | f7043644d7da341d3162cf80d91f46dc208393c5 /src/quick/items | |
parent | 8675bb6b5a4721aa4d94dcb3cb98dbed061c164f (diff) |
Fix touch event delivery in childMouseEventFilter
Since moving to pointer events, we would deliver all events inside the
filter function. The expected behavior though is that only points that
are already grabbed, pressed inside or grabbed by children would be seen
by the filter function.
This broke using multiple touch aware items at the same time (2 pinch
areas for example).
Change-Id: I42a430f196ebbcf0a83a6dc8aca319e433ad52ad
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items')
-rw-r--r-- | src/quick/items/qquickevents.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 70d95ccdf8..68f6dbcfa5 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -846,9 +846,24 @@ QTouchEvent *QQuickPointerTouchEvent::touchEventForItem(QQuickItem *item, bool i auto p = m_touchPoints.at(i); if (p->isAccepted()) continue; + // include points where item is the grabber bool isGrabber = p->grabber() == item; + // include newly pressed points inside the bounds bool isPressInside = p->state() == QQuickEventPoint::Pressed && item->contains(item->mapFromScene(p->scenePos())); - if (!(isGrabber || isPressInside || isFiltering)) + + // filtering: (childMouseEventFilter) include points that are grabbed by children of the target item + bool grabberIsChild = false; + auto parent = p->grabber(); + while (isFiltering && parent) { + if (parent == item) { + grabberIsChild = true; + break; + } + parent = parent->parentItem(); + } + bool filterRelevant = isFiltering && grabberIsChild; + + if (!(isGrabber || isPressInside || filterRelevant)) continue; const QTouchEvent::TouchPoint *tp = touchPointById(p->pointId()); |