summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmintegration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmintegration.cpp')
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp
index e601d553f2..703b0fde0b 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.cpp
+++ b/src/plugins/platforms/wasm/qwasmintegration.cpp
@@ -115,6 +115,21 @@ QWasmIntegration::QWasmIntegration()
}
emscripten::val::global("window").set("onbeforeunload", val::module_property("qtBrowserBeforeUnload"));
+
+ // install browser window resize handler
+ auto onWindowResize = [](int eventType, const EmscriptenUiEvent *e, void *userData) -> int {
+ Q_UNUSED(eventType);
+ Q_UNUSED(e);
+ Q_UNUSED(userData);
+
+ // This resize event is called when the HTML window is resized. Depending
+ // on the page layout the the canvas(es) might also have been resized, so we
+ // update the Qt screen sizes (and canvas render sizes).
+ if (QWasmIntegration *integration = QWasmIntegration::get())
+ integration->resizeAllScreens();
+ return 0;
+ };
+ emscripten_set_resize_callback(nullptr, nullptr, 1, onWindowResize);
}
QWasmIntegration::~QWasmIntegration()
@@ -245,4 +260,11 @@ void QWasmIntegration::resizeScreen(const QString &canvasId)
m_screens.value(canvasId)->updateQScreenAndCanvasRenderSize();
}
+void QWasmIntegration::resizeAllScreens()
+{
+ qDebug() << "resizeAllScreens";
+ for (QWasmScreen *screen : m_screens)
+ screen->updateQScreenAndCanvasRenderSize();
+}
+
QT_END_NAMESPACE