Create win32_change_display_settings

This commit is contained in:
twinaphex 2018-04-15 17:55:37 +02:00
parent 87cf910396
commit 359de5c84b
3 changed files with 26 additions and 19 deletions

View File

@ -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)&current_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
}

View File

@ -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);

View File

@ -21,7 +21,8 @@
#include <stdlib.h>
#if defined(_WIN32)
#include <windows.h>
#include <windows.h>
#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: