ddraw: Acquire/release the focus window from the correct location.
This commit is contained in:
parent
0838d0ab64
commit
914c8cb8ea
|
@ -324,6 +324,7 @@ static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
|
|||
HeapFree(GetProcessHeap(), 0, This->decls);
|
||||
|
||||
IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D8CB_DestroySwapChain);
|
||||
IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
|
||||
IWineD3DDevice_Release(This->WineD3DDevice);
|
||||
HeapFree(GetProcessHeap(), 0, This->handle_table.entries);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
|
@ -2791,6 +2792,19 @@ HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapte
|
|||
return hr;
|
||||
}
|
||||
|
||||
if (!parameters->Windowed)
|
||||
{
|
||||
if (!focus_window) focus_window = parameters->hDeviceWindow;
|
||||
if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(device->WineD3DDevice, focus_window)))
|
||||
{
|
||||
ERR("Failed to acquire focus window, hr %#x.\n", hr);
|
||||
IWineD3DDevice_Release(device->WineD3DDevice);
|
||||
wined3d_mutex_unlock();
|
||||
HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice);
|
||||
|
||||
wined3d_parameters.BackBufferWidth = parameters->BackBufferWidth;
|
||||
|
@ -2813,6 +2827,7 @@ HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapte
|
|||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize 3D, hr %#x.\n", hr);
|
||||
IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
|
||||
IWineD3DDevice_Release(device->WineD3DDevice);
|
||||
wined3d_mutex_unlock();
|
||||
HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
|
||||
|
@ -2855,6 +2870,7 @@ HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapte
|
|||
err:
|
||||
wined3d_mutex_lock();
|
||||
IWineD3DDevice_Uninit3D(device->WineD3DDevice, D3D8CB_DestroySwapChain);
|
||||
IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
|
||||
IWineD3DDevice_Release(device->WineD3DDevice);
|
||||
wined3d_mutex_unlock();
|
||||
HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
|
||||
|
|
|
@ -271,6 +271,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Release(LPDIRECT3DDEV
|
|||
HeapFree(GetProcessHeap(), 0, This->convertedDecls);
|
||||
|
||||
IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D9CB_DestroySwapChain);
|
||||
IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
|
||||
IWineD3DDevice_Release(This->WineD3DDevice);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
|
@ -2842,6 +2843,18 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte
|
|||
return hr;
|
||||
}
|
||||
|
||||
if (!parameters->Windowed)
|
||||
{
|
||||
if (!focus_window) focus_window = parameters->hDeviceWindow;
|
||||
if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(device->WineD3DDevice, focus_window)))
|
||||
{
|
||||
ERR("Failed to acquire focus window, hr %#x.\n", hr);
|
||||
IWineD3DDevice_Release(device->WineD3DDevice);
|
||||
wined3d_mutex_unlock();
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & D3DCREATE_ADAPTERGROUP_DEVICE)
|
||||
{
|
||||
WINED3DCAPS caps;
|
||||
|
@ -2885,6 +2898,7 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte
|
|||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize 3D, hr %#x.\n", hr);
|
||||
IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
|
||||
HeapFree(GetProcessHeap(), 0, wined3d_parameters);
|
||||
IWineD3DDevice_Release(device->WineD3DDevice);
|
||||
wined3d_mutex_unlock();
|
||||
|
@ -2921,6 +2935,7 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte
|
|||
ERR("Failed to allocate FVF vertex declaration map memory.\n");
|
||||
wined3d_mutex_lock();
|
||||
IWineD3DDevice_Uninit3D(device->WineD3DDevice, D3D9CB_DestroySwapChain);
|
||||
IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
|
||||
IWineD3DDevice_Release(device->WineD3DDevice);
|
||||
wined3d_mutex_unlock();
|
||||
return E_OUTOFMEMORY;
|
||||
|
|
|
@ -447,6 +447,8 @@ IDirectDrawImpl_SetCooperativeLevel(IDirectDraw7 *iface,
|
|||
This->cooperative_level &= ~DDSCL_FULLSCREEN;
|
||||
This->cooperative_level &= ~DDSCL_EXCLUSIVE;
|
||||
This->cooperative_level &= ~DDSCL_ALLOWMODEX;
|
||||
|
||||
IWineD3DDevice_ReleaseFocusWindow(This->wineD3DDevice);
|
||||
}
|
||||
|
||||
/* Don't override focus windows or private device windows */
|
||||
|
@ -483,6 +485,13 @@ IDirectDrawImpl_SetCooperativeLevel(IDirectDraw7 *iface,
|
|||
!(This->devicewindow) &&
|
||||
(hwnd != window) )
|
||||
{
|
||||
HRESULT hr = IWineD3DDevice_AcquireFocusWindow(This->wineD3DDevice, hwnd);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ERR("Failed to acquire focus window, hr %#x.\n", hr);
|
||||
LeaveCriticalSection(&ddraw_cs);
|
||||
return hr;
|
||||
}
|
||||
This->dest_window = hwnd;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3289,10 +3289,10 @@ static void test_wndproc(void)
|
|||
goto done;
|
||||
}
|
||||
|
||||
todo_wine ok(!expect_message, "Expected message %#x, but didn't receive it.\n", expect_message);
|
||||
ok(!expect_message, "Expected message %#x, but didn't receive it.\n", expect_message);
|
||||
|
||||
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
|
||||
todo_wine ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
|
||||
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
|
||||
(LONG_PTR)test_proc, proc);
|
||||
|
||||
ref = IDirectDraw7_Release(ddraw7);
|
||||
|
@ -3322,7 +3322,7 @@ static void test_wndproc(void)
|
|||
}
|
||||
|
||||
proc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
|
||||
todo_wine ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
|
||||
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
|
||||
(LONG_PTR)test_proc, proc);
|
||||
|
||||
ref = IDirectDraw7_Release(ddraw7);
|
||||
|
|
|
@ -1491,6 +1491,30 @@ static void destroy_dummy_textures(IWineD3DDeviceImpl *device, const struct wine
|
|||
memset(device->dummyTextureName, 0, gl_info->limits.textures * sizeof(*device->dummyTextureName));
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWineD3DDeviceImpl_AcquireFocusWindow(IWineD3DDevice *iface, HWND window)
|
||||
{
|
||||
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
|
||||
|
||||
if (!wined3d_register_window(window, device))
|
||||
{
|
||||
ERR("Failed to register window %p.\n", window);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
device->focus_window = window;
|
||||
SetForegroundWindow(window);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
static void WINAPI IWineD3DDeviceImpl_ReleaseFocusWindow(IWineD3DDevice *iface)
|
||||
{
|
||||
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
|
||||
|
||||
if (device->focus_window) wined3d_unregister_window(device->focus_window);
|
||||
device->focus_window = NULL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
|
||||
WINED3DPRESENT_PARAMETERS *pPresentationParameters)
|
||||
{
|
||||
|
@ -1507,17 +1531,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
|
|||
if(This->d3d_initialized) return WINED3DERR_INVALIDCALL;
|
||||
if(!This->adapter->opengl) return WINED3DERR_INVALIDCALL;
|
||||
|
||||
if (!pPresentationParameters->Windowed)
|
||||
{
|
||||
This->focus_window = This->createParms.hFocusWindow;
|
||||
if (!This->focus_window) This->focus_window = pPresentationParameters->hDeviceWindow;
|
||||
if (!wined3d_register_window(This->focus_window, This))
|
||||
{
|
||||
ERR("Failed to register window %p.\n", This->focus_window);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
TRACE("(%p) : Creating stateblock\n", This);
|
||||
/* Creating the startup stateBlock - Note Special Case: 0 => Don't fill in yet! */
|
||||
hr = IWineD3DDevice_CreateStateBlock(iface,
|
||||
|
@ -1571,8 +1584,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
|
|||
}
|
||||
}
|
||||
|
||||
if (This->focus_window) SetForegroundWindow(This->focus_window);
|
||||
|
||||
/* Setup the implicit swapchain. This also initializes a context. */
|
||||
TRACE("Creating implicit swapchain\n");
|
||||
hr = IWineD3DDeviceParent_CreateSwapChain(This->device_parent,
|
||||
|
@ -1703,7 +1714,6 @@ err_out:
|
|||
if (This->shader_priv) {
|
||||
This->shader_backend->shader_free_private(iface);
|
||||
}
|
||||
if (This->focus_window) wined3d_unregister_window(This->focus_window);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -1883,8 +1893,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface,
|
|||
|
||||
This->d3d_initialized = FALSE;
|
||||
|
||||
if (This->focus_window) wined3d_unregister_window(This->focus_window);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
|
@ -7042,6 +7050,8 @@ static const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl =
|
|||
/*** object tracking ***/
|
||||
IWineD3DDeviceImpl_EnumResources,
|
||||
IWineD3DDeviceImpl_GetSurfaceFromDC,
|
||||
IWineD3DDeviceImpl_AcquireFocusWindow,
|
||||
IWineD3DDeviceImpl_ReleaseFocusWindow,
|
||||
};
|
||||
|
||||
HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
|
||||
|
|
|
@ -3460,6 +3460,11 @@ interface IWineD3DDevice : IWineD3DBase
|
|||
[in] HDC dc,
|
||||
[out] IWineD3DSurface **surface
|
||||
);
|
||||
HRESULT AcquireFocusWindow(
|
||||
[in] HWND window
|
||||
);
|
||||
void ReleaseFocusWindow(
|
||||
);
|
||||
}
|
||||
|
||||
IWineD3D *WineDirect3DCreate(UINT dxVersion, IUnknown *parent);
|
||||
|
|
Loading…
Reference in New Issue