diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2023-02-08 14:39:17 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2023-02-09 14:45:35 +1000 |
commit | 56068f3a36a2f8e23a2a5e43a28e463a5aa6b400 (patch) | |
tree | a51e53c3a3245510c65c90d3fd601e661fec25af | |
parent | 230bc059ae50a16346700a47090dcb97d239e8c0 (diff) |
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>
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcompositor.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index e020d50728..73faef4999 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; |