diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2021-11-27 23:56:40 +0100 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2022-04-05 22:34:44 +0200 |
commit | 08733dff582e220ba381939e74c623a5321fb9a5 (patch) | |
tree | 11c8f3212489b555eea37ecd881724ed0f18ceb1 /src/plugins/platforms/wasm/qwasmopenglcontext.cpp | |
parent | 4bc85b9850303fa20206f8774af88d72593d3454 (diff) | |
download | qtbase-08733dff582e220ba381939e74c623a5321fb9a5.tar.gz |
wasm: use “specialHtmlTargets” for canvas lookup
We’d like to support use cases which require using
multiple html documents, for example when displaying
application content using more than one browser window.
Normally Emscripten uses the primary html document when
looking up elements by id, which means that targeting
elements on secondary documents is not possible.
Emscripten does provide a workaround: the application
can create custom id mappings to any html element on
the “specialHtmlTargets” object, and then use the
“!id” syntax instead of normal “#id” lookup.
Change-Id: I4dda920868cfbc6f8991425daf8933144c0ffad8
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmopenglcontext.cpp')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmopenglcontext.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index c122335a57..4462e55524 100644 --- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -87,13 +87,12 @@ bool QWasmOpenGLContext::maybeCreateEmscriptenContext(QPlatformSurface *surface) if (m_context) return m_screen == screen; - QString canvasId = QWasmScreen::get(screen)->canvasId(); - m_context = createEmscriptenContext(canvasId, m_requestedFormat); + m_context = createEmscriptenContext(QWasmScreen::get(screen)->canvasTargetId(), m_requestedFormat); m_screen = screen; return true; } -EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(const QString &canvasId, QSurfaceFormat format) +EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(const QString &canvasTargetId, QSurfaceFormat format) { EmscriptenWebGLContextAttributes attributes; emscripten_webgl_init_context_attributes(&attributes); // Populate with default attributes @@ -114,7 +113,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(cons attributes.depth = useDepthStencil; attributes.stencil = useDepthStencil; - QByteArray convasSelector = "#" + canvasId.toUtf8(); + QByteArray convasSelector = canvasTargetId.toUtf8(); EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(convasSelector.constData(), &attributes); return context; |