aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-05-11 15:10:40 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-05-12 18:27:12 +0200
commitdd53f68d7b899d7d5b566f97fda1268cf8136152 (patch)
tree3e52992aeeb75414db027622f3c93870fa3e3b85
parent1fa382485e6fd231acd367c5037e3a0cc6d99f3d (diff)
Don't add the same point twice when splitting touch events by subscene
A point might have an exclusive grabber and multiple passive grabbers. It could be that different grabbers are in different subscenes; but in the case that there is both a passive and an exclusive grabber in one subscene, QQuickWindow::event() calls the inline insert() function multiple times with the same point and same DeliveryAgent, but we must not add it to the QList more than once. (It could even be a QSet instead of a QList, but that might not be optimal, and would disrupt the order of EventPoints FWIW... not that we normally guarantee order. And afterwards we pass the QList to the QMutableTouchEvent ctor taking QList<QEventPoint>, so it's just as well to have it built already.) This helps to fix the tst_Input::dualTouchTap2D test in Qt Quick 3D: if you press one finger on a MouseArea in the left subscene and one on an MA in the right subscene, and then release, we do not want to give two copies of the left eventpoint to the left subscene, because then QQuickDeliveryAgentPrivate::deliverPointerEvent() will actually store into originalScenePositions a copy of the scene position that has already been through the sceneTransform->map(), and restore it afterwards. That results in the synth-mouse event getting the wrong position, and the test fails because the press and release positions don't match. Amends 5c08e911375966761ee8e4d7cd425120985876e2 Change-Id: I856b676b5c66b59ed20c4a5e395e6e66478438da Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 82bf2eeb341ecc6b252e7a575bed8bf4bd329e96)
-rw-r--r--src/quick/items/qquickwindow.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 6d602a3810..c3fd4560d2 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -1370,7 +1370,12 @@ bool QQuickWindow::event(QEvent *e)
if (danpit == deliveryAgentsNeedingPoints.end()) {
deliveryAgentsNeedingPoints.insert(ptda, QList<QEventPoint>() << pt);
} else {
- danpit.value().append(pt);
+ auto &ptList = danpit.value();
+ auto ptid = pt.id();
+ auto alreadyThere = std::find_if(ptList.constBegin(), ptList.constEnd(),
+ [ptid] (const QEventPoint &pep) { return pep.id() == ptid; });
+ if (alreadyThere == ptList.constEnd())
+ danpit.value().append(pt);
}
};