wasm: capture pointer unconditionally on PointerDown event

The pointer events weren't captured previously
if, for example, mouse was pressed inside the window
and released outside of the window.

Fixes: QTBUG-71948
Change-Id: Ie50e5c132fa03046f0c5b321c35a58cb9f34b67a
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit aee64bbe134b057b60e8848a8433cd9c4329b046)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Aleksandr Reviakin 2022-09-16 13:18:41 +02:00 committed by Qt Cherry-pick Bot
parent c8b9fcef6c
commit 1444763616

View File

@ -928,6 +928,8 @@ bool QWasmCompositor::processPointer(const PointerEvent& event)
switch (event.type) { switch (event.type) {
case EventType::PointerDown: case EventType::PointerDown:
{ {
screen()->canvas().call<void>("setPointerCapture", event.pointerId);
if (targetWindow) if (targetWindow)
targetWindow->requestActivate(); targetWindow->requestActivate();
@ -940,6 +942,8 @@ bool QWasmCompositor::processPointer(const PointerEvent& event)
} }
case EventType::PointerUp: case EventType::PointerUp:
{ {
screen()->canvas().call<void>("releasePointerCapture", event.pointerId);
m_windowManipulation.onPointerUp(event); m_windowManipulation.onPointerUp(event);
if (m_pressedWindow) { if (m_pressedWindow) {
@ -1100,8 +1104,6 @@ void QWasmCompositor::WindowManipulation::onPointerDown(
.window = windowAtPoint, .window = windowAtPoint,
.operationSpecific = std::move(*operationSpecific), .operationSpecific = std::move(*operationSpecific),
}); });
m_screen->canvas().call<void>("setPointerCapture", event.pointerId);
} }
void QWasmCompositor::WindowManipulation::onPointerMove( void QWasmCompositor::WindowManipulation::onPointerMove(
@ -1140,7 +1142,6 @@ void QWasmCompositor::WindowManipulation::onPointerUp(const PointerEvent& event)
return; return;
m_state.reset(); m_state.reset();
m_screen->canvas().call<void>("releasePointerCapture", event.pointerId);
} }
bool QWasmCompositor::processKeyboard(int eventType, const EmscriptenKeyboardEvent *emKeyEvent) bool QWasmCompositor::processKeyboard(int eventType, const EmscriptenKeyboardEvent *emKeyEvent)