[PATCH 1/2] gdi32/tests: Fix possible test failures in test_clip_box().

Zhiyi Zhang zzhang at codeweavers.com
Mon Dec 14 01:11:43 CST 2020


When there are multiple monitors and their monitor region union can still be represented by a simple
rectangle, the clip box region type for the screen DC is still SIMPLEREGION.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
Fix test failures like in https://test.winehq.org/data/3acb0b3326c4120ea0c4c6076bd03c9cfe82c744/win7_newtb-w7u-2qxl/gdi32:dc.html

 dlls/gdi32/tests/dc.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c
index b4a89b213d2..2cb8c65dd64 100644
--- a/dlls/gdi32/tests/dc.c
+++ b/dlls/gdi32/tests/dc.c
@@ -1539,6 +1539,40 @@ static void test_pscript_printer_dc(void)
     DeleteDC(hdc);
 }
 
+struct screen_region_info
+{
+    HRGN region;
+    INT type;
+};
+
+static BOOL CALLBACK enum_monitor_proc(HMONITOR monitor, HDC hdc, RECT *rect, LPARAM lparam)
+{
+    struct screen_region_info *info = (struct screen_region_info *)lparam;
+    HRGN region;
+
+    if (!info->region)
+    {
+        info->region = CreateRectRgnIndirect(rect);
+        info->type = SIMPLEREGION;
+    }
+    else
+    {
+        region = CreateRectRgnIndirect(rect);
+        info->type = CombineRgn(info->region, info->region, region, RGN_OR);
+        DeleteObject(region);
+    }
+    return TRUE;
+}
+
+static INT get_screen_region_type(void)
+{
+    struct screen_region_info info = {NULL, NULLREGION};
+
+    EnumDisplayMonitors(NULL, NULL, enum_monitor_proc, (LPARAM)&info);
+    DeleteObject(info.region);
+    return info.type;
+}
+
 static void test_clip_box(void)
 {
     DEVMODEA scale_mode = {.dmSize = sizeof(DEVMODEA)};
@@ -1554,7 +1588,7 @@ static void test_clip_box(void)
     SetRect(&screen_rect, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN),
             GetSystemMetrics(SM_XVIRTUALSCREEN) + GetSystemMetrics(SM_CXVIRTUALSCREEN),
             GetSystemMetrics(SM_YVIRTUALSCREEN) + GetSystemMetrics(SM_CYVIRTUALSCREEN));
-    screen_type = GetSystemMetrics(SM_CMONITORS) > 1 ? COMPLEXREGION : SIMPLEREGION;
+    screen_type = get_screen_region_type();
 
     dc = CreateDCA("DISPLAY", NULL, NULL, NULL);
     type = GetClipBox(dc, &rect);
-- 
2.27.0




More information about the wine-devel mailing list