Borderless window toggle

https://github.com/Indev450/SRB2Kart-Saturn/pull/193
This commit is contained in:
NepDisk 2025-08-13 19:26:25 -04:00
parent bfa463934f
commit e0d0d99cf3
3 changed files with 17 additions and 3 deletions

View file

@ -153,6 +153,8 @@ void I_EndRead(void);
UINT32 I_GetRefreshRate(void);
void I_SetBorderlessWindow(void);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -80,7 +80,8 @@ consvar_t cv_renderer = CVAR_INIT ("renderer", "Software", CV_SAVE|CV_NOLUA|CV_C
static void SCR_ChangeFullscreen(void);
consvar_t cv_fullscreen = CVAR_INIT ("fullscreen", "Yes", CV_SAVE|CV_CALL, CV_YesNo, SCR_ChangeFullscreen);
static CV_PossibleValue_t fullscreen_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Borderless Window"}, {0, NULL}};
consvar_t cv_fullscreen = CVAR_INIT ("fullscreen", "Yes", CV_SAVE|CV_CALL, fullscreen_cons_t, SCR_ChangeFullscreen);
// =========================================================================
// SCREEN VARIABLES
@ -449,6 +450,8 @@ void SCR_SetDefaultMode(void)
void SCR_ChangeFullscreen(void)
{
#ifdef DIRECTFULLSCREEN
I_SetBorderlessWindow(); // Running this here so we can have borderless window at startup
// allow_fullscreen is set by VID_PrepareModeList
// it is used to prevent switching to fullscreen during startup
if (!allow_fullscreen)

View file

@ -110,7 +110,7 @@ UINT8 graphics_started = 0; // Is used in console.c and screen.c
boolean allow_fullscreen = false;
static SDL_bool disable_fullscreen = SDL_FALSE;
#define USE_FULLSCREEN (disable_fullscreen||!allow_fullscreen)?static_cast<SDL_bool>(0):static_cast<SDL_bool>(cv_fullscreen.value)
#define USE_FULLSCREEN (disable_fullscreen||!allow_fullscreen)?static_cast<SDL_bool>(0):static_cast<SDL_bool>(cv_fullscreen.value == 1)
static SDL_bool disable_mouse = SDL_FALSE;
#define USE_MOUSEINPUT (!disable_mouse && cv_usemouse.value && havefocus)
@ -380,6 +380,7 @@ static SDL_bool SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_b
{
wasfullscreen = SDL_TRUE;
SDL_SetWindowFullscreen(window, fullscreen_type);
I_SetBorderlessWindow();
}
else // windowed mode
{
@ -1906,7 +1907,6 @@ void I_ShutdownGraphics(void)
SDL_QuitSubSystem(SDL_INIT_VIDEO);
framebuffer = SDL_FALSE;
}
#endif
UINT32 I_GetRefreshRate(void)
{
@ -1917,3 +1917,12 @@ UINT32 I_GetRefreshRate(void)
// trouble querying mode over and over again.
return refresh_rate;
}
void I_SetBorderlessWindow(void)
{
SDL_bool borderless = (cv_fullscreen.value == 2) ? SDL_FALSE : SDL_TRUE;
SDL_SetWindowBordered(window, borderless);
}
#endif