summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qapplication_win.cpp
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-05-28 07:57:36 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-05-28 07:57:36 (GMT)
commit9667870db5b929c76656f3a4235b9539a1d5de5b (patch)
treeb6b74e837b9f26f113036075fdd9077ab0ff9996 /src/gui/kernel/qapplication_win.cpp
parent2101aa8e9ec65864878b027d66d069542da8677f (diff)
downloadQt-9667870db5b929c76656f3a4235b9539a1d5de5b.zip
Qt-9667870db5b929c76656f3a4235b9539a1d5de5b.tar.gz
Qt-9667870db5b929c76656f3a4235b9539a1d5de5b.tar.bz2
Don't try to maintain a current and active list of points for the app and widgets/items
Instead, build the list of touchPoints per event. This solves the problem when encountering releases early in the active/current list while there are still touch points in move/stationary states (which effectively caused the code to "forget" about the released point).
Diffstat (limited to 'src/gui/kernel/qapplication_win.cpp')
-rw-r--r--src/gui/kernel/qapplication_win.cpp62
1 files changed, 14 insertions, 48 deletions
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 0fc76ae..f980f8e 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -3989,19 +3989,17 @@ void QApplicationPrivate::initializeMultitouch()
CloseTouchInputHandle = static_cast<qt_CloseTouchInputHandlePtr>(library.resolve("CloseTouchInputHandle"));
widgetForTouchPointId.clear();
- widgetCurrentTouchPoints.clear();
touchInputIDToTouchPointID.clear();
appAllTouchPoints.clear();
appCurrentTouchPoints.clear();
}
-QTouchEvent::TouchPoint *QApplicationPrivate::findClosestTouchPoint(const QList<QTouchEvent::TouchPoint *> &appActiveTouchPoints,
- const QPointF &screenPos)
+QTouchEvent::TouchPoint *QApplicationPrivate::findClosestTouchPoint(const QPointF &screenPos)
{
QTouchEvent::TouchPoint *closestTouchPoint = 0;
qreal closestDistance;
- for (int i = 0; i < appActiveTouchPoints.count(); ++i) {
- QTouchEvent::TouchPoint *touchPoint = appActiveTouchPoints.at(i);
+ for (int i = 0; i < appCurrentTouchPoints.count(); ++i) {
+ QTouchEvent::TouchPoint *touchPoint = appCurrentTouchPoints.at(i);
qreal distance = QLineF(screenPos, touchPoint->screenPos()).length();
if (!closestTouchPoint || distance < closestDistance) {
closestTouchPoint = touchPoint;
@@ -4011,22 +4009,15 @@ QTouchEvent::TouchPoint *QApplicationPrivate::findClosestTouchPoint(const QList<
return closestTouchPoint;
}
-void QApplicationPrivate::appendTouchPoint(QTouchEvent::TouchPoint *touchPoint,
- QList<QTouchEvent::TouchPoint *> *currentTouchPoints)
-{
- // insort touch point (for the app)
+void QApplicationPrivate::appendTouchPoint(QTouchEvent::TouchPoint *touchPoint)
+{
+ // insort touch point
int at = 0;
for (; at < appCurrentTouchPoints.count(); ++at) {
if (appCurrentTouchPoints.at(at)->id() > touchPoint->id())
break;
}
appCurrentTouchPoints.insert(at, touchPoint);
- // again, for the widget's currentTouchPoints
- for (at = 0; at < currentTouchPoints->count(); ++at) {
- if (currentTouchPoints->at(at)->id() > touchPoint->id())
- break;
- }
- currentTouchPoints->insert(at, touchPoint);
if (appCurrentTouchPoints.count() > appAllTouchPoints.count()) {
qFatal("Qt: INTERNAL ERROR: appCurrentTouchPoints.count() (%d) > appAllTouchPoints.count() (%d)",
@@ -4035,8 +4026,7 @@ void QApplicationPrivate::appendTouchPoint(QTouchEvent::TouchPoint *touchPoint,
}
}
-void QApplicationPrivate::removeTouchPoint(QTouchEvent::TouchPoint *touchPoint,
- QList<QTouchEvent::TouchPoint *> *currentTouchPoints)
+void QApplicationPrivate::removeTouchPoint(QTouchEvent::TouchPoint *touchPoint)
{
// remove touch point from all known touch points
for (int i = qMin(appCurrentTouchPoints.count() - 1, touchPoint->id()); i >= 0; --i) {
@@ -4045,13 +4035,6 @@ void QApplicationPrivate::removeTouchPoint(QTouchEvent::TouchPoint *touchPoint,
break;
}
}
- // again, for the widget's currentTouchPoints
- for (int i = qMin(currentTouchPoints->count() - 1, touchPoint->id()); i >= 0; --i) {
- if (currentTouchPoints->at(i) == touchPoint) {
- currentTouchPoints->removeAt(i);
- break;
- }
- }
}
bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
@@ -4062,10 +4045,9 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
if (!widgetForHwnd)
return false;
- QList<QTouchEvent::TouchPoint *> appActiveTouchPoints = appCurrentTouchPoints;
-
typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint *> > StatesAndTouchPoints;
QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
+
QVector<TOUCHINPUT> winTouchInputs(msg.wParam);
memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * winTouchInputs.count());
QApplicationPrivate::GetTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT));
@@ -4090,14 +4072,13 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
bool down = touchPoint->state() != Qt::TouchPointReleased;
QPointF screenPos(qreal(touchInput.x) / qreal(100.), qreal(touchInput.y) / qreal(100.));
- QList<QTouchEvent::TouchPoint *> activeTouchPoints;
if (!down && (touchInput.dwFlags & TOUCHEVENTF_DOWN)) {
// determine which widget this event will go to
widget = widgetForHwnd->childAt(widgetForHwnd->mapFromGlobal(screenPos.toPoint()));
if (!widget)
widget = widgetForHwnd;
- QTouchEvent::TouchPoint *closestTouchPoint = findClosestTouchPoint(appActiveTouchPoints, screenPos);
+ QTouchEvent::TouchPoint *closestTouchPoint = findClosestTouchPoint(screenPos);
if (closestTouchPoint) {
QWidget *closestWidget = widgetForTouchPointId.value(closestTouchPoint->id());
if (closestWidget
@@ -4107,11 +4088,7 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
}
widgetForTouchPointId[touchPoint->id()] = widget;
- QList<QTouchEvent::TouchPoint *> &currentTouchPoints = widgetCurrentTouchPoints[widget];
- appendTouchPoint(touchPoint, &currentTouchPoints);
- // make sure new points are added to activeTouchPoints as well
- appActiveTouchPoints = appCurrentTouchPoints;
- activeTouchPoints = currentTouchPoints;
+ appendTouchPoint(touchPoint);
touchPoint->setState(Qt::TouchPointPressed);
touchPoint->setScreenPos(screenPos);
@@ -4120,10 +4097,8 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
touchPoint->setPressure(qreal(1.));
} else if (down && (touchInput.dwFlags & TOUCHEVENTF_UP)) {
widget = widgetForTouchPointId.take(touchPoint->id());
- QList<QTouchEvent::TouchPoint *> &currentTouchPoints = widgetCurrentTouchPoints[widget];
- appActiveTouchPoints = appCurrentTouchPoints;
- activeTouchPoints = currentTouchPoints;
- removeTouchPoint(touchPoint, &currentTouchPoints);
+
+ removeTouchPoint(touchPoint);
touchPoint->setState(Qt::TouchPointReleased);
touchPoint->setLastScreenPos(touchPoint->screenPos());
@@ -4131,8 +4106,7 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
touchPoint->setPressure(qreal(0.));
} else if (down) {
widget = widgetForTouchPointId.value(touchPoint->id());
- appActiveTouchPoints = appCurrentTouchPoints;
- activeTouchPoints = widgetCurrentTouchPoints.value(widget);
+
touchPoint->setState(screenPos == touchPoint->screenPos()
? Qt::TouchPointStationary
: Qt::TouchPointMoved);
@@ -4144,7 +4118,7 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget];
maskAndPoints.first |= touchPoint->state();
- maskAndPoints.second = activeTouchPoints;
+ maskAndPoints.second.append(touchPoint);
}
QApplicationPrivate::CloseTouchInputHandle((HANDLE) msg.lParam);
@@ -4194,14 +4168,6 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
returnValue = returnValue || (qt_tabletChokeMouse = qt_tabletChokeMouse || res);
break;
}
- case QEvent::TouchEnd:
- {
- QList<QTouchEvent::TouchPoint *> currentTouchPoints = widgetCurrentTouchPoints.take(widget);
- if (!currentTouchPoints.isEmpty()) {
- qFatal("Qt: INTERNAL ERROR, the widget's currentTouchPoints should be empty!");
- }
- // fall-through intended
- }
default:
if (widget->testAttribute(Qt::WA_AcceptedTouchBeginEvent)) {
(void) QApplication::sendSpontaneousEvent(widget, &touchEvent);