From a98652cfc22d37e49a09cb36afbd340f535da9a5 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 6 Jan 2017 13:59:13 +0000 Subject: 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 --- src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp') 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(0, filteredNormalizedX, 1), + qBound(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::const_iterator it = m_filteredPoints.constBegin(), end = m_filteredPoints.constEnd(); it != end; ++it) { -- cgit v1.2.3