wasm: sync pointer button state on pointer down
We may get PointerDown events with "no buttons" as the button state in some cases such as for tap events on Apple trackpads. Make sure the mouse button which caused the pointer down event is in the mouse buttons set for the event. Fixes: QTBUG-108639 Pick-to: 6.4 6.5 Change-Id: I0a49abc398308bbfed657b99fc74f60c16e05a59 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
029e118a4e
commit
1d3d7bfbbc
@ -44,6 +44,14 @@ std::optional<PointerEvent> PointerEvent::fromWeb(emscripten::val event)
|
||||
PointerType::Mouse : PointerType::Other;
|
||||
ret.mouseButton = MouseEvent::buttonFromWeb(event["button"].as<int>());
|
||||
ret.mouseButtons = MouseEvent::buttonsFromWeb(event["buttons"].as<unsigned short>());
|
||||
|
||||
// The current button state (event.buttons) may be out of sync for some PointerDown
|
||||
// events where the "down" state is very brief, for example taps on Apple trackpads.
|
||||
// Qt expects that the current button state is in sync with the event, so we sync
|
||||
// it up here.
|
||||
if (*eventType == EventType::PointerDown)
|
||||
ret.mouseButtons |= ret.mouseButton;
|
||||
|
||||
ret.localPoint = QPoint(event["offsetX"].as<int>(), event["offsetY"].as<int>());
|
||||
ret.pointInPage = QPoint(event["pageX"].as<int>(), event["pageY"].as<int>());
|
||||
ret.pointInViewport = QPoint(event["clientX"].as<int>(), event["clientY"].as<int>());
|
||||
|
Loading…
Reference in New Issue
Block a user