Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasmintegration.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWASMINTEGRATION_H
5#define QWASMINTEGRATION_H
6
7#include "qwasmwindow.h"
8
10
11#include <qpa/qplatformintegration.h>
12#include <qpa/qplatformscreen.h>
13#include <qpa/qplatforminputcontext.h>
14
15#include <QtCore/qhash.h>
16
17#include <private/qstdweb_p.h>
18
19#include <emscripten.h>
20#include <emscripten/html5.h>
21#include <emscripten/val.h>
22
23#include <memory>
24
26
27class QWasmEventTranslator;
28class QWasmFontDatabase;
29class QWasmWindow;
31class QWasmScreen;
32class QWasmCompositor;
34class QWasmClipboard;
35class QWasmAccessibility;
36class QWasmServices;
37class QWasmDrag;
38class QWasmSuspendResumeControl;
39
41{
43public:
46
47 bool hasCapability(QPlatformIntegration::Capability cap) const override;
48 QPlatformWindow *createPlatformWindow(QWindow *window) const override;
49 QPlatformWindow *createForeignWindow(QWindow *window, WId nativeHandle) const override;
50 QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
51#ifndef QT_NO_OPENGL
52 QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
53#endif
54 QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
55 QPlatformFontDatabase *fontDatabase() const override;
57 QVariant styleHint(QPlatformIntegration::StyleHint hint) const override;
58 Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override;
59 QStringList themeNames() const override;
60 QPlatformTheme *createPlatformTheme(const QString &name) const override;
61 QPlatformServices *services() const override;
62#if QT_CONFIG(clipboard)
64#endif
65#ifndef QT_NO_ACCESSIBILITY
66 QPlatformAccessibility *accessibility() const override;
67#endif
68 void initialize() override;
69 QPlatformInputContext *inputContext() const override;
70 QWasmInputContext *wasmInputContext() const { return m_wasmInputContext; }
71
72#if QT_CONFIG(draganddrop)
74#endif
75
76 QWasmClipboard *getWasmClipboard() { return m_clipboard; }
77 static QWasmIntegration *get() { return s_instance; }
78
79 void setContainerElements(emscripten::val elementArray);
80 void addContainerElement(emscripten::val elementArray);
81 void removeContainerElement(emscripten::val elementArray);
82 void resizeScreen(const emscripten::val &canvas);
83 void updateDpi();
84 void resizeAllScreens();
85 void loadLocalFontFamilies(emscripten::val families);
86 void removeBackingStore(QWindow* window);
88 static quint64 getTimestamp();
89
91
92private:
93 QWasmWindow *createWindow(QWindow *, WId nativeHandle) const;
94
95 struct ScreenMapping {
96 emscripten::val emscriptenVal;
97 QWasmScreen *wasmScreen;
98 };
99
100 // m_suspendResume should be created first and destroyed early as other fields depend on it
101 std::shared_ptr<QWasmSuspendResumeControl> m_suspendResume;
102
103 mutable QWasmFontDatabase *m_fontDb;
104 mutable QWasmServices *m_desktopServices;
105 mutable QHash<QWindow *, QWasmBackingStore *> m_backingStores;
106 QList<ScreenMapping> m_screens;
107 mutable QWasmClipboard *m_clipboard;
108 mutable QWasmAccessibility *m_accessibility;
109
110 qreal m_fontDpi = -1;
111 mutable QScopedPointer<QPlatformInputContext> m_inputContext;
112 static QWasmIntegration *s_instance;
113
114 QWasmInputContext *m_wasmInputContext = nullptr;
115
116#if QT_CONFIG(draganddrop)
118#endif
119
120};
121
122QT_END_NAMESPACE
123
124#endif // QWASMINTEGRATION_H
QWasmCompositor(QWasmScreen *screen)
QPlatformInputContext * inputContext() const override
Returns the platforms input context.
void setContainerElements(emscripten::val elementArray)
static QWasmIntegration * get()
Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override
QPlatformFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
QPlatformOffscreenSurface * createPlatformOffscreenSurface(QOffscreenSurface *surface) const override
Factory function for QOffscreenSurface.
void addContainerElement(emscripten::val elementArray)
void initialize() override
Performs initialization steps that depend on having an event dispatcher available.
QWasmClipboard * getWasmClipboard()
void removeContainerElement(emscripten::val elementArray)
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
QStringList themeNames() const override
void loadLocalFontFamilies(emscripten::val families)
QPlatformOpenGLContext * createPlatformOpenGLContext(QOpenGLContext *context) const override
Factory function for QPlatformOpenGLContext.
QWasmInputContext * wasmInputContext() const
void removeBackingStore(QWindow *window)
QPlatformBackingStore * createPlatformBackingStore(QWindow *window) const override
Factory function for QPlatformBackingStore.
static quint64 getTimestamp()
QPlatformServices * services() const override
QPlatformWindow * createForeignWindow(QWindow *window, WId nativeHandle) const override
QPlatformTheme * createPlatformTheme(const QString &name) const override
void resizeScreen(const emscripten::val &canvas)
QVariant styleHint(QPlatformIntegration::StyleHint hint) const override
bool hasCapability(QPlatformIntegration::Capability cap) const override
QPlatformWindow * createPlatformWindow(QWindow *window) const override
Factory function for QPlatformWindow.
QPlatformAccessibility * accessibility() const override
friend class QWasmCompositor