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// Qt-Security score:significant reason:default
4
5#ifndef QWASMINTEGRATION_H
6#define QWASMINTEGRATION_H
7
8#include "qwasmwindow.h"
9
11
12#include <qpa/qplatformintegration.h>
13#include <qpa/qplatformscreen.h>
14#include <qpa/qplatforminputcontext.h>
15
16#include <QtCore/qhash.h>
17
18#include <private/qstdweb_p.h>
19
20#include <emscripten.h>
21#include <emscripten/html5.h>
22#include <emscripten/val.h>
23
24#include <memory>
25
27
28class QWasmEventTranslator;
29class QWasmFontDatabase;
30class QWasmWindow;
32class QWasmScreen;
33class QWasmCompositor;
35class QWasmClipboard;
36class QWasmAccessibility;
37class QWasmServices;
38class QWasmDrag;
39class QWasmSuspendResumeControl;
40
42{
44public:
47
48 bool hasCapability(QPlatformIntegration::Capability cap) const override;
49 QPlatformWindow *createPlatformWindow(QWindow *window) const override;
50 QPlatformWindow *createForeignWindow(QWindow *window, WId nativeHandle) const override;
51 QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
52#ifndef QT_NO_OPENGL
53 QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
54#endif
55 QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
56 QPlatformFontDatabase *fontDatabase() const override;
58 QVariant styleHint(QPlatformIntegration::StyleHint hint) const override;
59 Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override;
60 QStringList themeNames() const override;
61 QPlatformTheme *createPlatformTheme(const QString &name) const override;
62 QPlatformServices *services() const override;
63#if QT_CONFIG(clipboard)
65#endif
66#ifndef QT_NO_ACCESSIBILITY
67 QPlatformAccessibility *accessibility() const override;
68#endif
69 void initialize() override;
70 QPlatformInputContext *inputContext() const override;
71 QWasmInputContext *wasmInputContext() const { return m_wasmInputContext; }
72
73#if QT_CONFIG(draganddrop)
75#endif
76
77 QWasmClipboard *getWasmClipboard() { return m_clipboard; }
78 static QWasmIntegration *get() { return s_instance; }
79
80 void setContainerElements(emscripten::val elementArray);
81 void addContainerElement(emscripten::val elementArray);
82 void removeContainerElement(emscripten::val elementArray);
83 void resizeScreen(const emscripten::val &canvas);
84 void updateDpi();
85 void resizeAllScreens();
86 void loadLocalFontFamilies(emscripten::val families);
87 void removeBackingStore(QWindow* window);
89 static quint64 getTimestamp();
90
92
93private:
94 QWasmWindow *createWindow(QWindow *, WId nativeHandle) const;
95
96 struct ScreenMapping {
97 emscripten::val emscriptenVal;
98 QWasmScreen *wasmScreen;
99 };
100
101 // m_suspendResume should be created first and destroyed early as other fields depend on it
102 std::shared_ptr<QWasmSuspendResumeControl> m_suspendResume;
103
104 mutable QWasmFontDatabase *m_fontDb;
105 mutable QWasmServices *m_desktopServices;
106 mutable QHash<QWindow *, QWasmBackingStore *> m_backingStores;
107 QList<ScreenMapping> m_screens;
108 mutable QWasmClipboard *m_clipboard;
109 mutable QWasmAccessibility *m_accessibility;
110
111 qreal m_fontDpi = -1;
112 mutable QScopedPointer<QPlatformInputContext> m_inputContext;
113 static QWasmIntegration *s_instance;
114
115 QWasmInputContext *m_wasmInputContext = nullptr;
116
117#if QT_CONFIG(draganddrop)
119#endif
120
121};
122
123QT_END_NAMESPACE
124
125#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
Combined button and popup list for selecting options.