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:
parent
230bc059ae
commit
56068f3a36
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user