diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index d616330c307..56a1ed7fd94 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -583,8 +583,10 @@ static HRESULT ddraw_attach_d3d_device(struct ddraw *ddraw, HWND window, swapchain_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD; swapchain_desc.device_window = window; swapchain_desc.windowed = windowed; - swapchain_desc.flags = WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH - | WINED3D_SWAPCHAIN_IMPLICIT | WINED3D_SWAPCHAIN_NO_WINDOW_CHANGES; + swapchain_desc.flags = WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH | WINED3D_SWAPCHAIN_IMPLICIT; + + if (window != GetForegroundWindow()) + swapchain_desc.flags |= WINED3D_SWAPCHAIN_NO_WINDOW_CHANGES; if (ddraw->flags & DDRAW_NO3D) return wined3d_swapchain_create(ddraw->wined3d_device, &swapchain_desc, diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 57bc622e48b..b9020157253 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -2543,14 +2543,16 @@ static void test_window_style(void) { LONG style, exstyle, tmp, expected_style; RECT fullscreen_rect, r; + HWND window, window2; IDirectDraw *ddraw; - HWND window; HRESULT hr; ULONG ref; BOOL ret; window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, 0, 0); + window2 = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 0, 0, 50, 50, 0, 0, 0, 0); ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); @@ -2594,6 +2596,68 @@ static void test_window_style(void) tmp = GetWindowLongA(window, GWL_EXSTYLE); ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + SetActiveWindow(window); + ok(GetActiveWindow() == window, "Unexpected active window.\n"); + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", + wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r)); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + SetWindowPos(window, NULL, 0, 0, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE); + GetWindowRect(window, &r); + ok(!EqualRect(&r, &fullscreen_rect), "Window resize failed? got %s.\n", + wine_dbgstr_rect(&r)); + + ret = SetForegroundWindow(window2); + ok(ret, "Failed to set foreground window.\n"); + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", + wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r)); + + ret = SetForegroundWindow(window); + ok(ret, "Failed to set foreground window.\n"); + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + + ShowWindow(window, SW_HIDE); + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); @@ -2617,6 +2681,7 @@ static void test_window_style(void) ref = IDirectDraw_Release(ddraw); ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref); + DestroyWindow(window2); DestroyWindow(window); } diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index d2889aa05d7..e8beb67c692 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -2597,14 +2597,16 @@ static void test_window_style(void) { LONG style, exstyle, tmp, expected_style; RECT fullscreen_rect, r; + HWND window, window2; IDirectDraw2 *ddraw; - HWND window; HRESULT hr; ULONG ref; BOOL ret; window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, 0, 0); + window2 = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 0, 0, 50, 50, 0, 0, 0, 0); ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); @@ -2648,6 +2650,68 @@ static void test_window_style(void) tmp = GetWindowLongA(window, GWL_EXSTYLE); ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + SetActiveWindow(window); + ok(GetActiveWindow() == window, "Unexpected active window.\n"); + hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", + wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r)); + + hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + SetWindowPos(window, NULL, 0, 0, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE); + GetWindowRect(window, &r); + ok(!EqualRect(&r, &fullscreen_rect), "Window resize failed? got %s.\n", + wine_dbgstr_rect(&r)); + + ret = SetForegroundWindow(window2); + ok(ret, "Failed to set foreground window.\n"); + hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", + wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r)); + + ret = SetForegroundWindow(window); + ok(ret, "Failed to set foreground window.\n"); + hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + + ShowWindow(window, SW_HIDE); + hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); @@ -2671,6 +2735,7 @@ static void test_window_style(void) ref = IDirectDraw2_Release(ddraw); ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref); + DestroyWindow(window2); DestroyWindow(window); } diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 6e003fbfb7e..903c4c5fdb5 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -2832,14 +2832,16 @@ static void test_window_style(void) { LONG style, exstyle, tmp, expected_style; RECT fullscreen_rect, r; + HWND window, window2; IDirectDraw4 *ddraw; - HWND window; HRESULT hr; ULONG ref; BOOL ret; window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, 0, 0); + window2 = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 0, 0, 50, 50, 0, 0, 0, 0); ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); @@ -2883,6 +2885,68 @@ static void test_window_style(void) tmp = GetWindowLongA(window, GWL_EXSTYLE); ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + SetActiveWindow(window); + ok(GetActiveWindow() == window, "Unexpected active window.\n"); + hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", + wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r)); + + hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + SetWindowPos(window, NULL, 0, 0, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE); + GetWindowRect(window, &r); + ok(!EqualRect(&r, &fullscreen_rect), "Window resize failed? got %s.\n", + wine_dbgstr_rect(&r)); + + ret = SetForegroundWindow(window2); + ok(ret, "Failed to set foreground window.\n"); + hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", + wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r)); + + ret = SetForegroundWindow(window); + ok(ret, "Failed to set foreground window.\n"); + hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + + ShowWindow(window, SW_HIDE); + hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); @@ -2906,6 +2970,7 @@ static void test_window_style(void) ref = IDirectDraw4_Release(ddraw); ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref); + DestroyWindow(window2); DestroyWindow(window); } diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 559d13d035c..22af91a4667 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -2481,14 +2481,16 @@ static void test_window_style(void) { LONG style, exstyle, tmp, expected_style; RECT fullscreen_rect, r; + HWND window, window2; IDirectDraw7 *ddraw; - HWND window; HRESULT hr; ULONG ref; BOOL ret; window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, 0, 0); + window2 = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 0, 0, 50, 50, 0, 0, 0, 0); ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); @@ -2532,6 +2534,68 @@ static void test_window_style(void) tmp = GetWindowLongA(window, GWL_EXSTYLE); ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + SetActiveWindow(window); + ok(GetActiveWindow() == window, "Unexpected active window.\n"); + hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", + wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r)); + + hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + SetWindowPos(window, NULL, 0, 0, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE); + GetWindowRect(window, &r); + ok(!EqualRect(&r, &fullscreen_rect), "Window resize failed? got %s.\n", + wine_dbgstr_rect(&r)); + + ret = SetForegroundWindow(window2); + ok(ret, "Failed to set foreground window.\n"); + hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", + wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r)); + + ret = SetForegroundWindow(window); + ok(ret, "Failed to set foreground window.\n"); + hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + + ShowWindow(window, SW_HIDE); + hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); @@ -2555,6 +2619,7 @@ static void test_window_style(void) ref = IDirectDraw7_Release(ddraw); ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref); + DestroyWindow(window2); DestroyWindow(window); }