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 QPlatformClipboard *clipboard() const override;
63#ifndef QT_NO_ACCESSIBILITY
64 QPlatformAccessibility *accessibility() const override;
65#endif
66 void initialize() override;
67 QPlatformInputContext *inputContext() const override;
68 QWasmInputContext *wasmInputContext() const { return m_wasmInputContext; }
69
70#if QT_CONFIG(draganddrop)
72#endif
73
74 QWasmClipboard *getWasmClipboard() { return m_clipboard; }
75 static QWasmIntegration *get() { return s_instance; }
76
77 void setContainerElements(emscripten::val elementArray);
78 void addContainerElement(emscripten::val elementArray);
79 void removeContainerElement(emscripten::val elementArray);
80 void resizeScreen(const emscripten::val &canvas);
81 void updateDpi();
82 void resizeAllScreens();
83 void loadLocalFontFamilies(emscripten::val families);
84 void removeBackingStore(QWindow* window);
86 static quint64 getTimestamp();
87
89
90private:
91 QWasmWindow *createWindow(QWindow *, WId nativeHandle) const;
92
93 struct ScreenMapping {
94 emscripten::val emscriptenVal;
95 QWasmScreen *wasmScreen;
96 };
97
98 mutable QWasmFontDatabase *m_fontDb;
99 mutable QWasmServices *m_desktopServices;
100 mutable QHash<QWindow *, QWasmBackingStore *> m_backingStores;
101 QList<ScreenMapping> m_screens;
102 mutable QWasmClipboard *m_clipboard;
103 mutable QWasmAccessibility *m_accessibility;
104
105 qreal m_fontDpi = -1;
106 mutable QScopedPointer<QPlatformInputContext> m_inputContext;
107 static QWasmIntegration *s_instance;
108
109 QWasmInputContext *m_wasmInputContext = nullptr;
110 std::shared_ptr<QWasmSuspendResumeControl> m_suspendResume;
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
QPlatformClipboard * clipboard() const override
Accessor for the platform integration's clipboard.
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.