Add mon_id argument to win32_get_monitor_info

This commit is contained in:
twinaphex 2015-11-11 17:47:56 +01:00
parent 8f9218ab1b
commit e0720cd764
3 changed files with 21 additions and 5 deletions

View File

@ -97,9 +97,9 @@ void win32_monitor_get_info(void)
ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL); ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL);
} }
void win32_monitor_info(void *data, void *hm_data) void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id)
{ {
unsigned fs_monitor; unsigned i, fs_monitor;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
MONITORINFOEX *mon = (MONITORINFOEX*)data; MONITORINFOEX *mon = (MONITORINFOEX*)data;
HMONITOR *hm_to_use = (HMONITOR*)hm_data; HMONITOR *hm_to_use = (HMONITOR*)hm_data;
@ -112,7 +112,21 @@ void win32_monitor_info(void *data, void *hm_data)
if (fs_monitor && fs_monitor <= win32_monitor_count if (fs_monitor && fs_monitor <= win32_monitor_count
&& win32_monitor_all[fs_monitor - 1]) && win32_monitor_all[fs_monitor - 1])
{
*hm_to_use = win32_monitor_all[fs_monitor - 1]; *hm_to_use = win32_monitor_all[fs_monitor - 1];
*mon_id = fs_monitor - 1;
}
else
{
for (i = 0; i < win32_monitor_count; i++)
{
if (win32_monitor_all[i] != *hm_to_use)
continue;
*mon_id = i;
break;
}
}
memset(mon, 0, sizeof(*mon)); memset(mon, 0, sizeof(*mon));
mon->cbSize = sizeof(MONITORINFOEX); mon->cbSize = sizeof(MONITORINFOEX);

View File

@ -46,7 +46,7 @@ void win32_monitor_from_window(HWND data, bool destroy);
void win32_monitor_get_info(void); void win32_monitor_get_info(void);
void win32_monitor_info(void *data, void *hm_data); void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id);
#endif #endif
bool win32_suppress_screensaver(void *data, bool enable); bool win32_suppress_screensaver(void *data, bool enable);

View File

@ -374,11 +374,12 @@ static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *he
if (!g_hwnd) if (!g_hwnd)
{ {
unsigned mon_id;
RECT mon_rect; RECT mon_rect;
MONITORINFOEX current_mon; MONITORINFOEX current_mon;
HMONITOR hm_to_use = NULL; HMONITOR hm_to_use = NULL;
win32_monitor_info(&current_mon, &hm_to_use); win32_monitor_info(&current_mon, &hm_to_use, &mon_id);
mon_rect = current_mon.rcMonitor; mon_rect = current_mon.rcMonitor;
*width = mon_rect.right - mon_rect.left; *width = mon_rect.right - mon_rect.left;
*height = mon_rect.bottom - mon_rect.top; *height = mon_rect.bottom - mon_rect.top;
@ -446,6 +447,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data,
DWORD style; DWORD style;
MSG msg; MSG msg;
RECT mon_rect; RECT mon_rect;
unsigned mon_id;
MONITORINFOEX current_mon; MONITORINFOEX current_mon;
float refresh_mod; float refresh_mod;
unsigned refresh; unsigned refresh;
@ -455,7 +457,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data,
driver_t *driver = driver_get_ptr(); driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
win32_monitor_info(&current_mon, &hm_to_use); win32_monitor_info(&current_mon, &hm_to_use, &mon_id);
mon_rect = current_mon.rcMonitor; mon_rect = current_mon.rcMonitor;
g_resize_width = width; g_resize_width = width;