From d9c7a40d4a6af003bbe3912e8389e92e4c2e13bb Mon Sep 17 00:00:00 2001 From: chromaticpipe <127907268+chromaticpipe@users.noreply.github.com> Date: Sat, 26 Jul 2025 11:58:55 -0500 Subject: [PATCH 1/2] Borderless window toggle --- src/sdl/i_video.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f4a2c288c..e357d98e8 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -134,9 +134,12 @@ static INT32 desktopwidth = 0, desktopheight = 0; static void I_CheckDesktopRes(void); +static void VID_SetBorderless(void); + // synchronize page flipping with screen refresh consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Impl_SetVsync, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_borderless = {"borderless", "Off", CV_SAVE|CV_CALL, CV_OnOff, VID_SetBorderless, 0, NULL, NULL, 0, 0, NULL}; static void mousegrabOnChange(void); consvar_t cv_alwaysgrabmouse = {"alwaysgrabmouse", "Off", CV_SAVE|CV_CALL, CV_OnOff, mousegrabOnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -1353,6 +1356,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) { wasfullscreen = SDL_TRUE; SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); + VID_SetBorderless(); } else // windowed mode { @@ -1877,6 +1881,7 @@ void I_StartupGraphics(void) CV_RegisterVar (&cv_vidwait); CV_RegisterVar (&cv_stretch); CV_RegisterVar (&cv_alwaysgrabmouse); + CV_RegisterVar (&cv_borderless); disable_mouse = M_CheckParm("-nomouse"); disable_fullscreen = M_CheckParm("-win") ? 1 : 0; @@ -2157,4 +2162,10 @@ static void Impl_SetVsync(void) #endif } +static void VID_SetBorderless(void) +{ + SDL_bool borderless = (cv_borderless.value) ? SDL_FALSE : SDL_TRUE; + SDL_SetWindowBordered(window, borderless); +} + #endif -- 2.54.0 From fae50c0e19c539517860af8d6aa6f81118df6814 Mon Sep 17 00:00:00 2001 From: chromaticpipe <127907268+chromaticpipe@users.noreply.github.com> Date: Sat, 26 Jul 2025 15:18:03 -0500 Subject: [PATCH 2/2] Make it a part of fullscreen cvar --- src/dedicated/i_video.c | 5 +++++ src/i_video.h | 2 ++ src/screen.c | 6 +++++- src/sdl/i_video.c | 12 ++++-------- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/dedicated/i_video.c b/src/dedicated/i_video.c index 6c0b6644a..8f8781e9e 100644 --- a/src/dedicated/i_video.c +++ b/src/dedicated/i_video.c @@ -152,3 +152,8 @@ boolean I_UseNativeKeyboard(void) { return false; } + +void I_SetBorderlessWindow(void) +{ + +} diff --git a/src/i_video.h b/src/i_video.h index 68042a654..88d295ed9 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -145,6 +145,8 @@ boolean I_UseNativeKeyboard(void); boolean I_CheckNativeRes(void); +void I_SetBorderlessWindow(void); + #ifdef USE_FBO_OGL void RefreshOGLSDLSurface(void); diff --git a/src/screen.c b/src/screen.c index eb6c2bc82..a8a3ca78b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -66,7 +66,9 @@ static void Highreshudscale_OnChange(void) static void SCR_ChangeFullscreen (void); -consvar_t cv_fullscreen = {"fullscreen", "Yes", CV_SAVE|CV_CALL, CV_YesNo, SCR_ChangeFullscreen, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t fullscreen_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Borderless Window"}, {0, NULL}}; + +consvar_t cv_fullscreen = {"fullscreen", "Yes", CV_SAVE|CV_CALL, fullscreen_cons_t, SCR_ChangeFullscreen, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t accuratefps_cons_t[] = {{0, "Inaccurate"}, {1, "Accurate"}, {0, NULL}}; consvar_t cv_accuratefps = {"fpssampling", "1", CV_SAVE, accuratefps_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -325,6 +327,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) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index e357d98e8..fa55e62f1 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -134,12 +134,9 @@ static INT32 desktopwidth = 0, desktopheight = 0; static void I_CheckDesktopRes(void); -static void VID_SetBorderless(void); - // synchronize page flipping with screen refresh consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Impl_SetVsync, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_borderless = {"borderless", "Off", CV_SAVE|CV_CALL, CV_OnOff, VID_SetBorderless, 0, NULL, NULL, 0, 0, NULL}; static void mousegrabOnChange(void); consvar_t cv_alwaysgrabmouse = {"alwaysgrabmouse", "Off", CV_SAVE|CV_CALL, CV_OnOff, mousegrabOnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -153,7 +150,7 @@ UINT8 graphics_started = 0; // Is used in console.c and screen.c // To disable fullscreen at startup; is set in VID_PrepareModeList boolean allow_fullscreen = false; static SDL_bool disable_fullscreen = SDL_FALSE; -#define USE_FULLSCREEN (disable_fullscreen||!allow_fullscreen)?0:cv_fullscreen.value +#define USE_FULLSCREEN (disable_fullscreen||!allow_fullscreen)? 0: (cv_fullscreen.value == 1) static SDL_bool disable_mouse = SDL_FALSE; #define USE_MOUSEINPUT (!disable_mouse && cv_usemouse.value && havefocus) #define MOUSE_MENU false //(!disable_mouse && cv_usemouse.value && menuactive && !USE_FULLSCREEN) @@ -1356,7 +1353,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) { wasfullscreen = SDL_TRUE; SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); - VID_SetBorderless(); + I_SetBorderlessWindow(); } else // windowed mode { @@ -1881,7 +1878,6 @@ void I_StartupGraphics(void) CV_RegisterVar (&cv_vidwait); CV_RegisterVar (&cv_stretch); CV_RegisterVar (&cv_alwaysgrabmouse); - CV_RegisterVar (&cv_borderless); disable_mouse = M_CheckParm("-nomouse"); disable_fullscreen = M_CheckParm("-win") ? 1 : 0; @@ -2162,9 +2158,9 @@ static void Impl_SetVsync(void) #endif } -static void VID_SetBorderless(void) +void I_SetBorderlessWindow(void) { - SDL_bool borderless = (cv_borderless.value) ? SDL_FALSE : SDL_TRUE; + SDL_bool borderless = (cv_fullscreen.value == 2) ? SDL_FALSE : SDL_TRUE; SDL_SetWindowBordered(window, borderless); } -- 2.54.0