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.
This commit is contained in:
SuperUserNameMan 2024-07-11 18:36:56 +02:00 committed by GitHub
parent a76adf9a48
commit 545665da87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -144,6 +144,15 @@ bool WindowShouldClose(void)
// Toggle fullscreen mode // Toggle fullscreen mode
void ToggleFullscreen(void) 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) if (!CORE.Window.fullscreen)
{ {
// Store previous window position (in case we exit fullscreen) // Store previous window position (in case we exit fullscreen)
@ -201,13 +210,13 @@ void ToggleFullscreen(void)
// Toggle borderless windowed mode // Toggle borderless windowed mode
void ToggleBorderlessWindowed(void) 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) 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(); ToggleFullscreen();
wasOnFullscreen = true; return;
} }
const int monitor = GetCurrentMonitor(); const int monitor = GetCurrentMonitor();
@ -222,9 +231,8 @@ void ToggleBorderlessWindowed(void)
{ {
if (!IsWindowState(FLAG_BORDERLESS_WINDOWED_MODE)) if (!IsWindowState(FLAG_BORDERLESS_WINDOWED_MODE))
{ {
// Store screen position and size // Store screen position and size :
// NOTE: If it was on fullscreen, screen position was already stored, so skip setting it here glfwGetWindowPos(platform.handle, &CORE.Window.previousPosition.x, &CORE.Window.previousPosition.y);
if (!wasOnFullscreen) glfwGetWindowPos(platform.handle, &CORE.Window.previousPosition.x, &CORE.Window.previousPosition.y);
// We need to save the "render size" intead of the "screen size" // We need to save the "render size" intead of the "screen size"
// because we might have FLAG_WINDOW_HIGHDPI enabled. // because we might have FLAG_WINDOW_HIGHDPI enabled.