From 70df9cd0cd33e058b5e5c6e32cbe8284ad3c6b5b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 31 May 2014 12:21:55 -0700 Subject: [PATCH] Fullscreen to windowed mode switch From Melesie I noticed that when user switches from fullscreen mode to windowed mode and exits application while in windowed mode, Windows performs an additional change of display settings, even though desktop resolution is the same as current one. This causes short black screen to show up. The only way I know of avoiding this is to explicitly switch to default display settings found in registry. MSDN documentation for ChangeDisplaySettingsEx states: Passing NULL for the lpDevMode parameter and 0 for the dwFlags parameter is the easiest way to return to the default mode after a dynamic mode change. --- src/video/windows/SDL_windowsmodes.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index 1687e277a..f64a5788b 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -274,9 +274,11 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata; LONG status; - status = - ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode, - NULL, CDS_FULLSCREEN, NULL); + if (mode->driverdata == display->desktop_mode.driverdata) { + status = ChangeDisplaySettingsEx(displaydata->DeviceName, NULL, NULL, 0, NULL); + } else { + status = ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode, NULL, CDS_FULLSCREEN, NULL); + } if (status != DISP_CHANGE_SUCCESSFUL) { const char *reason = "Unknown reason"; switch (status) {