aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-09-12 20:44:43 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-10-10 08:48:24 +0200
commit803151f460509332a1fc8142e1b7659a42f70690 (patch)
tree30ace294996bca3a28b5599e6211eaff73de23db /tests
parentda74e8fbb91b680d7783daa1595baa3ecc92cb2e (diff)
Handle "interesting" stationary touchpoints as if they moved
Qt Quick will not receive "uninteresting" stationary touchpoints, but only those in which some property has changed. So MultiPointTouchArea should react to stationary touchpoints in the same way as if they moved, so that UIs can react to changes in touchpoint velocity, pressure etc. And QQuickWindow has to be willing to delivery stationary touchpoints to make this possible. However when a QTouchEvent is customized for delivery to a specific Item, by including only the touchpoints that are inside the Item, then if those touchpoints are all stationary, the event only needs to be delivered if at least one of them is an "interesting" stationary touchpoint. So we need to depend on a new per-touchpoint flag that QGuiApplication will set when it discovers that some property of the touchpoint has changed. That is QTouchEventTouchPointPrivate::stationaryWithModifiedProperty. Fixes: QTBUG-77142 Change-Id: I763d56ff55c048b258dca40d88283ed016447c35 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit ae346195efaca5d01b67c5df1209512c7edaddb0) Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
index d4ad282701..9c19e8e522 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -72,6 +72,7 @@ private slots:
void mouseGestureStarted_data();
void mouseGestureStarted();
void cancel();
+ void stationaryTouchWithChangingPressure();
private:
QQuickView *createAndShowView(const QString &file);
@@ -1303,6 +1304,42 @@ void tst_QQuickMultiPointTouchArea::cancel()
}
+void tst_QQuickMultiPointTouchArea::stationaryTouchWithChangingPressure() // QTBUG-77142
+{
+ QScopedPointer<QQuickView> window(createAndShowView("basic.qml"));
+ QVERIFY(window->rootObject() != nullptr);
+
+ QQuickTouchPoint *point1 = window->rootObject()->findChild<QQuickTouchPoint*>("point1");
+ QCOMPARE(point1->pressed(), false);
+
+ QPoint p1(20,100);
+ QTouchEvent::TouchPoint tp1(1);
+
+ tp1.setScreenPos(window->mapToGlobal(p1));
+ tp1.setState(Qt::TouchPointPressed);
+ tp1.setPressure(0.5);
+ qt_handleTouchEvent(window.data(), device, {tp1});
+ QQuickTouchUtils::flush(window.data());
+
+ QCOMPARE(point1->pressed(), true);
+ QCOMPARE(point1->pressure(), 0.5);
+
+ tp1.setState(Qt::TouchPointStationary);
+ tp1.setPressure(0.6);
+ qt_handleTouchEvent(window.data(), device, {tp1});
+ QQuickTouchUtils::flush(window.data());
+
+ QCOMPARE(point1->pressure(), 0.6);
+
+ tp1.setState(Qt::TouchPointReleased);
+ tp1.setPressure(0);
+ qt_handleTouchEvent(window.data(), device, {tp1});
+ QQuickTouchUtils::flush(window.data());
+
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point1->pressure(), 0);
+}
+
QTEST_MAIN(tst_QQuickMultiPointTouchArea)