From 56068f3a36a2f8e23a2a5e43a28e463a5aa6b400 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 8 Feb 2023 14:39:17 +1000 Subject: [PATCH] wasm: fix multitouch processing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../platforms/wasm/qwasmcompositor.cpp | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index e020d507289..73faef49993 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -286,12 +286,15 @@ bool QWasmCompositor::processTouch(int eventType, const EmscriptenTouchEvent *to touchPointList.reserve(touchEvent->numTouches); QWindow *targetWindow = nullptr; + qWarning() << Q_FUNC_INFO << "number emTouchPoint:" << touchEvent->numTouches; + for (int i = 0; i < touchEvent->numTouches; i++) { - const EmscriptenTouchPoint *touches = &touchEvent->touches[i]; + const EmscriptenTouchPoint *emTouchPoint = &touchEvent->touches[i]; + QPoint targetPointInScreenCoords = - screen()->mapFromLocal(QPoint(touches->targetX, touches->targetY)); + screen()->mapFromLocal(QPoint(emTouchPoint->targetX, emTouchPoint->targetY)); targetWindow = screen()->compositor()->windowAt(targetPointInScreenCoords, 5); if (targetWindow == nullptr) @@ -300,7 +303,7 @@ bool QWasmCompositor::processTouch(int eventType, const EmscriptenTouchEvent *to QWindowSystemInterface::TouchPoint touchPoint; touchPoint.area = QRect(0, 0, 8, 8); - touchPoint.id = touches->identifier; + touchPoint.id = emTouchPoint->identifier; touchPoint.pressure = 1.0; touchPoint.area.moveCenter(targetPointInScreenCoords); @@ -318,26 +321,31 @@ bool QWasmCompositor::processTouch(int eventType, const EmscriptenTouchEvent *to switch (eventType) { case EMSCRIPTEN_EVENT_TOUCHSTART: - if (tp != m_pressedTouchIds.constEnd()) { - touchPoint.state = (stationaryTouchPoint - ? QEventPoint::State::Stationary - : QEventPoint::State::Updated); - } else { - touchPoint.state = QEventPoint::State::Pressed; + if (emTouchPoint->isChanged) { + if (tp != m_pressedTouchIds.constEnd()) { + touchPoint.state = (stationaryTouchPoint + ? QEventPoint::State::Stationary + : QEventPoint::State::Updated); + } 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: - touchPoint.state = QEventPoint::State::Released; - m_pressedTouchIds.remove(touchPoint.id); + if (emTouchPoint->isChanged) { + touchPoint.state = QEventPoint::State::Released; + m_pressedTouchIds.remove(touchPoint.id); + } break; case EMSCRIPTEN_EVENT_TOUCHMOVE: - touchPoint.state = (stationaryTouchPoint - ? QEventPoint::State::Stationary - : QEventPoint::State::Updated); + if (emTouchPoint->isChanged) { + touchPoint.state = (stationaryTouchPoint + ? QEventPoint::State::Stationary + : QEventPoint::State::Updated); - m_pressedTouchIds.insert(touchPoint.id, touchPoint.normalPosition); + m_pressedTouchIds.insert(touchPoint.id, touchPoint.normalPosition); + } break; default: break;