ddraw: Improve ddraw7_TestCooperativeLevel().

This commit is contained in:
Henri Verbeet 2014-06-30 11:17:03 +02:00 committed by Alexandre Julliard
parent ee7eee5511
commit 8d4988a43f
4 changed files with 19 additions and 15 deletions

View file

@ -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,

View file

@ -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;

View file

@ -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);

View file

@ -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);