Commit 04d541c2 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Just use SetWindowPos() in ddraw_set_display_mode().

Instead of going through wined3d_device_restore_fullscreen_window() / wined3d_device_setup_fullscreen_window(). The main point of those functions is changing the window styles, but we don't actually need that here. More importantly, we filter the messages generated by those functions in wined3d, while tests show that messages generated by SetDisplayMode() / RestoreDisplayMode() are visible to the application. Applications depend on WM_SIZE in particular.
parent 0daac59a
...@@ -910,15 +910,12 @@ static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD ...@@ -910,15 +910,12 @@ static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD
* or some drawing is in progress * or some drawing is in progress
*/ */
if (ddraw->cooperative_level & DDSCL_EXCLUSIVE)
SetWindowPos(ddraw->dest_window, HWND_TOP, 0, 0, Width, Height, SWP_SHOWWINDOW | SWP_NOACTIVATE);
/* TODO: Lose the primary surface */ /* TODO: Lose the primary surface */
hr = wined3d_device_set_display_mode(ddraw->wined3d_device, 0, &Mode); hr = wined3d_device_set_display_mode(ddraw->wined3d_device, 0, &Mode);
if (ddraw->cooperative_level & DDSCL_EXCLUSIVE)
{
wined3d_device_restore_fullscreen_window(ddraw->wined3d_device, ddraw->dest_window);
wined3d_device_setup_fullscreen_window(ddraw->wined3d_device, ddraw->dest_window, Width, Height);
}
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
switch(hr) switch(hr)
{ {
......
...@@ -4150,10 +4150,26 @@ static void test_coop_level_mode_set(void) ...@@ -4150,10 +4150,26 @@ static void test_coop_level_mode_set(void)
{ {
RECT fullscreen_rect, r, s; RECT fullscreen_rect, r, s;
IDirectDraw7 *ddraw7; IDirectDraw7 *ddraw7;
WNDCLASSA wc = {0};
HWND window; HWND window;
HRESULT hr; HRESULT hr;
ULONG ref; ULONG ref;
static const UINT exclusive_messages[] =
{
WM_WINDOWPOSCHANGING,
WM_WINDOWPOSCHANGED,
WM_SIZE,
WM_DISPLAYCHANGE,
0,
};
static const UINT normal_messages[] =
{
WM_DISPLAYCHANGE,
0,
};
hr = pDirectDrawCreateEx(NULL, (void **)&ddraw7, &IID_IDirectDraw7, NULL); hr = pDirectDrawCreateEx(NULL, (void **)&ddraw7, &IID_IDirectDraw7, NULL);
if (FAILED(hr)) if (FAILED(hr))
{ {
...@@ -4161,7 +4177,11 @@ static void test_coop_level_mode_set(void) ...@@ -4161,7 +4177,11 @@ static void test_coop_level_mode_set(void)
return; return;
} }
window = CreateWindowA("static", "d3d7_test", WS_OVERLAPPEDWINDOW, wc.lpfnWndProc = test_proc;
wc.lpszClassName = "d3d7_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
window = CreateWindowA("d3d7_test_wndproc_wc", "d3d7_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0); 0, 0, 100, 100, 0, 0, 0, 0);
SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
...@@ -4172,8 +4192,7 @@ static void test_coop_level_mode_set(void) ...@@ -4172,8 +4192,7 @@ static void test_coop_level_mode_set(void)
if (FAILED(hr)) if (FAILED(hr))
{ {
IDirectDraw7_Release(ddraw7); IDirectDraw7_Release(ddraw7);
DestroyWindow(window); goto done;
return;
} }
GetWindowRect(window, &r); GetWindowRect(window, &r);
...@@ -4181,17 +4200,27 @@ static void test_coop_level_mode_set(void) ...@@ -4181,17 +4200,27 @@ static void test_coop_level_mode_set(void)
fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
r.left, r.top, r.right, r.bottom); r.left, r.top, r.right, r.bottom);
expect_messages = exclusive_messages;
hr = IDirectDraw7_SetDisplayMode(ddraw7, 640, 480, 32, 0, 0); hr = IDirectDraw7_SetDisplayMode(ddraw7, 640, 480, 32, 0, 0);
ok(SUCCEEDED(hr), "SetDipslayMode failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "SetDipslayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
GetWindowRect(window, &r); GetWindowRect(window, &r);
ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
s.left, s.top, s.right, s.bottom, s.left, s.top, s.right, s.bottom,
r.left, r.top, r.right, r.bottom); r.left, r.top, r.right, r.bottom);
expect_messages = exclusive_messages;
hr = IDirectDraw_RestoreDisplayMode(ddraw7); hr = IDirectDraw_RestoreDisplayMode(ddraw7);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
GetWindowRect(window, &r); GetWindowRect(window, &r);
ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
...@@ -4204,17 +4233,27 @@ static void test_coop_level_mode_set(void) ...@@ -4204,17 +4233,27 @@ static void test_coop_level_mode_set(void)
fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
r.left, r.top, r.right, r.bottom); r.left, r.top, r.right, r.bottom);
expect_messages = normal_messages;
hr = IDirectDraw7_SetDisplayMode(ddraw7, 640, 480, 32, 0, 0); hr = IDirectDraw7_SetDisplayMode(ddraw7, 640, 480, 32, 0, 0);
ok(SUCCEEDED(hr), "SetDipslayMode failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "SetDipslayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
GetWindowRect(window, &r); GetWindowRect(window, &r);
ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
r.left, r.top, r.right, r.bottom); r.left, r.top, r.right, r.bottom);
expect_messages = normal_messages;
hr = IDirectDraw_RestoreDisplayMode(ddraw7); hr = IDirectDraw_RestoreDisplayMode(ddraw7);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
GetWindowRect(window, &r); GetWindowRect(window, &r);
ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
...@@ -4228,7 +4267,10 @@ static void test_coop_level_mode_set(void) ...@@ -4228,7 +4267,10 @@ static void test_coop_level_mode_set(void)
fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
r.left, r.top, r.right, r.bottom); r.left, r.top, r.right, r.bottom);
done:
expect_messages = NULL;
DestroyWindow(window); DestroyWindow(window);
UnregisterClassA("d3d7_test_wndproc_wc", GetModuleHandleA(NULL));
} }
START_TEST(d3d) START_TEST(d3d)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment