From c2bcf9c2fb977b4be7970f7dd7391150ea9c43c1 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Tue, 21 Nov 2023 14:04:20 +1000 Subject: [PATCH] wasm: fix Pen input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also adds the ability to distinguish between a Pen and a Touch. Fixes: QTBUG-116989 Change-Id: Iffc5d20c9b46c1746a03c45dd12017d5dd5172a5 Reviewed-by: Morten Johan Sørvig (cherry picked from commit 0367aace14b61e72433fa7cb7aab18b3def0030c) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 82a32ac7ab78d449531f3d5681c1dc943e681d00) --- src/plugins/platforms/wasm/qwasmevent.cpp | 2 ++ src/plugins/platforms/wasm/qwasmevent.h | 1 + src/plugins/platforms/wasm/qwasmwindowclientarea.cpp | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wasm/qwasmevent.cpp b/src/plugins/platforms/wasm/qwasmevent.cpp index 6353cce48f5..ec37c64b2da 100644 --- a/src/plugins/platforms/wasm/qwasmevent.cpp +++ b/src/plugins/platforms/wasm/qwasmevent.cpp @@ -177,6 +177,8 @@ PointerEvent::PointerEvent(EventType type, emscripten::val event) : MouseEvent(t return PointerType::Mouse; if (type == "touch") return PointerType::Touch; + if (type == "pen") + return PointerType::Pen; return PointerType::Other; })(); width = event["width"].as(); diff --git a/src/plugins/platforms/wasm/qwasmevent.h b/src/plugins/platforms/wasm/qwasmevent.h index 012b1b235b8..3b2e5bfc52d 100644 --- a/src/plugins/platforms/wasm/qwasmevent.h +++ b/src/plugins/platforms/wasm/qwasmevent.h @@ -35,6 +35,7 @@ enum class EventType { enum class PointerType { Mouse, Touch, + Pen, Other, }; diff --git a/src/plugins/platforms/wasm/qwasmwindowclientarea.cpp b/src/plugins/platforms/wasm/qwasmwindowclientarea.cpp index a0684e8ecf8..aa8cfeebb2e 100644 --- a/src/plugins/platforms/wasm/qwasmwindowclientarea.cpp +++ b/src/plugins/platforms/wasm/qwasmwindowclientarea.cpp @@ -99,7 +99,7 @@ bool ClientArea::deliverEvent(const PointerEvent &event) pointInTargetWindowCoords.y() / m_window->window()->height()); const auto tp = m_pointerIdToTouchPoints.find(event.pointerId); - if (tp != m_pointerIdToTouchPoints.end()) { + if (event.pointerType != PointerType::Pen && tp != m_pointerIdToTouchPoints.end()) { touchPoint = &tp.value(); } else { touchPoint = &m_pointerIdToTouchPoints