Full-screen: Retain uniform x and y scaling, unless user specifies a full-screen resolution (#1121)

This commit is contained in:
tomcw 2022-09-24 17:13:09 +01:00
parent 3875b7b433
commit 4a7f05ed36
3 changed files with 18 additions and 0 deletions

View File

@ -64,6 +64,8 @@ static bool g_bSysClkOK = false;
bool g_bRestartFullScreen = false;
static bool g_fullScreenResolutionChangedByUser = false;
//===========================================================================
bool GetLoadedSaveStateFlag(void)
@ -86,6 +88,11 @@ bool GetHookAltGrControl(void)
return g_bHookAltGrControl;
}
bool GetFullScreenResolutionChangedByUser(void)
{
return g_fullScreenResolutionChangedByUser;
}
static void ResetToLogoMode(void)
{
g_nAppMode = MODE_LOGO;
@ -809,6 +816,9 @@ static void RepeatInitialization(void)
LogFileOutput("Best resolution for -fs-width/height=x switch(es): Width=%d, Height=%d\n", bestWidth, bestHeight);
else
LogFileOutput("Failed to set parameter for -fs-width/height=x switch(es)\n");
if (res)
g_fullScreenResolutionChangedByUser = true;
}
// Pre: may need g_hFrameWindow for MessageBox errors

View File

@ -8,5 +8,6 @@ void SingleStep(bool bReinit);
bool GetLoadedSaveStateFlag(void);
bool GetHookAltTab(void);
bool GetHookAltGrControl(void);
bool GetFullScreenResolutionChangedByUser(void);
extern bool g_bRestartFullScreen;

View File

@ -2149,6 +2149,13 @@ void Win32Frame::SetFullScreenMode(void)
scalex = width / GetVideo().GetFrameBufferBorderlessWidth();
scaley = height / GetVideo().GetFrameBufferBorderlessHeight();
// Retain aspect ratio if user hasn't changed full-screen resolution (GH#1121)
if (!GetFullScreenResolutionChangedByUser())
{
const int minimumScale = (scalex <= scaley) ? scalex : scaley;
scalex = scaley = minimumScale;
}
// NB. Separate x,y scaling is OK in full-screen mode
// . eg. SHR 640x400 (scalex=2, scaley=3) => 1280x1200, which roughly gives a 4:3 aspect ratio for a resolution of 1600x1200
g_win_fullscreen_offsetx = ((int)width - (int)(scalex * GetVideo().GetFrameBufferBorderlessWidth())) / 2;