diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index 03c5a6f8..a0fdff91 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -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(); diff --git a/source/Windows/AppleWin.h b/source/Windows/AppleWin.h index 2e60ab95..31c348e2 100644 --- a/source/Windows/AppleWin.h +++ b/source/Windows/AppleWin.h @@ -9,4 +9,4 @@ bool GetLoadedSaveStateFlag(void); bool GetHookAltTab(void); bool GetHookAltGrControl(void); -extern bool g_bRestartFullScreen; +extern bool g_bRestartFullScreen; diff --git a/source/Windows/Win32Frame.cpp b/source/Windows/Win32Frame.cpp index e4173b22..8a47a37a 100644 --- a/source/Windows/Win32Frame.cpp +++ b/source/Windows/Win32Frame.cpp @@ -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; diff --git a/source/Windows/Win32Frame.h b/source/Windows/Win32Frame.h index 6ec88fb8..cbce057e 100644 --- a/source/Windows/Win32Frame.h +++ b/source/Windows/Win32Frame.h @@ -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]; diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index f8c70897..6f2473fd 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -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