Skip to content

Commit

Permalink
toggle currently active fullscreen mode and leave
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SuperUserNameMan committed Jul 11, 2024
1 parent a76adf9 commit 545665d
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/platforms/rcore_desktop_glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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.
Expand Down

0 comments on commit 545665d

Please sign in to comment.