ddraw: Properly handle DDSCL_CREATEDEVICEWINDOW.
This commit is contained in:
parent
a5af10e12b
commit
d8153e5364
|
@ -812,14 +812,42 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
|
|||
return hr;
|
||||
}
|
||||
|
||||
if(cooplevel & DDSCL_EXCLUSIVE)
|
||||
if (cooplevel & DDSCL_EXCLUSIVE)
|
||||
{
|
||||
if( !(cooplevel & DDSCL_FULLSCREEN) || !hwnd )
|
||||
if (!(cooplevel & DDSCL_FULLSCREEN) || !(hwnd || (cooplevel & DDSCL_CREATEDEVICEWINDOW)))
|
||||
{
|
||||
TRACE("(%p) DDSCL_EXCLUSIVE needs DDSCL_FULLSCREEN and a window\n", This);
|
||||
WARN("DDSCL_EXCLUSIVE requires DDSCL_FULLSCREEN and a window.\n");
|
||||
wined3d_mutex_unlock();
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
if (cooplevel & DDSCL_CREATEDEVICEWINDOW)
|
||||
{
|
||||
HWND device_window;
|
||||
|
||||
if (!This->focuswindow && !(cooplevel & DDSCL_SETFOCUSWINDOW))
|
||||
{
|
||||
WARN("No focus window set.\n");
|
||||
wined3d_mutex_unlock();
|
||||
return DDERR_NOFOCUSWINDOW;
|
||||
}
|
||||
|
||||
device_window = CreateWindowExA(0, DDRAW_WINDOW_CLASS_NAME, "DDraw device window",
|
||||
WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
|
||||
NULL, NULL, NULL, NULL);
|
||||
if (!device_window)
|
||||
{
|
||||
ERR("Failed to create window, last error %#x.\n", GetLastError());
|
||||
wined3d_mutex_unlock();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
ShowWindow(device_window, SW_SHOW);
|
||||
TRACE("Created a device window %p.\n", device_window);
|
||||
|
||||
This->devicewindow = device_window;
|
||||
hwnd = device_window;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -864,29 +892,6 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
|
|||
if (hwnd && !This->focuswindow && !This->devicewindow && (hwnd != window))
|
||||
This->dest_window = hwnd;
|
||||
|
||||
if(cooplevel & DDSCL_CREATEDEVICEWINDOW)
|
||||
{
|
||||
/* Don't create a device window if a focus window is set */
|
||||
if( !(This->focuswindow) )
|
||||
{
|
||||
HWND devicewindow = CreateWindowExA(0, DDRAW_WINDOW_CLASS_NAME, "DDraw device window",
|
||||
WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
|
||||
NULL, NULL, NULL, NULL);
|
||||
if (!devicewindow)
|
||||
{
|
||||
ERR("Failed to create window, last error %#x.\n", GetLastError());
|
||||
wined3d_mutex_unlock();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
ShowWindow(devicewindow, SW_SHOW); /* Just to be sure */
|
||||
TRACE("(%p) Created a DDraw device window. HWND=%p\n", This, devicewindow);
|
||||
|
||||
This->devicewindow = devicewindow;
|
||||
This->dest_window = devicewindow;
|
||||
}
|
||||
}
|
||||
|
||||
if (cooplevel & DDSCL_MULTITHREADED && !(This->cooperative_level & DDSCL_MULTITHREADED))
|
||||
wined3d_device_set_multithreaded(This->wined3d_device);
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
||||
todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
|
||||
ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
|
||||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
|
||||
|
@ -108,7 +108,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
||||
todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
|
||||
ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
|
||||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
|
||||
|
@ -116,7 +116,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, 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");
|
||||
todo_wine ok(!!device_window, "Device window not found.\n");
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
||||
todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
|
||||
ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
|
||||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
|
||||
|
@ -115,7 +115,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
||||
todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
|
||||
ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
|
||||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
|
||||
|
@ -123,7 +123,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, 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");
|
||||
todo_wine ok(!!device_window, "Device window not found.\n");
|
||||
|
||||
|
|
|
@ -364,7 +364,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
||||
todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
|
||||
ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
|
||||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
|
||||
|
@ -411,7 +411,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
||||
todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
|
||||
ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
|
||||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
|
||||
|
@ -419,7 +419,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, 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");
|
||||
todo_wine ok(!!device_window, "Device window not found.\n");
|
||||
|
||||
|
|
|
@ -357,7 +357,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
||||
todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
|
||||
ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
|
||||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
|
||||
|
@ -404,7 +404,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
||||
todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
|
||||
ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
|
||||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
|
||||
|
@ -412,7 +412,7 @@ static void test_coop_level_create_device_window(void)
|
|||
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
||||
ok(!device_window, "Unexpected device window found.\n");
|
||||
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, 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");
|
||||
todo_wine ok(!!device_window, "Device window not found.\n");
|
||||
|
||||
|
|
Loading…
Reference in New Issue