From e0720cd7648c791ed415b143d9da9d922a82fd58 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 17:47:56 +0100 Subject: [PATCH] Add mon_id argument to win32_get_monitor_info --- gfx/common/win32_common.c | 18 ++++++++++++++++-- gfx/common/win32_common.h | 2 +- gfx/drivers_context/wgl_ctx.c | 6 ++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index cc8a8331d1..82a3a7f03e 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -97,9 +97,9 @@ void win32_monitor_get_info(void) 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(); MONITORINFOEX *mon = (MONITORINFOEX*)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 && 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)); mon->cbSize = sizeof(MONITORINFOEX); diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index c24b463677..91a5f77b52 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -46,7 +46,7 @@ void win32_monitor_from_window(HWND data, bool destroy); 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 bool win32_suppress_screensaver(void *data, bool enable); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 80856f1bb7..cccdff2bc1 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -374,11 +374,12 @@ static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *he if (!g_hwnd) { + unsigned mon_id; RECT mon_rect; MONITORINFOEX current_mon; HMONITOR hm_to_use = NULL; - win32_monitor_info(¤t_mon, &hm_to_use); + win32_monitor_info(¤t_mon, &hm_to_use, &mon_id); mon_rect = current_mon.rcMonitor; *width = mon_rect.right - mon_rect.left; *height = mon_rect.bottom - mon_rect.top; @@ -446,6 +447,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, DWORD style; MSG msg; RECT mon_rect; + unsigned mon_id; MONITORINFOEX current_mon; float refresh_mod; unsigned refresh; @@ -455,7 +457,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); - win32_monitor_info(¤t_mon, &hm_to_use); + win32_monitor_info(¤t_mon, &hm_to_use, &mon_id); mon_rect = current_mon.rcMonitor; g_resize_width = width;