12#include <QtGui/private/qguiapplication_p.h>
13#include <QtGui/qpointingdevice.h>
15#include <QtCore/qassert.h>
22 const auto callback = std::function([
this](emscripten::val
event) {
24 event.call<
void>(
"preventDefault");
25 event.call<
void>(
"stopPropagation");
28 m_pointerDownCallback =
29 std::make_unique<qstdweb::EventCallback>(element,
"pointerdown", callback);
30 m_pointerMoveCallback =
31 std::make_unique<qstdweb::EventCallback>(element,
"pointermove", callback);
32 m_pointerUpCallback = std::make_unique<qstdweb::EventCallback>(element,
"pointerup", callback);
33 m_pointerCancelCallback =
34 std::make_unique<qstdweb::EventCallback>(element,
"pointercancel", callback);
36 element.call<
void>(
"setAttribute", emscripten::val(
"draggable"), emscripten::val(
"true"));
38 m_dragStartCallback = std::make_unique<qstdweb::EventCallback>(
39 element,
"dragstart", [
this](emscripten::val webEvent) {
40 webEvent.call<
void>(
"preventDefault");
44 m_dragOverCallback = std::make_unique<qstdweb::EventCallback>(
45 element,
"dragover", [
this](emscripten::val webEvent) {
46 webEvent.call<
void>(
"preventDefault");
50 m_dropCallback = std::make_unique<qstdweb::EventCallback>(
51 element,
"drop", [
this](emscripten::val webEvent) {
52 webEvent.call<
void>(
"preventDefault");
56 m_dragEndCallback = std::make_unique<qstdweb::EventCallback>(
57 element,
"dragend", [
this](emscripten::val webEvent) {
58 webEvent.call<
void>(
"preventDefault");
70 m_element.call<
void>(
"setPointerCapture",
event.pointerId);
73 && m_window->
window()->isTopLevel())
74 m_window->
window()->requestActivate();
77 m_element.call<
void>(
"releasePointerCapture",
event.pointerId);
83 const bool eventAccepted = deliverEvent(
event);
95 const QPointF targetPointClippedToScreen(
96 qBound(geometryF.left(), pointInScreen.x(), geometryF.right()),
97 qBound(geometryF.top(), pointInScreen.y(), geometryF.bottom()));
106 m_window->
window()->mapFromGlobal(targetPointClippedToScreen),
107 targetPointClippedToScreen,
event.mouseButtons,
event.mouseButton,
108 eventType,
event.modifiers);
113 switch (
event.type) {
116 pressure =
event.pressure;
128 qreal rotation =
event.twist > 180.0 ? 360.0 -
event.twist :
event.twist;
131 m_window->
window()->mapFromGlobal(targetPointClippedToScreen),
132 targetPointClippedToScreen,
event.mouseButtons, pressure, xTilt, yTilt,
133 event.tangentialPressure, rotation,
event.modifiers);
138 QPointF pointInTargetWindowCoords =
139 QPointF(m_window->
window()->mapFromGlobal(targetPointClippedToScreen));
141 pointInTargetWindowCoords.y() / m_window->
window()->
height());
143 const auto tp = m_pointerIdToTouchPoints.
find(
event.pointerId);
145 touchPoint = &tp.value();
147 touchPoint = &m_pointerIdToTouchPoints
159 const bool stationaryTouchPoint = (normalPosition == touchPoint->
normalPosition);
163 touchPoint->
pressure =
event.pressure;
165 switch (
event.type) {
177 QList<QWindowSystemInterface::TouchPoint> touchPointList;
178 touchPointList.reserve(m_pointerIdToTouchPoints.
size());
179 std::transform(m_pointerIdToTouchPoints.
begin(), m_pointerIdToTouchPoints.
end(),
180 std::back_inserter(touchPointList),
ClientArea(QWasmWindow *window, QWasmScreen *screen, emscripten::val element)
Type
This enum type defines the valid event types in Qt.
static QGuiApplicationPrivate * instance()
iterator insert(const Key &key, const T &value)
size_type remove(const Key &key)
iterator find(const Key &key)
\inmodule QtCore\reentrant
\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 QWasmDrag * instance()
static quint64 getTimestamp()
emscripten::val element() const
QPointF mapFromLocal(const QPointF &p) const
QPointingDevice * touchDevice()
QPointingDevice * tabletDevice()
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 handleTabletEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, const QPointF &local, const QPointF &global, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
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
Qt::WindowFlags flags
the window flags of the window
int height
the height of the window's geometry
EGLImageKHR int int EGLuint64KHR * modifiers
Combined button and popup list for selecting options.
@ WindowDoesNotAcceptFocus
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 std::optional< DragEvent > fromWeb(emscripten::val webEvent, QWindow *targetQWindow)
static constexpr QEvent::Type mouseEventTypeFromEventType(EventType eventType, WindowArea windowArea)
static std::optional< PointerEvent > fromWeb(emscripten::val webEvent)