diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2022-01-17 07:25:26 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2022-03-03 12:30:59 +1000 |
commit | 66a76a5def46d0e4a330f7130ad440c639b87cf7 (patch) | |
tree | 88a05b0a11fce75c7a672e16957c7d9f4f3bff0c /src/plugins/platforms/wasm/qwasmintegration.h | |
parent | 6f5c78fe3d445f1c6c8738f9cedb9dbd847645fa (diff) |
wasm: enable mobile native keyboarding
This works on iOS and Android, and Windows with touchscreen.
On Android, we need to listen to the input event
of a hidden text element and synthesize Qt keyboard
events from that in order to get input events into Qt.
On Windows, we need to be more creative about bringing the native
virtual keyboard up.
Because the entire canvas is contenteditable, we need to specify the
inputmode is set to 'none', otherwise the v keyboard pops up
when user clicks anywhere on the canvas. Therefore we set a hidden
element as contenteditable, which pops up keyboard when Qt
needs it for editable widgets. On Android, this is the same
element that is used to proxy the keyboard input.
[ChangeLog][wasm] Add support for native mobile keyboard
Done-with: Morten Johan Sørvig <morten.sorvig@qt.io>
Fixes: QTBUG-83064
Fixes: QTBUG-88803
Change-Id: I769fe344fc10c17971bd1c0a603501040fe82653
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmintegration.h')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmintegration.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/platforms/wasm/qwasmintegration.h b/src/plugins/platforms/wasm/qwasmintegration.h index 46fab8e818..316f6eef40 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.h +++ b/src/plugins/platforms/wasm/qwasmintegration.h @@ -42,6 +42,9 @@ #include <emscripten/html5.h> #include <emscripten/val.h> +#include "qwasminputcontext.h" +#include <private/qstdweb_p.h> + QT_BEGIN_NAMESPACE class QWasmEventTranslator; @@ -58,6 +61,14 @@ class QWasmIntegration : public QObject, public QPlatformIntegration { Q_OBJECT public: + enum Platform { + GenericPlatform, + MacOSPlatform, + WindowsPlatform, + LinuxPlatform, + AndroidPlatform + }; + QWasmIntegration(); ~QWasmIntegration(); @@ -80,7 +91,7 @@ public: QPlatformInputContext *inputContext() const override; QWasmClipboard *getWasmClipboard() { return m_clipboard; } - + QWasmInputContext *getWasmInputContext() { return m_platformInputContext; } static QWasmIntegration *get() { return s_instance; } void addScreen(const emscripten::val &canvas); @@ -91,6 +102,9 @@ public: void removeBackingStore(QWindow* window); static quint64 getTimestamp(); + Platform platform; + int touchPoints; + private: mutable QWasmFontDatabase *m_fontDb; mutable QWasmServices *m_desktopServices; @@ -100,6 +114,8 @@ private: qreal m_fontDpi = -1; mutable QScopedPointer<QPlatformInputContext> m_inputContext; static QWasmIntegration *s_instance; + + mutable QWasmInputContext *m_platformInputContext = nullptr; }; QT_END_NAMESPACE |