diff options
author | Gunnar Sletta <gunnar@sletta.org> | 2017-01-06 13:59:13 +0000 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2017-01-09 06:13:21 +0000 |
commit | a98652cfc22d37e49a09cb36afbd340f535da9a5 (patch) | |
tree | 53723a0abbcbb683403fbd5da9003aede2a9971e /src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp | |
parent | 3f455a4b53254b3ebbafae91600a63caebee3e0e (diff) |
A few fixes to evdev touch filtering
- Clamp the position to the bounding rect of the device
- Send TouchRelease only once
Change-Id: I8776079dbc886612e6adfb1fef5ec7cf14a8af3b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp')
-rw-r--r-- | src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index c515e663c8..11f7311bb7 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -920,8 +920,12 @@ void QEvdevTouchScreenHandlerThread::filterAndSendTouchPoints() tp.velocity = QVector2D(f.x.velocity() * winRect.width(), f.y.velocity() * winRect.height()); - tp.normalPosition = QPointF(f.x.position() + f.x.velocity() * m_handler->d->m_prediction / 1000.0, - f.y.position() + f.y.velocity() * m_handler->d->m_prediction / 1000.0); + qreal filteredNormalizedX = f.x.position() + f.x.velocity() * m_handler->d->m_prediction / 1000.0; + qreal filteredNormalizedY = f.y.position() + f.y.velocity() * m_handler->d->m_prediction / 1000.0; + + // Clamp to the screen + tp.normalPosition = QPointF(qBound<qreal>(0, filteredNormalizedX, 1), + qBound<qreal>(0, filteredNormalizedY, 1)); qreal x = winRect.x() + (tp.normalPosition.x() * (winRect.width() - 1)); qreal y = winRect.y() + (tp.normalPosition.y() * (winRect.height() - 1)); @@ -931,7 +935,10 @@ void QEvdevTouchScreenHandlerThread::filterAndSendTouchPoints() // Store the touch point for later so we can release it if we've // missed the actual release between our last update and this. f.touchPoint = tp; - filteredPoints[tp.id] = f; + + // Don't store the point for future reference if it is a release. + if (tp.state != Qt::TouchPointReleased) + filteredPoints[tp.id] = f; } for (QHash<int, FilteredTouchPoint>::const_iterator it = m_filteredPoints.constBegin(), end = m_filteredPoints.constEnd(); it != end; ++it) { |