From 78f994eced204cfa1acd358ac404193f61fca45e Mon Sep 17 00:00:00 2001 From: Alug <136046486+alufolie91@users.noreply.github.com> Date: Sat, 26 Jul 2025 21:42:50 +0100 Subject: [PATCH] Merge pull request #193 from chromaticpipe/borderlesswindowtoggle Borderless window toggle --- src/dedicated/i_video.c | 5 +++++ src/i_video.h | 2 ++ src/screen.c | 6 +++++- src/sdl/i_video.c | 9 ++++++++- 4 files changed, 20 insertions(+), 2 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 54c6cd2b4..0751e1219 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 extern float InvSupersampleFactorX; extern float InvSupersampleFactorY; diff --git a/src/screen.c b/src/screen.c index c9a90d23a..06581ec02 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 336e460dd..383af0a04 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -152,7 +152,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) @@ -1366,6 +1366,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) { wasfullscreen = SDL_TRUE; SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); + I_SetBorderlessWindow(); } else // windowed mode { @@ -2170,4 +2171,10 @@ static void Impl_SetVsync(void) #endif } +void I_SetBorderlessWindow(void) +{ + SDL_bool borderless = (cv_fullscreen.value == 2) ? SDL_FALSE : SDL_TRUE; + SDL_SetWindowBordered(window, borderless); +} + #endif