From 6e565768dd30bd3a489cea0dfd7715c93df62522 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 8 Jun 2009 14:00:24 +0200 Subject: set the start and last global positions when translating "raw" touch events this makes it possible to have a little code as possible feeding the raw events into Qt (and tests/auto/qtouchevent passes now too :P) --- src/gui/kernel/qapplication.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 00399fc..e5cf0b5 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -5305,7 +5305,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, QHash widgetsNeedingEvents; for (int i = 0; i < touchPoints.count(); ++i) { - const QTouchEvent::TouchPoint &touchPoint = touchPoints.at(i); + QTouchEvent::TouchPoint touchPoint = touchPoints.at(i); // update state QWidget *widget = 0; @@ -5328,21 +5328,30 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, widget = closestWidget; } d->widgetForTouchPointId[touchPoint.id()] = widget; + touchPoint.setStartGlobalPos(touchPoint.globalPos()); + touchPoint.setLastGlobalPos(touchPoint.globalPos()); d->appCurrentTouchPoints.insert(touchPoint.id(), touchPoint); break; } case Qt::TouchPointReleased: + { widget = d->widgetForTouchPointId.take(touchPoint.id()); if (!widget) continue; - d->appCurrentTouchPoints.remove(touchPoint.id()); + QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.take(touchPoint.id()); + touchPoint.setStartGlobalPos(previousTouchPoint.startGlobalPos()); + touchPoint.setLastGlobalPos(previousTouchPoint.globalPos()); break; + } default: widget = d->widgetForTouchPointId.value(touchPoint.id()); if (!widget) continue; Q_ASSERT(d->appCurrentTouchPoints.contains(touchPoint.id())); + QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.value(touchPoint.id()); + touchPoint.setStartGlobalPos(previousTouchPoint.startGlobalPos()); + touchPoint.setLastGlobalPos(previousTouchPoint.globalPos()); d->appCurrentTouchPoints[touchPoint.id()] = touchPoint; break; } -- cgit v0.12