Full-screen / resolution change: fix display flicker. (Fixes #965)

This commit is contained in:
tomcw 2021-06-19 15:06:04 +01:00
parent 0e275f0131
commit 7086ea5208
5 changed files with 12 additions and 4 deletions

View File

@ -896,7 +896,7 @@ static void RepeatInitialization(void)
static void Shutdown(void)
{
ChangeDisplaySettings(NULL, 0); // restore default resolution
// NB. WM_CLOSE has already called SetNormalMode() to exit full screen mode & restore default resolution
// Release COM
SysClk_UninitTimer();

View File

@ -38,6 +38,7 @@ Win32Frame::Win32Frame()
g_win_fullscreen_offsety = 0;
m_bestWidthForFullScreen = 0;
m_bestHeightForFullScreen = 0;
m_changedDisplaySettings = false;
btnfacebrush = (HBRUSH)0;
btnfacepen = (HPEN)0;

View File

@ -134,6 +134,7 @@ private:
int g_win_fullscreen_offsety;
UINT m_bestWidthForFullScreen;
UINT m_bestHeightForFullScreen;
bool m_changedDisplaySettings;
static const UINT MAX_DRAW_DEVICES = 10;
char* draw_devices[MAX_DRAW_DEVICES];

View File

@ -2126,6 +2126,7 @@ void Win32Frame::SetFullScreenMode(void)
DWORD dwFlags = 0;
LONG res = ChangeDisplaySettings(&devMode, dwFlags);
m_changedDisplaySettings = true;
}
//
@ -2175,7 +2176,12 @@ void Win32Frame::SetFullScreenMode(void)
//===========================================================================
void Win32Frame::SetNormalMode(void)
{
if (m_changedDisplaySettings)
{
// Only call ChangeDisplaySettings() if resolution has changed, otherwise there'll be a display flicker (GH#965)
ChangeDisplaySettings(NULL, 0); // restore default resolution
m_changedDisplaySettings = false;
}
FullScreenRevealCursor(); // Do before clearing g_bIsFullScreen flag