11#include <QtGui/private/qguiapplication_p.h>
12#include <QtGui/qpointingdevice.h>
14#include <QtCore/qassert.h>
21 const auto callback = std::function([
this](emscripten::val
event) {
23 event.call<
void>(
"preventDefault");
24 event.call<
void>(
"stopPropagation");
27 m_pointerDownCallback =
28 std::make_unique<qstdweb::EventCallback>(element,
"pointerdown", callback);
29 m_pointerMoveCallback =
30 std::make_unique<qstdweb::EventCallback>(element,
"pointermove", callback);
31 m_pointerUpCallback = std::make_unique<qstdweb::EventCallback>(element,
"pointerup", callback);
32 m_pointerCancelCallback =
33 std::make_unique<qstdweb::EventCallback>(element,
"pointercancel", callback);
41 m_element.call<
void>(
"setPointerCapture",
event.pointerId);
42 m_window->
window()->requestActivate();
45 m_element.call<
void>(
"releasePointerCapture",
event.pointerId);
51 const bool eventAccepted = deliverEvent(
event);
63 const QPointF targetPointClippedToScreen(
64 qBound(geometryF.left(), pointInScreen.x(), geometryF.right()),
65 qBound(geometryF.top(), pointInScreen.y(), geometryF.bottom()));
74 m_window->
window()->mapFromGlobal(targetPointClippedToScreen),
75 targetPointClippedToScreen,
event.mouseButtons,
event.mouseButton,
76 eventType,
event.modifiers);
81 QPointF pointInTargetWindowCoords =
82 QPointF(m_window->
window()->mapFromGlobal(targetPointClippedToScreen));
84 pointInTargetWindowCoords.
y() / m_window->
window()->
height());
86 const auto tp = m_pointerIdToTouchPoints.
find(
event.pointerId);
87 if (tp != m_pointerIdToTouchPoints.
end()) {
88 touchPoint = &tp.value();
90 touchPoint = &m_pointerIdToTouchPoints
102 const bool stationaryTouchPoint = (normalPosition == touchPoint->
normalPosition);
106 touchPoint->
pressure =
event.pressure;
108 switch (
event.type) {
121 touchPointList.
reserve(m_pointerIdToTouchPoints.
size());
122 std::transform(m_pointerIdToTouchPoints.
begin(), m_pointerIdToTouchPoints.
end(),
123 std::back_inserter(touchPointList),
ClientArea(QWasmWindow *window, QWasmScreen *screen, emscripten::val element)
Type
This enum type defines the valid event types in Qt.
virtual bool closeAllPopups()
static QGuiApplicationPrivate * instance()
void reserve(qsizetype size)
iterator insert(const Key &key, const T &value)
size_type remove(const Key &key)
iterator find(const Key &key)
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr QRectF toRectF() const noexcept
static quint64 getTimestamp()
emscripten::val element() const
QPointF mapFromLocal(const QPointF &p) const
QPointingDevice * touchDevice()
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
The QWindowSystemInterface provides an event queue for the QPA platform.
static bool handleTouchCancelEvent(QWindow *window, const QPointingDevice *device, Qt::KeyboardModifiers mods=Qt::NoModifier)
static bool handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
int width
the width of the window's geometry
int height
the height of the window's geometry
EGLImageKHR int int EGLuint64KHR * modifiers
Combined button and popup list for selecting options.
QPointF mapPoint(emscripten::val source, emscripten::val target, const QPointF &point)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr T qAbs(const T &t)
static constexpr QEvent::Type mouseEventTypeFromEventType(EventType eventType, WindowArea windowArea)
static std::optional< PointerEvent > fromWeb(emscripten::val webEvent)