From 545665da8766fbd178b8e26dc14ec5dfa1dabdc3 Mon Sep 17 00:00:00 2001 From: SuperUserNameMan <9801802+SuperUserNameMan@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:36:56 +0200 Subject: [PATCH] toggle currently active fullscreen mode and leave Trying to go straight forward from one fullscreen mode to another make things more complicated to control. Seems a full loop is required when trying to change fullscreen modes and window size properly for now. Maybe will restore the ability to jump from one fullscreen mode to another when more cleaning will be done deeper in the rabbit hole. --- src/platforms/rcore_desktop_glfw.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 1a9706f30..93d6033c5 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -144,6 +144,15 @@ bool WindowShouldClose(void) // Toggle fullscreen mode void ToggleFullscreen(void) { + if (IsWindowState(FLAG_BORDERLESS_WINDOWED_MODE)) + { + // We can't go straighforward from one fullscreen mode to an other + // there needs to be at least one loop between them + // so we just toggle the currently active fullscreen mode and leave. + ToggleBorderlessWindowed(); + return; + } + if (!CORE.Window.fullscreen) { // Store previous window position (in case we exit fullscreen) @@ -201,13 +210,13 @@ void ToggleFullscreen(void) // Toggle borderless windowed mode void ToggleBorderlessWindowed(void) { - // Leave fullscreen before attempting to set borderless windowed mode and get screen position from it - bool wasOnFullscreen = false; if (CORE.Window.fullscreen) { - CORE.Window.previousPosition = CORE.Window.position; + // We can't go straighforward from one fullscreen mode to an other + // there needs to be at least one loop between them + // so we just toggle the currently active fullscreen mode and leave. ToggleFullscreen(); - wasOnFullscreen = true; + return; } const int monitor = GetCurrentMonitor(); @@ -222,9 +231,8 @@ void ToggleBorderlessWindowed(void) { if (!IsWindowState(FLAG_BORDERLESS_WINDOWED_MODE)) { - // Store screen position and size - // NOTE: If it was on fullscreen, screen position was already stored, so skip setting it here - if (!wasOnFullscreen) glfwGetWindowPos(platform.handle, &CORE.Window.previousPosition.x, &CORE.Window.previousPosition.y); + // Store screen position and size : + glfwGetWindowPos(platform.handle, &CORE.Window.previousPosition.x, &CORE.Window.previousPosition.y); // We need to save the "render size" intead of the "screen size" // because we might have FLAG_WINDOW_HIGHDPI enabled.