From 072dd3efbe278fca0253a3e8d0e3cb52320b7a5b Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 19 Jun 2009 14:20:53 +0200 Subject: Handle the case where TOUCHINPUT id numbers are not reused As documented in the Windows 7 SDK RC, the id's may not be reused. We don't want the touchInputIDToTouchPointID hash to grow indefinitely, so clear it each time we detect that all touch points have been released. --- src/gui/kernel/qapplication_win.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 66dfee2..f8b1cbb 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -4027,6 +4027,7 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg) QVector winTouchInputs(msg.wParam); memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * winTouchInputs.count()); + Qt::TouchPointStates allStates = 0; QApplicationPrivate::GetTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT)); for (int i = 0; i < winTouchInputs.count(); ++i) { const TOUCHINPUT &touchInput = winTouchInputs.at(i); @@ -4062,10 +4063,17 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg) touchPoint.setState(state); touchPoint.setScreenRect(screenRect); + allStates |= state; + touchPoints.append(touchPoint); } QApplicationPrivate::CloseTouchInputHandle((HANDLE) msg.lParam); + if ((allStates & Qt::TouchPointStateMask) == Qt::TouchPointReleased) { + // all touch points released, forget the ids we've seen, they may not be reused + touchInputIDToTouchPointID.clear(); + } + translateRawTouchEvent(widgetForHwnd, touchPoints); return true; } -- cgit v0.12