gdi32/tests: Fix possible test failures in test_clip_box().

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@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2020-12-14 15:11:43 +08:00 committed by Alexandre Julliard
parent a4456ff9f9
commit d93412ca67
1 changed files with 35 additions and 1 deletions

View File

@ -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);