wasm: fix multitouch processing

Not all touch points are changed as per emscripten event, so we
do not need to remove or add them to the touch event

Fixes: QTBUG-110941
Pick-to: 6.5
Change-Id: I4799ef0c05750a36361836698eb83e5bf844ece8
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
This commit is contained in:
Lorn Potter 2023-02-08 14:39:17 +10:00
parent 230bc059ae
commit 56068f3a36

View File

@ -286,12 +286,15 @@ bool QWasmCompositor::processTouch(int eventType, const EmscriptenTouchEvent *to
touchPointList.reserve(touchEvent->numTouches); touchPointList.reserve(touchEvent->numTouches);
QWindow *targetWindow = nullptr; QWindow *targetWindow = nullptr;
qWarning() << Q_FUNC_INFO << "number emTouchPoint:" << touchEvent->numTouches;
for (int i = 0; i < touchEvent->numTouches; i++) { for (int i = 0; i < touchEvent->numTouches; i++) {
const EmscriptenTouchPoint *touches = &touchEvent->touches[i]; const EmscriptenTouchPoint *emTouchPoint = &touchEvent->touches[i];
QPoint targetPointInScreenCoords = QPoint targetPointInScreenCoords =
screen()->mapFromLocal(QPoint(touches->targetX, touches->targetY)); screen()->mapFromLocal(QPoint(emTouchPoint->targetX, emTouchPoint->targetY));
targetWindow = screen()->compositor()->windowAt(targetPointInScreenCoords, 5); targetWindow = screen()->compositor()->windowAt(targetPointInScreenCoords, 5);
if (targetWindow == nullptr) if (targetWindow == nullptr)
@ -300,7 +303,7 @@ bool QWasmCompositor::processTouch(int eventType, const EmscriptenTouchEvent *to
QWindowSystemInterface::TouchPoint touchPoint; QWindowSystemInterface::TouchPoint touchPoint;
touchPoint.area = QRect(0, 0, 8, 8); touchPoint.area = QRect(0, 0, 8, 8);
touchPoint.id = touches->identifier; touchPoint.id = emTouchPoint->identifier;
touchPoint.pressure = 1.0; touchPoint.pressure = 1.0;
touchPoint.area.moveCenter(targetPointInScreenCoords); touchPoint.area.moveCenter(targetPointInScreenCoords);
@ -318,26 +321,31 @@ bool QWasmCompositor::processTouch(int eventType, const EmscriptenTouchEvent *to
switch (eventType) { switch (eventType) {
case EMSCRIPTEN_EVENT_TOUCHSTART: case EMSCRIPTEN_EVENT_TOUCHSTART:
if (tp != m_pressedTouchIds.constEnd()) { if (emTouchPoint->isChanged) {
touchPoint.state = (stationaryTouchPoint if (tp != m_pressedTouchIds.constEnd()) {
? QEventPoint::State::Stationary touchPoint.state = (stationaryTouchPoint
: QEventPoint::State::Updated); ? QEventPoint::State::Stationary
} else { : QEventPoint::State::Updated);
touchPoint.state = QEventPoint::State::Pressed; } else {
touchPoint.state = QEventPoint::State::Pressed;
}
m_pressedTouchIds.insert(touchPoint.id, touchPoint.normalPosition);
} }
m_pressedTouchIds.insert(touchPoint.id, touchPoint.normalPosition); break;
break;
case EMSCRIPTEN_EVENT_TOUCHEND: case EMSCRIPTEN_EVENT_TOUCHEND:
touchPoint.state = QEventPoint::State::Released; if (emTouchPoint->isChanged) {
m_pressedTouchIds.remove(touchPoint.id); touchPoint.state = QEventPoint::State::Released;
m_pressedTouchIds.remove(touchPoint.id);
}
break; break;
case EMSCRIPTEN_EVENT_TOUCHMOVE: case EMSCRIPTEN_EVENT_TOUCHMOVE:
touchPoint.state = (stationaryTouchPoint if (emTouchPoint->isChanged) {
? QEventPoint::State::Stationary touchPoint.state = (stationaryTouchPoint
: QEventPoint::State::Updated); ? QEventPoint::State::Stationary
: QEventPoint::State::Updated);
m_pressedTouchIds.insert(touchPoint.id, touchPoint.normalPosition); m_pressedTouchIds.insert(touchPoint.id, touchPoint.normalPosition);
}
break; break;
default: default:
break; break;