From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58844 --- dlls/ddraw/tests/ddraw1.c | 102 ++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw2.c | 102 ++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw4.c | 102 ++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw7.c | 102 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 408 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index fb5201f66ba..53397088829 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -16305,6 +16305,107 @@ out: DestroyWindow(window); }
+static RGNDATA *get_region_data(HRGN region) +{ + RGNDATA *data = NULL; + DWORD size; + + if (region && (size = GetRegionData(region, 0, NULL)) && (data = malloc(size))) + GetRegionData(region, size, data); + + return data; +} + +static void test_window_clipping(void) +{ + IDirectDraw *ddraw; + ULONG refcount; + RGNDATA *data; + HRGN region; + HWND window; + HRESULT hr; + UINT ret; + HDC dc; + + window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, NULL, NULL, NULL, NULL); + CreateWindowA("#32770", "", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, window, NULL, NULL, NULL); + flush_events(); + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!!(ret & WS_CLIPCHILDREN), "Missing WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children to be clipped out */ + ok(data->rdh.nCount == 2, "Got nCount %lu\n", data->rdh.nCount); + free(data); + ReleaseDC(window, dc); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!(ret & WS_CLIPCHILDREN), "Got WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children *not* to be clipped out */ + todo_wine ok(data->rdh.nCount == 1, "Got nCount %lu\n", data->rdh.nCount); + free(data); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!!(ret & WS_CLIPCHILDREN), "Missing WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children to be clipped out */ + ok(data->rdh.nCount == 2, "Got nCount %lu\n", data->rdh.nCount); + free(data); + ReleaseDC(window, dc); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!(ret & WS_CLIPCHILDREN), "Got WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children *not* to be clipped out */ + todo_wine ok(data->rdh.nCount == 1, "Got nCount %lu\n", data->rdh.nCount); + free(data); + DeleteObject(region); + + refcount = IDirectDraw_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw1) { DDDEVICEIDENTIFIER identifier; @@ -16429,4 +16530,5 @@ START_TEST(ddraw1) test_sysmem_x_channel(); test_yuv_blit(); test_blit_to_self(); + test_window_clipping(); } diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index f163ec80bed..d4678344585 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -17376,6 +17376,107 @@ out: DestroyWindow(window); }
+static RGNDATA *get_region_data(HRGN region) +{ + RGNDATA *data = NULL; + DWORD size; + + if (region && (size = GetRegionData(region, 0, NULL)) && (data = malloc(size))) + GetRegionData(region, size, data); + + return data; +} + +static void test_window_clipping(void) +{ + IDirectDraw2 *ddraw; + ULONG refcount; + RGNDATA *data; + HRGN region; + HWND window; + HRESULT hr; + UINT ret; + HDC dc; + + window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, NULL, NULL, NULL, NULL); + CreateWindowA("#32770", "", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, window, NULL, NULL, NULL); + flush_events(); + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!!(ret & WS_CLIPCHILDREN), "Missing WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children to be clipped out */ + ok(data->rdh.nCount == 2, "Got nCount %lu\n", data->rdh.nCount); + free(data); + ReleaseDC(window, dc); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!(ret & WS_CLIPCHILDREN), "Got WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children *not* to be clipped out */ + todo_wine ok(data->rdh.nCount == 1, "Got nCount %lu\n", data->rdh.nCount); + free(data); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!!(ret & WS_CLIPCHILDREN), "Missing WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children to be clipped out */ + ok(data->rdh.nCount == 2, "Got nCount %lu\n", data->rdh.nCount); + free(data); + ReleaseDC(window, dc); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!(ret & WS_CLIPCHILDREN), "Got WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children *not* to be clipped out */ + todo_wine ok(data->rdh.nCount == 1, "Got nCount %lu\n", data->rdh.nCount); + free(data); + DeleteObject(region); + + refcount = IDirectDraw_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw2) { DDDEVICEIDENTIFIER identifier; @@ -17506,4 +17607,5 @@ START_TEST(ddraw2) test_sysmem_x_channel(); test_yuv_blit(); test_blit_to_self(); + test_window_clipping(); } diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 60eaa3ec8d0..7a955155099 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -20457,6 +20457,107 @@ out: DestroyWindow(window); }
+static RGNDATA *get_region_data(HRGN region) +{ + RGNDATA *data = NULL; + DWORD size; + + if (region && (size = GetRegionData(region, 0, NULL)) && (data = malloc(size))) + GetRegionData(region, size, data); + + return data; +} + +static void test_window_clipping(void) +{ + IDirectDraw4 *ddraw; + ULONG refcount; + RGNDATA *data; + HRGN region; + HWND window; + HRESULT hr; + UINT ret; + HDC dc; + + window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, NULL, NULL, NULL, NULL); + CreateWindowA("#32770", "", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, window, NULL, NULL, NULL); + flush_events(); + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!!(ret & WS_CLIPCHILDREN), "Missing WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children to be clipped out */ + ok(data->rdh.nCount == 2, "Got nCount %lu\n", data->rdh.nCount); + free(data); + ReleaseDC(window, dc); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!(ret & WS_CLIPCHILDREN), "Got WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children *not* to be clipped out */ + todo_wine ok(data->rdh.nCount == 1, "Got nCount %lu\n", data->rdh.nCount); + free(data); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!!(ret & WS_CLIPCHILDREN), "Missing WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children to be clipped out */ + ok(data->rdh.nCount == 2, "Got nCount %lu\n", data->rdh.nCount); + free(data); + ReleaseDC(window, dc); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!(ret & WS_CLIPCHILDREN), "Got WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children *not* to be clipped out */ + todo_wine ok(data->rdh.nCount == 1, "Got nCount %lu\n", data->rdh.nCount); + free(data); + DeleteObject(region); + + refcount = IDirectDraw_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw4) { DDDEVICEIDENTIFIER identifier; @@ -20604,4 +20705,5 @@ START_TEST(ddraw4) test_sysmem_x_channel(); test_yuv_blit(); test_blit_to_self(); + test_window_clipping(); } diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index a3df2fa659f..50963559fb3 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -20857,6 +20857,107 @@ out: DestroyWindow(window); }
+static RGNDATA *get_region_data(HRGN region) +{ + RGNDATA *data = NULL; + DWORD size; + + if (region && (size = GetRegionData(region, 0, NULL)) && (data = malloc(size))) + GetRegionData(region, size, data); + + return data; +} + +static void test_window_clipping(void) +{ + IDirectDraw7 *ddraw; + ULONG refcount; + RGNDATA *data; + HRGN region; + HWND window; + HRESULT hr; + UINT ret; + HDC dc; + + window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, NULL, NULL, NULL, NULL); + CreateWindowA("#32770", "", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, window, NULL, NULL, NULL); + flush_events(); + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!!(ret & WS_CLIPCHILDREN), "Missing WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children to be clipped out */ + ok(data->rdh.nCount == 2, "Got nCount %lu\n", data->rdh.nCount); + free(data); + ReleaseDC(window, dc); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!(ret & WS_CLIPCHILDREN), "Got WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children *not* to be clipped out */ + todo_wine ok(data->rdh.nCount == 1, "Got nCount %lu\n", data->rdh.nCount); + free(data); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!!(ret & WS_CLIPCHILDREN), "Missing WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children to be clipped out */ + ok(data->rdh.nCount == 2, "Got nCount %lu\n", data->rdh.nCount); + free(data); + ReleaseDC(window, dc); + DeleteObject(region); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES); + ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); + ret = GetWindowLongW(window, GWL_STYLE); + ok(!(ret & WS_CLIPCHILDREN), "Got WS_CLIPCHILDREN\n"); + ok(!!(ret & WS_CLIPSIBLINGS), "Missing WS_CLIPSIBLINGS\n"); + + region = CreateRectRgn(0, 0, 0, 0); + dc = GetDCEx(window, 0, DCX_CACHE | DCX_USESTYLE); + ret = GetRandomRgn(dc, region, SYSRGN); + ok(ret == 1, "Got unexpected ret %d\n", ret); + data = get_region_data(region); + /* expect children *not* to be clipped out */ + todo_wine ok(data->rdh.nCount == 1, "Got nCount %lu\n", data->rdh.nCount); + free(data); + DeleteObject(region); + + refcount = IDirectDraw_Release(ddraw); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw7) { DDDEVICEIDENTIFIER2 identifier; @@ -21038,4 +21139,5 @@ START_TEST(ddraw7) test_sysmem_x_channel(); test_yuv_blit(); test_blit_to_self(); + test_window_clipping(); }