aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-28 01:00:07 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-04-29 09:12:31 +0200
commit23f988fe48f3f3c63e8311c31ed09394702089d2 (patch)
treefeba876785ad8c7404b44bc3e6e12e0837cf902c /src/quick
parent3ef2b2727df42510512669ec879788d41d83cebb (diff)
parent332e514fb4954fde9af03e1699c066cbbdb0420d (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts: src/qml/compiler/qv4compilercontext.cpp src/qml/qml/qqmlmetatype.cpp Change-Id: I02e0216961b92ff68a3f91a70edc33fe9e8db147
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/handlers/qquickmultipointhandler.cpp13
-rw-r--r--src/quick/items/qquickevents.cpp38
2 files changed, 23 insertions, 28 deletions
diff --git a/src/quick/handlers/qquickmultipointhandler.cpp b/src/quick/handlers/qquickmultipointhandler.cpp
index 5c10ecce75..0afc9997aa 100644
--- a/src/quick/handlers/qquickmultipointhandler.cpp
+++ b/src/quick/handlers/qquickmultipointhandler.cpp
@@ -70,14 +70,15 @@ bool QQuickMultiPointHandler::wantsPointerEvent(QQuickPointerEvent *event)
if (!QQuickPointerDeviceHandler::wantsPointerEvent(event))
return false;
-#if QT_CONFIG(gestures)
- if (event->asPointerNativeGestureEvent())
- return true;
-#endif
-
if (event->asPointerScrollEvent())
return false;
+ bool ret = false;
+#if QT_CONFIG(gestures)
+ if (event->asPointerNativeGestureEvent() && event->point(0)->state() != QQuickEventPoint::Released)
+ ret = true;
+#endif
+
// If points were pressed or released within parentItem, reset stored state
// and check eligible points again. This class of handlers is intended to
// handle a specific number of points, so a differing number of points will
@@ -97,7 +98,7 @@ bool QQuickMultiPointHandler::wantsPointerEvent(QQuickPointerEvent *event)
return true;
}
- const bool ret = (candidatePoints.size() >= minimumPointCount() && candidatePoints.size() <= maximumPointCount());
+ ret = ret || (candidatePoints.size() >= minimumPointCount() && candidatePoints.size() <= maximumPointCount());
if (ret) {
const int c = candidatePoints.count();
d->currentPoints.resize(c);
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index c43eab6b8a..28b217b7b3 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -1135,10 +1135,10 @@ void QQuickEventTouchPoint::reset(const QTouchEvent::TouchPoint &tp, ulong times
struct PointVelocityData {
QVector2D velocity;
QPointF pos;
- ulong timestamp;
+ ulong timestamp = 0;
};
-typedef QMap<quint64, PointVelocityData*> PointDataForPointIdMap;
+typedef QMap<quint64, PointVelocityData> PointDataForPointIdMap;
Q_GLOBAL_STATIC(PointDataForPointIdMap, g_previousPointData)
static const int PointVelocityAgeLimit = 500; // milliseconds
@@ -1149,42 +1149,36 @@ static const int PointVelocityAgeLimit = 500; // milliseconds
*/
QVector2D QQuickEventPoint::estimatedVelocity() const
{
- PointVelocityData *prevPoint = g_previousPointData->value(m_pointId);
- if (!prevPoint) {
+ auto prevPointIt = g_previousPointData->find(m_pointId);
+ auto end = g_previousPointData->end();
+ if (prevPointIt == end) {
// cleanup events older than PointVelocityAgeLimit
- auto end = g_previousPointData->end();
for (auto it = g_previousPointData->begin(); it != end; ) {
- PointVelocityData *data = it.value();
- if (m_timestamp - data->timestamp > PointVelocityAgeLimit) {
+ if (m_timestamp - it->timestamp > PointVelocityAgeLimit)
it = g_previousPointData->erase(it);
- delete data;
- } else {
+ else
++it;
- }
}
- // TODO optimize: stop this dynamic memory thrashing
- prevPoint = new PointVelocityData;
- prevPoint->velocity = QVector2D();
- prevPoint->timestamp = 0;
- prevPoint->pos = QPointF();
- g_previousPointData->insert(m_pointId, prevPoint);
+ prevPointIt = g_previousPointData->insert(m_pointId, PointVelocityData());
}
- const ulong timeElapsed = m_timestamp - prevPoint->timestamp;
+
+ auto &prevPoint = prevPointIt.value();
+ const ulong timeElapsed = m_timestamp - prevPoint.timestamp;
if (timeElapsed == 0) // in case we call estimatedVelocity() twice on the same QQuickEventPoint
return m_velocity;
QVector2D newVelocity;
- if (prevPoint->timestamp != 0)
- newVelocity = QVector2D(m_scenePos - prevPoint->pos)/timeElapsed;
+ if (prevPoint.timestamp != 0)
+ newVelocity = QVector2D(m_scenePos - prevPoint.pos) / timeElapsed;
// VERY simple kalman filter: does a weighted average
// where the older velocities get less and less significant
static const float KalmanGain = 0.7f;
QVector2D filteredVelocity = newVelocity * KalmanGain + m_velocity * (1.0f - KalmanGain);
- prevPoint->velocity = filteredVelocity;
- prevPoint->pos = m_scenePos;
- prevPoint->timestamp = m_timestamp;
+ prevPoint.velocity = filteredVelocity;
+ prevPoint.pos = m_scenePos;
+ prevPoint.timestamp = m_timestamp;
return filteredVelocity;
}