(Win32/DispServer) Improve video resolution switching
* Only switch to a display mode with the same current bit-depth and screen rotation * Only switch to a display mode with default stretching mode * Cleanup the function for consistency with other functions
This commit is contained in:
parent
9ec3a5ccad
commit
2e57a690ce
|
@ -222,64 +222,70 @@ static bool win32_display_server_set_window_decorations(void *data, bool on)
|
||||||
static bool win32_display_server_set_resolution(void *data,
|
static bool win32_display_server_set_resolution(void *data,
|
||||||
unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset)
|
unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset)
|
||||||
{
|
{
|
||||||
DEVMODE curDevmode;
|
DEVMODE dm = {0};
|
||||||
int iModeNum;
|
LONG res = 0;
|
||||||
int freq = int_hz;
|
unsigned i = 0;
|
||||||
int depth = 0;
|
unsigned curr_bpp = 0;
|
||||||
|
#if _WIN32_WINNT >= 0x0500
|
||||||
|
unsigned curr_orientation = 0;
|
||||||
|
#endif
|
||||||
dispserv_win32_t *serv = (dispserv_win32_t*)data;
|
dispserv_win32_t *serv = (dispserv_win32_t*)data;
|
||||||
|
|
||||||
if (!serv)
|
if (!serv)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
win32_get_video_output(&curDevmode, -1, sizeof(curDevmode));
|
win32_get_video_output(&dm, -1, sizeof(dm));
|
||||||
|
|
||||||
if (serv->orig_width == 0)
|
if (serv->orig_width == 0)
|
||||||
serv->orig_width = GetSystemMetrics(SM_CXSCREEN);
|
serv->orig_width = GetSystemMetrics(SM_CXSCREEN);
|
||||||
serv->orig_refresh = curDevmode.dmDisplayFrequency;
|
|
||||||
if (serv->orig_height == 0)
|
if (serv->orig_height == 0)
|
||||||
serv->orig_height = GetSystemMetrics(SM_CYSCREEN);
|
serv->orig_height = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
serv->orig_refresh = dm.dmDisplayFrequency;
|
||||||
|
|
||||||
/* Used to stop super resolution bug */
|
/* Used to stop super resolution bug */
|
||||||
if (width == curDevmode.dmPelsWidth)
|
if (width == dm.dmPelsWidth)
|
||||||
width = 0;
|
width = 0;
|
||||||
if (width == 0)
|
if (width == 0)
|
||||||
width = curDevmode.dmPelsWidth;
|
width = dm.dmPelsWidth;
|
||||||
if (height == 0)
|
if (height == 0)
|
||||||
height = curDevmode.dmPelsHeight;
|
height = dm.dmPelsHeight;
|
||||||
if (depth == 0)
|
if (curr_bpp == 0)
|
||||||
depth = curDevmode.dmBitsPerPel;
|
curr_bpp = dm.dmBitsPerPel;
|
||||||
if (freq == 0)
|
if (int_hz == 0)
|
||||||
freq = curDevmode.dmDisplayFrequency;
|
int_hz = dm.dmDisplayFrequency;
|
||||||
|
#if _WIN32_WINNT >= 0x0500
|
||||||
|
if (curr_orientation == 0)
|
||||||
|
curr_orientation = dm.dmDisplayOrientation;
|
||||||
|
#endif
|
||||||
|
|
||||||
for (iModeNum = 0;; iModeNum++)
|
for (i = 0; win32_get_video_output(&dm, i, sizeof(dm)); i++)
|
||||||
{
|
{
|
||||||
LONG res;
|
if (dm.dmPelsWidth != width)
|
||||||
DEVMODE devmode;
|
|
||||||
|
|
||||||
if (!win32_get_video_output(&devmode, iModeNum, sizeof(devmode)))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (devmode.dmPelsWidth != width)
|
|
||||||
continue;
|
continue;
|
||||||
|
if (dm.dmPelsHeight != height)
|
||||||
if (devmode.dmPelsHeight != height)
|
|
||||||
continue;
|
continue;
|
||||||
|
if (dm.dmBitsPerPel != curr_bpp)
|
||||||
if (devmode.dmBitsPerPel != depth)
|
|
||||||
continue;
|
continue;
|
||||||
|
if (dm.dmDisplayFrequency != int_hz)
|
||||||
if (devmode.dmDisplayFrequency != freq)
|
|
||||||
continue;
|
continue;
|
||||||
|
#if _WIN32_WINNT >= 0x0500
|
||||||
|
if (dm.dmDisplayOrientation != curr_orientation)
|
||||||
|
continue;
|
||||||
|
if (dm.dmDisplayFixedOutput != DMDFO_DEFAULT)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
devmode.dmFields |=
|
dm.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
|
||||||
DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
|
#if _WIN32_WINNT >= 0x0500
|
||||||
res =
|
dm.dmFields |= DM_DISPLAYORIENTATION;
|
||||||
win32_change_display_settings(NULL, &devmode, CDS_TEST);
|
#endif
|
||||||
|
|
||||||
|
res = win32_change_display_settings(NULL, &dm, CDS_TEST);
|
||||||
|
|
||||||
switch (res)
|
switch (res)
|
||||||
{
|
{
|
||||||
case DISP_CHANGE_SUCCESSFUL:
|
case DISP_CHANGE_SUCCESSFUL:
|
||||||
res = win32_change_display_settings(NULL, &devmode, 0);
|
res = win32_change_display_settings(NULL, &dm, 0);
|
||||||
switch (res)
|
switch (res)
|
||||||
{
|
{
|
||||||
case DISP_CHANGE_SUCCESSFUL:
|
case DISP_CHANGE_SUCCESSFUL:
|
||||||
|
|
Loading…
Reference in New Issue