Commit 3e631305 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Handle the special DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW combination.

parent d8153e53
...@@ -788,21 +788,20 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, ...@@ -788,21 +788,20 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
} }
/* Handle those levels first which set various hwnds */ /* Handle those levels first which set various hwnds */
if(cooplevel & DDSCL_SETFOCUSWINDOW) if ((cooplevel & DDSCL_SETFOCUSWINDOW) && !(cooplevel & DDSCL_CREATEDEVICEWINDOW))
{ {
/* This isn't compatible with a lot of flags */ /* This isn't compatible with a lot of flags */
if(cooplevel & ( DDSCL_MULTITHREADED | if (cooplevel & (DDSCL_MULTITHREADED
DDSCL_CREATEDEVICEWINDOW | | DDSCL_FPUSETUP
DDSCL_FPUSETUP | | DDSCL_FPUPRESERVE
DDSCL_FPUPRESERVE | | DDSCL_ALLOWREBOOT
DDSCL_ALLOWREBOOT | | DDSCL_ALLOWMODEX
DDSCL_ALLOWMODEX | | DDSCL_SETDEVICEWINDOW
DDSCL_SETDEVICEWINDOW | | DDSCL_NORMAL
DDSCL_NORMAL | | DDSCL_EXCLUSIVE
DDSCL_EXCLUSIVE | | DDSCL_FULLSCREEN))
DDSCL_FULLSCREEN ) )
{ {
TRACE("Called with incompatible flags, returning DDERR_INVALIDPARAMS\n"); WARN("Called with incompatible flags, returning DDERR_INVALIDPARAMS.\n");
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
...@@ -845,7 +844,26 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, ...@@ -845,7 +844,26 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
ShowWindow(device_window, SW_SHOW); ShowWindow(device_window, SW_SHOW);
TRACE("Created a device window %p.\n", device_window); TRACE("Created a device window %p.\n", device_window);
/* Native apparently leaks the created device window if setting the
* focus window below fails. */
This->cooperative_level |= DDSCL_CREATEDEVICEWINDOW;
This->devicewindow = device_window; This->devicewindow = device_window;
if (cooplevel & DDSCL_SETFOCUSWINDOW)
{
if (!hwnd)
{
wined3d_mutex_unlock();
return DDERR_NOHWND;
}
if (FAILED(hr = ddraw_set_focus_window(This, hwnd)))
{
wined3d_mutex_unlock();
return hr;
}
}
hwnd = device_window; hwnd = device_window;
} }
} }
......
...@@ -89,7 +89,7 @@ static void test_coop_level_create_device_window(void) ...@@ -89,7 +89,7 @@ static void test_coop_level_create_device_window(void)
ok(!device_window, "Unexpected device window found.\n"); ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr); ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd"); device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n"); todo_wine ok(!!device_window, "Device window not found.\n");
...@@ -99,7 +99,7 @@ static void test_coop_level_create_device_window(void) ...@@ -99,7 +99,7 @@ static void test_coop_level_create_device_window(void)
ok(!device_window, "Unexpected device window found.\n"); ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd"); device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n"); todo_wine ok(!!device_window, "Device window not found.\n");
......
...@@ -96,7 +96,7 @@ static void test_coop_level_create_device_window(void) ...@@ -96,7 +96,7 @@ static void test_coop_level_create_device_window(void)
ok(!device_window, "Unexpected device window found.\n"); ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr); ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd"); device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n"); todo_wine ok(!!device_window, "Device window not found.\n");
...@@ -106,7 +106,7 @@ static void test_coop_level_create_device_window(void) ...@@ -106,7 +106,7 @@ static void test_coop_level_create_device_window(void)
ok(!device_window, "Unexpected device window found.\n"); ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd"); device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n"); todo_wine ok(!!device_window, "Device window not found.\n");
......
...@@ -392,7 +392,7 @@ static void test_coop_level_create_device_window(void) ...@@ -392,7 +392,7 @@ static void test_coop_level_create_device_window(void)
ok(!device_window, "Unexpected device window found.\n"); ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr); ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd"); device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n"); todo_wine ok(!!device_window, "Device window not found.\n");
...@@ -402,7 +402,7 @@ static void test_coop_level_create_device_window(void) ...@@ -402,7 +402,7 @@ static void test_coop_level_create_device_window(void)
ok(!device_window, "Unexpected device window found.\n"); ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd"); device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n"); todo_wine ok(!!device_window, "Device window not found.\n");
......
...@@ -385,7 +385,7 @@ static void test_coop_level_create_device_window(void) ...@@ -385,7 +385,7 @@ static void test_coop_level_create_device_window(void)
ok(!device_window, "Unexpected device window found.\n"); ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr); ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd"); device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n"); todo_wine ok(!!device_window, "Device window not found.\n");
...@@ -395,7 +395,7 @@ static void test_coop_level_create_device_window(void) ...@@ -395,7 +395,7 @@ static void test_coop_level_create_device_window(void)
ok(!device_window, "Unexpected device window found.\n"); ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd"); device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n"); todo_wine ok(!!device_window, "Device window not found.\n");
......
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