summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorubkp <[email protected]>2023-12-11 05:11:20 -0300
committerGitHub <[email protected]>2023-12-11 09:11:20 +0100
commit39457ace2f8048aa82d180040b1bce9ca59a6b74 (patch)
tree54c9724ae96e08d5276906cf34652f39e623f6c2 /src
parent44eeda247597b7d89b93612495c3b7f291604b61 (diff)
downloadraylib-39457ace2f8048aa82d180040b1bce9ca59a6b74.tar.gz
raylib-39457ace2f8048aa82d180040b1bce9ca59a6b74.zip
[rcore] Add `ToggleBorderlessWindowed()` implementation for `PLATFORM_WEB` (#3622)
* Add ToggleBorderlessWindowed() for PLATFORM_WEB * Fix coding convention
Diffstat (limited to 'src')
-rw-r--r--src/platforms/rcore_web.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c
index ae210853..c322a1d5 100644
--- a/src/platforms/rcore_web.c
+++ b/src/platforms/rcore_web.c
@@ -211,7 +211,33 @@ void ToggleFullscreen(void)
// Toggle borderless windowed mode
void ToggleBorderlessWindowed(void)
{
- TRACELOG(LOG_WARNING, "ToggleBorderlessWindowed() not available on target platform");
+ const bool wasFullscreen = EM_ASM_INT( { if (document.fullscreenElement) return 1; }, 0);
+ if (wasFullscreen)
+ {
+ EM_ASM(document.exitFullscreen(););
+
+ CORE.Window.fullscreen = false;
+ CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE;
+ }
+
+ if (!IsWindowState(FLAG_BORDERLESS_WINDOWED_MODE))
+ {
+ // NOTE: 1. The setTimeouts handle the browser mode change delay
+ // 2. The style unset handles the possibility of a width="100%" like on the default shell.html file
+ EM_ASM(
+ setTimeout(function()
+ {
+ Module.requestFullscreen(true, true);
+ setTimeout(function()
+ {
+ canvas.style.width="unset";
+ }, 100);
+ }, 100);
+ );
+
+ CORE.Window.flags |= FLAG_BORDERLESS_WINDOWED_MODE;
+ }
+ else CORE.Window.flags &= ~FLAG_BORDERLESS_WINDOWED_MODE;
}
// Set window state: maximized, if resizable