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();