diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 4373168740..fb46870faa 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -256,6 +256,19 @@ void win32_monitor_from_window(void) #endif } +int win32_change_display_settings(const char *str, void *devmode_data, + unsigned flags) +{ +#if _WIN32_WINDOWS >= 0x0410 || _WIN32_WINNT >= 0x0410 + /* Windows 98 and later codepath */ + return ChangeDisplaySettingsEx(str, (DEVMODE*)devmode_data, + NULL, flags, NULL); +#else + /* Windows 95 / NT codepath */ + return ChangeDisplaySettings((DEVMODE*)devmode_data, flags); +#endif +} + void win32_monitor_get_info(void) { MONITORINFOEX current_mon; @@ -265,13 +278,7 @@ void win32_monitor_get_info(void) GetMonitorInfo(win32_monitor_last, (LPMONITORINFO)¤t_mon); -#if _WIN32_WINDOWS >= 0x0410 || _WIN32_WINNT >= 0x0410 - /* Windows 98 and later codepath */ - ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL); -#else - /* Windows 95 / NT codepath */ - ChangeDisplaySettings(NULL, 0); -#endif + win32_change_display_settings(current_mon.szDevice, NULL, 0); } void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id) @@ -902,14 +909,8 @@ static bool win32_monitor_set_fullscreen( RARCH_LOG("Setting fullscreen to %ux%u @ %uHz on device %s.\n", width, height, refresh, dev_name); -#if _WIN32_WINDOWS >= 0x0410 || _WIN32_WINNT >= 0x0410 - /* Windows 98 and later codepath */ - return ChangeDisplaySettingsEx(dev_name, &devmode, - NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL; -#else - /* Windows 95 / NT codepath */ - return ChangeDisplaySettings(&devmode, CDS_FULLSCREEN); -#endif + return win32_change_display_settings(dev_name, &devmode, + CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL; #endif } diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index d780dc5a67..4220997fc2 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -56,6 +56,9 @@ void win32_monitor_get_info(void); void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id); +int win32_change_display_settings(const char *str, void *devmode_data, + unsigned flags); + void create_graphics_context(HWND hwnd, bool *quit); void create_gdi_context(HWND hwnd, bool *quit); diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index ef9d4b169b..12a1de932a 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -21,7 +21,8 @@ #include #if defined(_WIN32) - #include +#include +#include "common/win32_common.h" #endif #include "video_driver.h" @@ -235,13 +236,15 @@ void crt_switch_res(int width, int height, int f_restore,int ra_hz) if (devmode.dmDisplayFrequency != freq) continue; - devmode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; - res = ChangeDisplaySettings(&devmode, CDS_TEST); + devmode.dmFields |= + DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + res = + win32_change_display_settings(NULL, &devmode, CDS_TEST); switch (res) { case DISP_CHANGE_SUCCESSFUL: - res = ChangeDisplaySettings(&devmode, flags); + res = win32_change_display_settings(NULL, &devmode, flags); switch (res) { case DISP_CHANGE_SUCCESSFUL: