[PATCH] user32/tests: Trace monitor information with 'monitor info'.

Francois Gouget fgouget at codeweavers.com
Wed Apr 27 08:22:32 CDT 2022


Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
Just running user32:monitor does not provide useful information about
how many monitors are present, their resolution, etc. I can manually
check this information by starting a VM, connecting to it with
virt-viewer and using the GUI. But multi-monitor setups are a bit
finicky so I'm never really sure if they really get the same
configuration when they run tests.
This issue is exacerbated by the fact that Libvirt's screenshotting
functionality is particularly buggy for Windows guests and seems to only
capture the primary monitor.
So I'm hoping to use this patch to get more accurate monitor +
resolution information (at least until client-side screenshotting).

I can also keep it locally if it is deemed not suitable for Wine.
---
 dlls/user32/tests/monitor.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c
index 02bc6651dd3..94cb7e60382 100644
--- a/dlls/user32/tests/monitor.c
+++ b/dlls/user32/tests/monitor.c
@@ -2530,9 +2530,38 @@ static void test_display_dc(void)
     }
 }
 
+BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor,
+                              LPRECT lprcMonitor, LPARAM dwData)
+{
+    MONITORINFOEXW info;
+    static int index;
+
+    info.cbSize = sizeof(info);
+    if (GetMonitorInfoW(hMonitor, (MONITORINFO*)&info))
+    {
+        printf("Monitor %d %7s [%02lx] %s %s\n", index,
+              (info.dwFlags & MONITORINFOF_PRIMARY) ? "primary" : "",
+               info.dwFlags, wine_dbgstr_rect(&info.rcMonitor),
+               wine_dbgstr_w(info.szDevice));
+    }
+    index++;
+    return TRUE;
+}
+
 START_TEST(monitor)
 {
+    char** myARGV;
+    int myARGC = winetest_get_mainargs(&myARGV);
+
     init_function_pointers();
+
+    if (myARGC >= 3 && strcmp(myARGV[2], "info") == 0)
+    {
+        printf("Monitor information:\n");
+        EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, 0);
+        return;
+    }
+
     test_enumdisplaydevices();
     test_ChangeDisplaySettingsEx();
     test_DisplayConfigSetDeviceInfo();
-- 
2.30.2



More information about the wine-devel mailing list