diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index ad9106d437..5fd8531309 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5844,8 +5844,27 @@ BOOL WINAPI IWineD3DDeviceImpl_ShowCursor(IWineD3DDevice* iface, BOOL bShow HRESULT WINAPI IWineD3DDeviceImpl_TestCooperativeLevel(IWineD3DDevice* iface) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; - FIXME("(%p) : stub\n", This); /* No way of notifying yet! */ - return D3D_OK; + TRACE("(%p) : state (%lu)\n", This, This->state); + /* TODO: Implement wrapping of the WndProc so that mimimize and maxamise can be monitored and the states adjusted. */ + switch (This->state) { + case D3D_OK: + return D3D_OK; + case D3DERR_DEVICELOST: + { + ResourceList *resourceList = This->resources; + while (NULL != resourceList) { + if (((IWineD3DResourceImpl *)resourceList->resource)->resource.pool == D3DPOOL_DEFAULT /* TODO: IWineD3DResource_GetPool(resourceList->resource)*/) + return D3DERR_DEVICENOTRESET; + resourceList = resourceList->next; + } + return D3DERR_DEVICELOST; + } + case D3DERR_DRIVERINTERNALERROR: + return D3DERR_DRIVERINTERNALERROR; + } + + /* Unknown state */ + return D3DERR_DRIVERINTERNALERROR; } diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index ea18f54d1e..bcb292cebc 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -1639,6 +1639,9 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV IWineD3D_AddRef(object->wineD3D); object->parent = parent; + /* Set the state up as invalid until the device is fully created */ + object->state = D3DERR_DRIVERINTERNALERROR; + TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType, hFocusWindow, BehaviourFlags, pPresentationParameters, ppReturnedDeviceInterface); TRACE("(%p)->(DepthStencil:(%u,%s), BackBufferFormat:(%u,%s))\n", This, @@ -1736,8 +1739,15 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV } + /* set the state of the device to valid */ + object->state = D3D_OK; + return D3D_OK; create_device_error: + + /* Set the device state to error */ + object->state = D3DERR_DRIVERINTERNALERROR; + if (object->updateStateBlock != NULL) { IWineD3DStateBlock_Release((IWineD3DStateBlock *)object->updateStateBlock); object->updateStateBlock = NULL; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b816349de5..4b2c781b6d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -536,6 +536,9 @@ typedef struct IWineD3DDeviceImpl /* Debug stream management */ BOOL debug; + /* Device state management */ + HRESULT state; + /* Screen buffer resources */ glContext contextCache[CONTEXT_CACHE];