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

@ -60,7 +60,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
static bool g_bLoadedSaveState = false;
static bool g_bSysClkOK = false;
bool g_bRestartFullScreen = false;
bool g_bRestartFullScreen = false;
//===========================================================================
@ -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

@ -9,4 +9,4 @@ bool GetLoadedSaveStateFlag(void);
bool GetHookAltTab(void);
bool GetHookAltGrControl(void);
extern bool g_bRestartFullScreen;
extern bool g_bRestartFullScreen;

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)
{
ChangeDisplaySettings(NULL, 0); // restore default resolution
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