summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsmousehandler.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@digia.com>2012-11-27 10:11:30 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-27 16:18:19 +0100
commite9a8b026f51d77ccb014c9e8011b081d4100aad4 (patch)
treec500dc708ecf4259a33c72a236b80adbcbc9c026 /src/plugins/platforms/windows/qwindowsmousehandler.cpp
parenta7ac89353455cf05d11636400aee532de62a7427 (diff)
Fix touch event handling for Windows
Filtering touch events depending on Qt::WA_AcceptTouchEvents is not trivial. I thought about doing so in QWidgetWindow::handleTouchEvent but the target widget (not window), which has to be checked, has to be obtained using the primary touch event's position etc. Thus that is not part of this commit and will be done in a followup. Change-Id: I876ee72acd7fdfbe46da61c6eb3c5891ea319cd8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsmousehandler.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index d202da1d31..357def57c8 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -395,34 +395,40 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
QWindowsContext::user32dll.getTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT));
for (int i = 0; i < winTouchPointCount; ++i) {
const TOUCHINPUT &winTouchInput = winTouchInputs[i];
+ int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1);
+ if (id == -1) {
+ id = m_touchInputIDToTouchPointID.size();
+ m_touchInputIDToTouchPointID.insert(winTouchInput.dwID, id);
+ }
QTouchPoint touchPoint;
touchPoint.pressure = 1.0;
- touchPoint.id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1);
- if (touchPoint.id == -1) {
- touchPoint.id = m_touchInputIDToTouchPointID.size();
- m_touchInputIDToTouchPointID.insert(winTouchInput.dwID, touchPoint.id);
- }
+ touchPoint.id = id;
+ if (m_lastTouchPositions.contains(id))
+ touchPoint.normalPosition = m_lastTouchPositions.value(id);
QPointF screenPos = QPointF(qreal(winTouchInput.x) / qreal(100.), qreal(winTouchInput.y) / qreal(100.));
if (winTouchInput.dwMask & TOUCHINPUTMASKF_CONTACTAREA)
touchPoint.area.setSize(QSizeF(qreal(winTouchInput.cxContact) / qreal(100.),
qreal(winTouchInput.cyContact) / qreal(100.)));
touchPoint.area.moveCenter(screenPos);
+ QPointF normalPosition = QPointF(screenPos.x() / screenGeometry.width(),
+ screenPos.y() / screenGeometry.height());
+ const bool stationaryTouchPoint = (normalPosition == touchPoint.normalPosition);
+ touchPoint.normalPosition = normalPosition;
if (winTouchInput.dwFlags & TOUCHEVENTF_DOWN) {
touchPoint.state = Qt::TouchPointPressed;
+ m_lastTouchPositions.insert(id, touchPoint.normalPosition);
} else if (winTouchInput.dwFlags & TOUCHEVENTF_UP) {
touchPoint.state = Qt::TouchPointReleased;
+ m_lastTouchPositions.remove(id);
} else {
- // TODO: Previous code checked"
- // screenPos == touchPoint.normalPosition -> Qt::TouchPointStationary, but
- // but touchPoint.normalPosition was never initialized?
- touchPoint.state = touchPoint.state;
+ touchPoint.state = (stationaryTouchPoint
+ ? Qt::TouchPointStationary
+ : Qt::TouchPointMoved);
+ m_lastTouchPositions.insert(id, touchPoint.normalPosition);
}
- touchPoint.normalPosition = QPointF(screenPos.x() / screenGeometry.width(),
- screenPos.y() / screenGeometry.height());
-
allStates |= touchPoint.state;
touchPoints.append(touchPoint);