diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-09-16 22:22:24 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-09-24 23:09:23 +0200 |
commit | 05dc0a387ae324f2d6f3d7e633a0a49473f6957a (patch) | |
tree | 6bdfeaa2e700fdab6c5091993928fbf45419eb25 | |
parent | 8e3f40f8c62e94ef475f1c48d8f14df725b78a79 (diff) |
Get rid of QMutableEventPoint::stationaryWithModifiedProperty
Omitting stationary points from touch events is such a marginal
optimization that this code probably isn't worth maintaining.
It wasn't implemented correctly this time either, according to the
tst_QQuickMultiPointTouchArea::stationaryTouchWithChangingPressure()
test.
Task-number: QTBUG-77142
Change-Id: I1ccc8ffe0451d6417add2b03c063ac1aebe36e8e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r-- | src/quick/items/qquickitem.cpp | 6 | ||||
-rw-r--r-- | src/quick/items/qquickmultipointtoucharea.cpp | 4 | ||||
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 13 |
3 files changed, 10 insertions, 13 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 8e6bb0f224..de43f2fb7d 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -8382,7 +8382,6 @@ QTouchEvent QQuickItemPrivate::localizedTouchEvent(const QTouchEvent *event, boo QEventPoint::States eventStates; bool anyPressOrReleaseInside = false; - bool anyStationaryWithModifiedPropertyInside = false; bool anyGrabber = false; for (auto &p : event->points()) { if (p.isAccepted()) @@ -8415,8 +8414,6 @@ QTouchEvent QQuickItemPrivate::localizedTouchEvent(const QTouchEvent *event, boo anyPressOrReleaseInside = true; QEventPoint pCopy(p); QMutableEventPoint mut = QMutableEventPoint::from(pCopy); - if (isInside && mut.stationaryWithModifiedProperty()) - anyStationaryWithModifiedPropertyInside = true; eventStates |= p.state(); mut.setPosition(localPos); touchPoints << mut; @@ -8424,8 +8421,7 @@ QTouchEvent QQuickItemPrivate::localizedTouchEvent(const QTouchEvent *event, boo // Now touchPoints will have only points which are inside the item. // But if none of them were just pressed inside, and the item has no other reason to care, ignore them anyway. - if ((eventStates == QEventPoint::State::Stationary && !anyStationaryWithModifiedPropertyInside) || - touchPoints.isEmpty() || (!anyPressOrReleaseInside && !anyGrabber && !isFiltering)) + if (touchPoints.isEmpty() || (!anyPressOrReleaseInside && !anyGrabber && !isFiltering)) return QTouchEvent(QEvent::None); // if all points have the same state, set the event type accordingly diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp index 37fc928aee..23cf6c0351 100644 --- a/src/quick/items/qquickmultipointtoucharea.cpp +++ b/src/quick/items/qquickmultipointtoucharea.cpp @@ -638,8 +638,8 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event) addTouchPoint(&p); started = true; } else if ((touchPointState & QEventPoint::State::Updated) || - QMutableEventPoint::from(p).stationaryWithModifiedProperty()) { - // React to a stationary point with a property change (velocity, pressure) as if the point moved. (QTBUG-77142) + (touchPointState & QEventPoint::State::Stationary)) { + // React to a stationary point as if the point moved. (QTBUG-77142) QQuickTouchPoint* dtp = static_cast<QQuickTouchPoint*>(_touchPoints.value(id)); Q_ASSERT(dtp); _movedTouchPoints.append(dtp); diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index dd95ab1808..43dfcdb8a4 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -705,10 +705,10 @@ void tst_qquickwindow::touchEvent_basic() touchSeq.stationary(0) .press(1, bottomItem->mapToScene(pos).toPoint(), window).commit(); QQuickTouchUtils::flush(window); - QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); // received press only, not stationary + QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); // received press and then stationary QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); - COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, QEventPoint::State::Pressed, makeTouchPoint(topItem, pos))); + COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchUpdate, window, QEventPoint::State::Stationary, makeTouchPoint(topItem, pos))); COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, QEventPoint::State::Pressed, makeTouchPoint(bottomItem, pos))); topItem->reset(); bottomItem->reset(); @@ -729,10 +729,10 @@ void tst_qquickwindow::touchEvent_basic() topItem->reset(); // release while another point is pressed - touchSeq.press(0, topItem->mapToScene(pos).toPoint(),window) - .press(1, bottomItem->mapToScene(pos).toPoint(), window).commit(); + touchSeq.press(0, topItem->mapToScene(pos).toPoint(),window) // seen and grabbed by topItem + .press(1, bottomItem->mapToScene(pos).toPoint(), window).commit(); // seen and grabbed by bottomItem QQuickTouchUtils::flush(window); - touchSeq.move(0, bottomItem->mapToScene(pos).toPoint(), window).commit(); + touchSeq.move(0, bottomItem->mapToScene(pos).toPoint(), window).stationary(1).commit(); QQuickTouchUtils::flush(window); touchSeq.release(0, bottomItem->mapToScene(pos).toPoint(), window) .stationary(1).commit(); @@ -745,7 +745,8 @@ void tst_qquickwindow::touchEvent_basic() // it's the last position that was actually different. COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, window, QEventPoint::State::Released, makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos))); - COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, QEventPoint::State::Pressed, makeTouchPoint(bottomItem, pos))); + COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchUpdate, window, QEventPoint::State::Stationary, + makeTouchPoint(bottomItem, pos))); topItem->reset(); bottomItem->reset(); |