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);
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;
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);
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);
HeapFree(GetProcessHeap(), 0, This->convertedDecls);
IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D9CB_DestroySwapChain);
+ IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
IWineD3DDevice_Release(This->WineD3DDevice);
wined3d_mutex_unlock();
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;
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();
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;
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 */
!(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;
}
}
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);
}
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);
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)
{
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,
}
}
- 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,
if (This->shader_priv) {
This->shader_backend->shader_free_private(iface);
}
- if (This->focus_window) wined3d_unregister_window(This->focus_window);
return hr;
}
This->d3d_initialized = FALSE;
- if (This->focus_window) wined3d_unregister_window(This->focus_window);
-
return WINED3D_OK;
}
/*** object tracking ***/
IWineD3DDeviceImpl_EnumResources,
IWineD3DDeviceImpl_GetSurfaceFromDC,
+ IWineD3DDeviceImpl_AcquireFocusWindow,
+ IWineD3DDeviceImpl_ReleaseFocusWindow,
};
HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
[in] HDC dc,
[out] IWineD3DSurface **surface
);
+ HRESULT AcquireFocusWindow(
+ [in] HWND window
+ );
+ void ReleaseFocusWindow(
+ );
}
IWineD3D *WineDirect3DCreate(UINT dxVersion, IUnknown *parent);