diff options
author | Mikolaj Boc <mikolaj.boc@qt.io> | 2023-01-24 10:18:34 +0100 |
---|---|---|
committer | Mikolaj Boc <mikolaj.boc@qt.io> | 2023-02-07 18:59:59 +0100 |
commit | d141d6894960dba7c62d67400a31a49a4abcdb08 (patch) | |
tree | 8711444671b98ec1f0d889dc9cfc9c0ef013efc3 /src/plugins/platforms/wasm/qwasmevent.h | |
parent | 62be4ab5be41b09eea16e5675ed4a74c795e58d9 (diff) |
Transfer the key handling logic to QWasmWindow
Also, use the embind approach as the rest of the events do, and
introduce a KeyEvent class which simplifies and streamlines event
support.
The event translator has been given a more specific function of
just handling the dead keys. Rest of the translation functionality
is coded directly in KeyEvent for more encapsulation.
Change-Id: I11b0262fc42fe920206ecc6de0d434b9d9ab9998
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmevent.h')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmevent.h | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/plugins/platforms/wasm/qwasmevent.h b/src/plugins/platforms/wasm/qwasmevent.h index e8aea9072e..73bb28d267 100644 --- a/src/plugins/platforms/wasm/qwasmevent.h +++ b/src/plugins/platforms/wasm/qwasmevent.h @@ -17,8 +17,12 @@ QT_BEGIN_NAMESPACE +class QWasmDeadKeySupport; + enum class EventType { Drop, + KeyDown, + KeyUp, PointerDown, PointerMove, PointerUp, @@ -113,26 +117,37 @@ QFlags<Qt::KeyboardModifier> getForEvent<EmscriptenKeyboardEvent>( struct Event { - EventType type; - emscripten::val target = emscripten::val::undefined(); - Event(EventType type, emscripten::val target); ~Event(); Event(const Event &other); Event(Event &&other); Event &operator=(const Event &other); Event &operator=(Event &&other); + + EventType type; + emscripten::val target = emscripten::val::undefined(); }; -struct MouseEvent : public Event +struct KeyEvent : public Event { - QPoint localPoint; - QPoint pointInPage; - QPoint pointInViewport; - Qt::MouseButton mouseButton; - Qt::MouseButtons mouseButtons; + static std::optional<KeyEvent> + fromWebWithDeadKeyTranslation(emscripten::val webEvent, QWasmDeadKeySupport *deadKeySupport); + + KeyEvent(EventType type, emscripten::val webEvent); + ~KeyEvent(); + KeyEvent(const KeyEvent &other); + KeyEvent(KeyEvent &&other); + KeyEvent &operator=(const KeyEvent &other); + KeyEvent &operator=(KeyEvent &&other); + + Qt::Key key; QFlags<Qt::KeyboardModifier> modifiers; + bool deadKey; + QString text; +}; +struct MouseEvent : public Event +{ MouseEvent(EventType type, emscripten::val webEvent); ~MouseEvent(); MouseEvent(const MouseEvent &other); @@ -174,6 +189,13 @@ struct MouseEvent : public Event return QEvent::None; } } + + QPoint localPoint; + QPoint pointInPage; + QPoint pointInViewport; + Qt::MouseButton mouseButton; + Qt::MouseButtons mouseButtons; + QFlags<Qt::KeyboardModifier> modifiers; }; struct PointerEvent : public MouseEvent |