From afb04c91337730b0b51b62be2b780b04c9715882 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 28 Oct 2015 20:40:45 +0100 Subject: [PATCH] Clarify Win32 monitor physical size retrieval --- src/win32_monitor.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index fa6cc994..0ad1b7a4 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -112,6 +112,8 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) for (adapterIndex = 0; ; adapterIndex++) { DISPLAY_DEVICEW adapter; + int widthMM, heightMM; + HDC dc; ZeroMemory(&adapter, sizeof(DISPLAY_DEVICEW)); adapter.cb = sizeof(DISPLAY_DEVICEW); @@ -122,12 +124,16 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) if (!(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE)) continue; + dc = CreateDCW(L"DISPLAY", adapter.DeviceName, NULL, NULL); + widthMM = GetDeviceCaps(dc, HORZSIZE); + heightMM = GetDeviceCaps(dc, VERTSIZE); + DeleteDC(dc); + for (displayIndex = 0; ; displayIndex++) { DISPLAY_DEVICEW display; _GLFWmonitor* monitor; char* name; - HDC dc; ZeroMemory(&display, sizeof(DISPLAY_DEVICEW)); display.cb = sizeof(DISPLAY_DEVICEW); @@ -143,13 +149,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) continue; } - dc = CreateDCW(L"DISPLAY", adapter.DeviceName, NULL, NULL); - - monitor = _glfwAllocMonitor(name, - GetDeviceCaps(dc, HORZSIZE), - GetDeviceCaps(dc, VERTSIZE)); - - DeleteDC(dc); + monitor = _glfwAllocMonitor(name, widthMM, heightMM); free(name); if (adapter.StateFlags & DISPLAY_DEVICE_MODESPRUNED)