Commit 5d8666e2 authored by twinaphex's avatar twinaphex
Browse files

Only one function calls EnumDisplaySettings now

parent 45e075c8
......@@ -1353,15 +1353,13 @@ void win32_get_video_output_prev(
unsigned curr_width = 0;
unsigned curr_height = 0;
memset(&dm, 0, sizeof(dm));
dm.dmSize = sizeof(dm);
win32_get_video_output_size(&curr_width, &curr_height);
if (win32_get_video_output(&dm, -1, sizeof(dm)))
{
curr_width = dm.dmPelsWidth;
curr_height = dm.dmPelsHeight;
}
for (i = 0;
EnumDisplaySettings(NULL, i, &dm) != 0;
i++)
for (i = 0; win32_get_video_output(&dm, i, sizeof(dm)); i++)
{
if ( dm.dmPelsWidth == curr_width
&& dm.dmPelsHeight == curr_height)
......@@ -1458,14 +1456,13 @@ void win32_get_video_output_next(
unsigned curr_width = 0;
unsigned curr_height = 0;
memset(&dm, 0, sizeof(dm));
dm.dmSize = sizeof(dm);
win32_get_video_output_size(&curr_width, &curr_height);
if (win32_get_video_output(&dm, -1, sizeof(dm)))
{
curr_width = dm.dmPelsWidth;
curr_height = dm.dmPelsHeight;
}
for (i = 0;
EnumDisplaySettings(NULL, i, &dm) != 0;
i++)
for (i = 0; win32_get_video_output(&dm, i, sizeof(dm)); i++)
{
if (found)
{
......@@ -1480,13 +1477,23 @@ void win32_get_video_output_next(
}
}
bool win32_get_video_output(DEVMODE *dm, int mode, size_t len)
{
memset(dm, 0, len);
dm->dmSize = len;
if (EnumDisplaySettings(NULL,
(mode == -1) ? ENUM_CURRENT_SETTINGS : mode, dm) == 0)
return false;
return true;
}
void win32_get_video_output_size(unsigned *width, unsigned *height)
{
DEVMODE dm;
memset(&dm, 0, sizeof(dm));
dm.dmSize = sizeof(dm);
if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm) != 0)
if (win32_get_video_output(&dm, -1, sizeof(dm)))
{
*width = dm.dmPelsWidth;
*height = dm.dmPelsHeight;
......
......@@ -101,6 +101,8 @@ void win32_check_window(bool *quit,
void win32_set_window(unsigned *width, unsigned *height,
bool fullscreen, bool windowed_full, void *rect_data);
bool win32_get_video_output(DEVMODE *dm, int mode, size_t len);
void win32_get_video_output_size(
unsigned *width, unsigned *height);
......
......@@ -213,7 +213,7 @@ static bool win32_display_server_set_resolution(void *data,
if (!serv)
return false;
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode);
win32_get_video_output(&curDevmode, -1, sizeof(curDevmode));
if (win32_orig_width == 0)
win32_orig_width = GetSystemMetrics(SM_CXSCREEN);
......@@ -238,7 +238,7 @@ static bool win32_display_server_set_resolution(void *data,
LONG res;
DEVMODE devmode;
if (!EnumDisplaySettings(NULL, iModeNum, &devmode))
if (!win32_get_video_output(&devmode, iModeNum, sizeof(devmode)))
break;
if (devmode.dmPelsWidth != width)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment