From 9f76d50f19a151b6b5adb98646ea9b8f1941e755 Mon Sep 17 00:00:00 2001 From: Lactozilla <jp6781615@gmail.com> Date: Tue, 25 Jul 2023 01:45:34 -0300 Subject: [PATCH] Save window size if it's resized --- src/m_menu.c | 2 +- src/screen.c | 6 +++--- src/screen.h | 4 ++-- src/sdl/i_video.c | 6 +++++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 592bb55de4..9e571eb6f5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -13645,7 +13645,7 @@ static void M_HandleVideoMode(INT32 ch) if (vid.width == modedescs[vidm_selected].width && vid.height == modedescs[vidm_selected].height) { S_StartSound(NULL, sfx_strpst); - SCR_SetDefaultMode(); + SCR_SetDefaultMode(vid.width, vid.height); } else { diff --git a/src/screen.c b/src/screen.c index 89e03e03dc..59d94e0faa 100644 --- a/src/screen.c +++ b/src/screen.c @@ -456,10 +456,10 @@ void SCR_CheckDefaultMode(void) } // sets the modenum as the new default video mode to be saved in the config file -void SCR_SetDefaultMode(void) +void SCR_SetDefaultMode(INT32 width, INT32 height) { - CV_SetValue(cv_fullscreen.value ? &cv_scr_width : &cv_scr_width_w, vid.width); - CV_SetValue(cv_fullscreen.value ? &cv_scr_height : &cv_scr_height_w, vid.height); + CV_SetValue(cv_fullscreen.value ? &cv_scr_width : &cv_scr_width_w, width); + CV_SetValue(cv_fullscreen.value ? &cv_scr_height : &cv_scr_height_w, height); } // Change fullscreen on/off according to cv_fullscreen diff --git a/src/screen.h b/src/screen.h index edcfaadee2..42d62aa990 100644 --- a/src/screen.h +++ b/src/screen.h @@ -202,8 +202,8 @@ void SCR_Recalc(void); // Check parms once at startup void SCR_CheckDefaultMode(void); -// Set the mode number which is saved in the config -void SCR_SetDefaultMode(void); +// Set the resolution which is saved in the config +void SCR_SetDefaultMode(INT32 width, INT32 height); void SCR_CalculateFPS(void); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 846b4c742d..c29bafa7c1 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -671,7 +671,11 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) case SDL_WINDOWEVENT_MAXIMIZED: break; case SDL_WINDOWEVENT_SIZE_CHANGED: - SCR_SetWindowSize(evt.data1, evt.data2); + if ((SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN_DESKTOP) == 0) + { + SCR_SetWindowSize(evt.data1, evt.data2); + SCR_SetDefaultMode(evt.data1, evt.data2); + } break; } -- GitLab