Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
M374LX committed Oct 8, 2023
1 parent 12cc0d8 commit aa11065
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/rcore_desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,27 @@ void ToggleFullscreen(void)
}
else
{
int width = CORE.Window.screen.width;
int height = CORE.Window.screen.height;
int refreshRate = GLFW_DONT_CARE;

CORE.Window.previousScreen.width = width;
CORE.Window.previousScreen.height = height;

if (IsWindowState(FLAG_FULLSCREEN_DESKTOP))
{
width = GetMonitorWidth(monitorIndex);
height = GetMonitorHeight(monitorIndex);
refreshRate = GetMonitorRefreshRate(monitorIndex);

CORE.Window.screen.width = width;
CORE.Window.screen.height = height;
}

CORE.Window.fullscreen = true;
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;

glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, width, height, refreshRate);
}

}
Expand All @@ -357,7 +374,7 @@ void ToggleFullscreen(void)
CORE.Window.fullscreen = false;
CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE;

glfwSetWindowMonitor(CORE.Window.handle, NULL, CORE.Window.position.x, CORE.Window.position.y, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
glfwSetWindowMonitor(CORE.Window.handle, NULL, CORE.Window.position.x, CORE.Window.position.y, CORE.Window.previousScreen.width, CORE.Window.previousScreen.height, GLFW_DONT_CARE);
}

// Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS)
Expand Down Expand Up @@ -482,6 +499,11 @@ void SetWindowState(unsigned int flags)
CORE.Window.flags |= FLAG_VSYNC_HINT;
}

if (((CORE.Window.flags & FLAG_FULLSCREEN_DESKTOP) != (flags & FLAG_FULLSCREEN_DESKTOP)) && ((flags & FLAG_FULLSCREEN_DESKTOP) > 0))
{
CORE.Window.flags |= FLAG_FULLSCREEN_DESKTOP;
}

// State change: FLAG_BORDERLESS_WINDOWED_MODE
// NOTE: This must be handled before FLAG_FULLSCREEN_MODE because ToggleBorderlessWindowed() needs to get some fullscreen values if fullscreen is running
if (((CORE.Window.flags & FLAG_BORDERLESS_WINDOWED_MODE) != (flags & FLAG_BORDERLESS_WINDOWED_MODE)) && ((flags & FLAG_BORDERLESS_WINDOWED_MODE) > 0))
Expand Down Expand Up @@ -597,6 +619,11 @@ void ClearWindowState(unsigned int flags)
CORE.Window.flags &= ~FLAG_VSYNC_HINT;
}

if (((CORE.Window.flags & FLAG_FULLSCREEN_DESKTOP) > 0) && ((flags & FLAG_FULLSCREEN_DESKTOP) > 0))
{
CORE.Window.flags &= ~FLAG_FULLSCREEN_DESKTOP;
}

// State change: FLAG_BORDERLESS_WINDOWED_MODE
// NOTE: This must be handled before FLAG_FULLSCREEN_MODE because ToggleBorderlessWindowed() needs to get some fullscreen values if fullscreen is running
if (((CORE.Window.flags & FLAG_BORDERLESS_WINDOWED_MODE) > 0) && ((flags & FLAG_BORDERLESS_WINDOWED_MODE) > 0))
Expand Down

0 comments on commit aa11065

Please sign in to comment.