17#include <QtCore/private/qstdweb_p.h>
18#include <qpa/qwindowsysteminterface.h>
19#include <qpa/qplatformwindow.h>
20#include <qpa/qplatformwindow_p.h>
22#include <emscripten/val.h>
23#include <emscripten/html5.h>
36class QWasmInputContext;
38Q_DECLARE_LOGGING_CATEGORY(qLcQpaWasmInputContext)
92 void setParent(
const QPlatformWindow *window)
final;
126 static constexpr auto defaultWindowSize = 160;
128 QMetaObject::Connection m_transientWindowChangedConnection;
129 QMetaObject::Connection m_modalityChangedConnection;
133 void onParentChanged(QWasmWindowTreeNode *previous, QWasmWindowTreeNode *current,
134 QWasmWindowStack<>::PositionPreference positionPreference)
final;
136 void transferFocus();
138 bool hasFrame()
const;
139 bool hasTitleBar()
const;
140 bool hasBorder()
const;
141 bool hasShadow()
const;
142 bool hasMaximizeButton()
const;
143 void applyWindowState();
144 void commitParent(QWasmWindowTreeNode *parent);
146 void handleKeyEvent(
const KeyEvent &event);
147 bool processKey(
const KeyEvent &event);
149 void handleCompositionStartEvent(
emscripten::val event);
150 void handleCompositionUpdateEvent(
emscripten::val event);
151 void handleCompositionEndEvent(
emscripten::val event);
152 void handleBeforeInputEvent(
emscripten::val event);
153 void handleFocusinEvent(
emscripten::val event);
154 void handleFocusoutEvent(
emscripten::val event);
156 void handlePointerEnterLeaveEvent(
const PointerEvent &event);
157 bool processPointerEnterLeave(
const PointerEvent &event);
158 void releasePointerGrab(
const MouseEvent &event);
161 void handleWheelEvent(
const emscripten::val &event);
163 Qt::WindowFlags fixTopLevelWindowFlags(Qt::WindowFlags)
const;
164 bool shouldBeAboveTransientParentFlags(Qt::WindowFlags flags)
const;
165 QWasmWindowStack<>::PositionPreference positionPreferenceFromWindowFlags(Qt::WindowFlags)
const;
166 QWasmInputContext *activeWasmInputContext()
const;
170 QRect m_normalGeometry {0, 0, 0 ,0};
182 std::unique_ptr<NonClientArea> m_nonClientArea;
184 QWasmWindowTreeNode *m_commitedParent =
nullptr;
186 QWasmEventHandler m_keyDownCallback;
187 QWasmEventHandler m_keyUpCallback;
188 QWasmEventHandler m_keyDownCallbackForInputContext;
189 QWasmEventHandler m_keyUpCallbackForInputContext;
190 QWasmEventHandler m_inputCallback;
191 QWasmEventHandler m_compositionStartCallback;
192 QWasmEventHandler m_compositionUpdateCallback;
193 QWasmEventHandler m_compositionEndCallback;
194 QWasmEventHandler m_beforeInputCallback;
196 QWasmEventHandler m_pointerDownCallback;
197 QWasmEventHandler m_pointerMoveCallback;
198 QWasmEventHandler m_pointerUpCallback;
199 QWasmEventHandler m_pointerCancelCallback;
200 QWasmEventHandler m_pointerLeaveCallback;
201 QWasmEventHandler m_pointerEnterCallback;
203 QWasmEventHandler m_dragOverCallback;
204 QWasmEventHandler m_dragStartCallback;
205 QWasmEventHandler m_dragEndCallback;
206 QWasmEventHandler m_dropCallback;
207 QWasmEventHandler m_dragEnterCallback;
208 QWasmEventHandler m_dragLeaveCallback;
210 QWasmEventHandler m_wheelEventCallback;
211 QWasmEventHandler m_focusinCallback;
212 QWasmEventHandler m_focusoutCallback;
214 QMap<
int, QWindowSystemInterface::TouchPoint> m_pointerIdToTouchPoints;
216 QWasmEventHandler m_cutCallback;
217 QWasmEventHandler m_copyCallback;
218 QWasmEventHandler m_pasteCallback;
223 Qt::WindowFlags m_flags =
Qt::
Widget;
225 QPoint m_lastPointerMovePoint;
227 std::optional<
int> m_capturedPointerId =
std::
nullopt;
229 bool m_wantCapture =
false;
230 bool m_hasTitle =
false;
231 bool m_needsCompositor =
false;
232 long m_requestAnimationFrameId = -1;
234 friend class QWasmEventTranslator;
235 bool windowIsPopupType(Qt::WindowFlags flags)
const;
\inmodule QtCore\reentrant
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
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
qreal devicePixelRatio() const override
Reimplement this function in subclass to return the device pixel ratio for the window.
QRect normalGeometry() const override
Returns the geometry of a window in 'normal' state (neither maximized, fullscreen nor minimized) for ...
void focus(FocusTarget target=WindowFocus)
QSurfaceFormat format() const override
Returns the actual surface format of the window.
void setParent(const QPlatformWindow *window) final
This function is called to enable native child window in QPA.
static QWasmWindow * fromWindow(const QWindow *window)
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
void setWindowTitle(const QString &title) override
Reimplement to set the window title to title.
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
emscripten::val clientArea() const override
static emscripten::val focusedWindowInputElement()
std::string canvasSelector() const
emscripten::val a11yContainer() const
static QWasmWindow * focusWindow()
QWasmWindow(QWindow *w, QWasmCompositor *compositor, QWasmBackingStore *backingStore, WId nativeHandle)
friend class QWasmCompositor
void onNonClientAreaInteraction()
emscripten::val inputHandlerElement() const
void setGeometry(const QRect &) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
bool setMouseGrabEnabled(bool grab) final
bool onNonClientEvent(const PointerEvent &event)
void setWindowCursor(QByteArray cssCursorName)
void setZOrder(int order)
emscripten::val context2d() const
void setMask(const QRegion ®ion) final
Reimplement to be able to let Qt set the mask of a window.
QWasmWindow * transientParent() const
void setBackingStore(QWasmBackingStore *store)
QWasmWindowTreeNode * parentNode() final
void initialize() override
Called as part of QWindow::create(), after constructing the window.
emscripten::val document() const override
Qt::WindowFlags windowFlags() const
void registerEventHandlers()
void requestUpdate() override
Requests an QEvent::UpdateRequest event.
QWasmBackingStore * backingStore() const
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
void onParentChanged(QWasmWindowTreeNode *previous, QWasmWindowTreeNode *current, QWasmWindowStack<>::PositionPreference positionPreference) final
void setOpacity(qreal level) override
Reimplement to be able to let Qt set the opacity level of a window.
void onActivationChanged(bool active)
void onAccessibilityEnable()
void setWindowState(Qt::WindowStates state) override
Requests setting the window state of this surface to type.
void setWindowIcon(const QIcon &icon) override
Reimplement to set the window icon to icon.
emscripten::val inputElement() const
void propagateSizeHints() override
Reimplement to propagate the size hints of the QWindow.
bool setKeyboardGrabEnabled(bool) override
emscripten::val canvas() const override
QMargins frameMargins() const override
QWasmWindow * asWasmWindow() final
bool windowEvent(QEvent *event) final
Reimplement this method to be able to do any platform specific event handling.
QWasmScreen * platformScreen() const
emscripten::val containerElement() final
void setWindowFlags(Qt::WindowFlags flags) override
Requests setting the window flags of this surface to flags.
Combined button and popup list for selecting options.