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
10#include <qpa/qplatformintegration.h>
11#include <qpa/qplatformscreen.h>
12#include <qpa/qplatforminputcontext.h>
13
14#include <QtCore/qhash.h>
15
16#include <private/qstdweb_p.h>
17
18#include <emscripten.h>
19#include <emscripten/html5.h>
20#include <emscripten/val.h>
21
22#include <memory>
23
25
26class QWasmEventTranslator;
27class QWasmFontDatabase;
28class QWasmWindow;
30class QWasmScreen;
31class QWasmCompositor;
33class QWasmClipboard;
34class QWasmAccessibility;
35class QWasmServices;
36class QWasmDrag;
37class QWasmInputContext;
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);
87 static quint64 getTimestamp();
88
90
91private:
92 QWasmWindow *createWindow(QWindow *, WId nativeHandle) const;
93
94 struct ScreenMapping {
95 emscripten::val emscriptenVal;
96 QWasmScreen *wasmScreen;
97 };
98
99 mutable QWasmFontDatabase *m_fontDb;
100 mutable QWasmServices *m_desktopServices;
101 mutable QHash<QWindow *, QWasmBackingStore *> m_backingStores;
102 QList<ScreenMapping> m_screens;
103 mutable QWasmClipboard *m_clipboard;
104 mutable QWasmAccessibility *m_accessibility;
105
106 qreal m_fontDpi = -1;
107 mutable QScopedPointer<QPlatformInputContext> m_inputContext;
108 static QWasmIntegration *s_instance;
109
110 QWasmInputContext *m_wasmInputContext = nullptr;
111
112#if QT_CONFIG(draganddrop)
114#endif
115
116};
117
118QT_END_NAMESPACE
119
120#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.