From 9d30fe3d34d984f381beff18e96a02ca2f6fc68e Mon Sep 17 00:00:00 2001 From: ericek111 Date: Wed, 25 Mar 2026 22:55:44 +0100 Subject: [PATCH] wasm: add a fullscreen button --- src/ui/Application.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ui/Application.cpp b/src/ui/Application.cpp index 27093cd..d316d8d 100644 --- a/src/ui/Application.cpp +++ b/src/ui/Application.cpp @@ -7,7 +7,21 @@ #ifdef __EMSCRIPTEN__ #include +#include #include + +EM_JS(void, js_toggleFullscreen, (), { + if (document.fullscreenElement) { + document.exitFullscreen(); + } else { + document.documentElement.requestFullscreen(); + } +}); + +EM_JS(int, js_isFullscreen, (), { + return document.fullscreenElement ? 1 : 0; +}); + #else #include #endif @@ -369,6 +383,12 @@ void Application::render() { ImGui::EndMenu(); } +#ifdef __EMSCRIPTEN__ + if (ImGui::SmallButton(js_isFullscreen() ? "Exit Fullscreen" : "Fullscreen")) { + js_toggleFullscreen(); + } +#endif + // Right-aligned status in menu bar { float barW = ImGui::GetWindowWidth();