Commit 8d4988a4 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Improve ddraw7_TestCooperativeLevel().

parent ee7eee55
......@@ -2185,23 +2185,13 @@ static HRESULT WINAPI ddraw1_GetScanLine(IDirectDraw *iface, DWORD *line)
return ddraw7_GetScanLine(&ddraw->IDirectDraw7_iface, line);
}
/*****************************************************************************
* IDirectDraw7::TestCooperativeLevel
*
* Informs the application about the state of the video adapter, depending
* on the cooperative level
*
* Returns:
* DD_OK if the device is in a sane state
* DDERR_NOEXCLUSIVEMODE or DDERR_EXCLUSIVEMODEALREADYSET
* if the state is not correct(See below)
*
*****************************************************************************/
static HRESULT WINAPI ddraw7_TestCooperativeLevel(IDirectDraw7 *iface)
{
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
TRACE("iface %p.\n", iface);
return DD_OK;
return ddraw->device_state == DDRAW_DEVICE_STATE_OK ? DD_OK : DDERR_NOEXCLUSIVEMODE;
}
static HRESULT WINAPI ddraw4_TestCooperativeLevel(IDirectDraw4 *iface)
......@@ -4724,7 +4714,14 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
{
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
if (!activate)
InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_LOST, DDRAW_DEVICE_STATE_OK);
else
InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_OK, DDRAW_DEVICE_STATE_LOST);
}
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
......
......@@ -58,6 +58,12 @@ struct FvfToDecl
#define DDRAW_STRIDE_ALIGNMENT 8
enum ddraw_device_state
{
DDRAW_DEVICE_STATE_OK,
DDRAW_DEVICE_STATE_LOST,
};
struct ddraw
{
/* Interfaces */
......@@ -77,6 +83,7 @@ struct ddraw
struct wined3d *wined3d;
struct wined3d_device *wined3d_device;
DWORD flags;
LONG device_state;
struct ddraw_surface *primary;
RECT primary_lock;
......
......@@ -7644,7 +7644,7 @@ static void test_lost_device(void)
ret = SetForegroundWindow(GetDesktopWindow());
ok(ret, "Failed to set foreground window.\n");
hr = IDirectDraw4_TestCooperativeLevel(ddraw);
todo_wine ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_IsLost(surface);
todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
......
......@@ -7366,7 +7366,7 @@ static void test_lost_device(void)
ret = SetForegroundWindow(GetDesktopWindow());
ok(ret, "Failed to set foreground window.\n");
hr = IDirectDraw7_TestCooperativeLevel(ddraw);
todo_wine ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_IsLost(surface);
todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
......
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