diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 714a7ee058..8f41efa47d 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -371,6 +371,11 @@ qt_internal_extend_target(Gui CONDITION MACOS ${FWAppKit} ) +qt_internal_extend_target(Gui CONDITION WASM + SOURCES + platform/wasm/qwasmnativeinterface.cpp +) + qt_internal_extend_target(Gui CONDITION APPLE SOURCES image/qimage_darwin.mm diff --git a/src/gui/kernel/qplatformwindow_p.h b/src/gui/kernel/qplatformwindow_p.h index 65b8b4a2c5..a1c7b75468 100644 --- a/src/gui/kernel/qplatformwindow_p.h +++ b/src/gui/kernel/qplatformwindow_p.h @@ -41,6 +41,15 @@ public: namespace QNativeInterface::Private { +#if defined(Q_OS_WASM) || defined(Q_QDOC) +struct Q_GUI_EXPORT QWasmWindow +{ + QT_DECLARE_NATIVE_INTERFACE(QWasmWindow, 1, QWindow) + virtual emscripten::val document() const = 0; + virtual emscripten::val clientArea() const = 0; +}; +#endif + #if defined(Q_OS_MACOS) || defined(Q_QDOC) struct Q_GUI_EXPORT QCocoaWindow { diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index e83ed33a36..b59c32ac34 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -3065,6 +3065,10 @@ void *QWindow::resolveInterface(const char *name, int revision) const QT_NATIVE_INTERFACE_RETURN_IF(QWaylandWindow, platformWindow); #endif +#if defined(Q_OS_WASM) + QT_NATIVE_INTERFACE_RETURN_IF(QWasmWindow, platformWindow); +#endif + return nullptr; } diff --git a/src/gui/platform/wasm/qwasmnativeinterface.cpp b/src/gui/platform/wasm/qwasmnativeinterface.cpp new file mode 100644 index 0000000000..7313629a8d --- /dev/null +++ b/src/gui/platform/wasm/qwasmnativeinterface.cpp @@ -0,0 +1,17 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + + +#include +#include +#include + + +QT_BEGIN_NAMESPACE + +using namespace QNativeInterface::Private; + +QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWasmWindow); + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/wasm/qwasmwindow.h b/src/plugins/platforms/wasm/qwasmwindow.h index 661a5160e8..f191c90954 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.h +++ b/src/plugins/platforms/wasm/qwasmwindow.h @@ -6,6 +6,7 @@ #include "qwasmintegration.h" #include +#include #include #include "qwasmbackingstore.h" #include "qwasmscreen.h" @@ -37,7 +38,7 @@ struct PointerEvent; class QWasmDeadKeySupport; struct WheelEvent; -class QWasmWindow final : public QPlatformWindow +class QWasmWindow final : public QPlatformWindow, public QNativeInterface::Private::QWasmWindow { public: QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport, QWasmCompositor *compositor, @@ -91,6 +92,10 @@ public: emscripten::val a11yContainer() const { return m_a11yContainer; } emscripten::val inputHandlerElement() const { return m_windowContents; } + // QNativeInterface::Private::QWasmWindow + emscripten::val document() const override { return m_document; } + emscripten::val clientArea() const override { return m_qtWindow; } + private: friend class QWasmScreen; static constexpr auto minSizeForRegularWindows = 100;