This fixes tabbing out of Deus Ex Game of the Year edition.
Signed-off-by: Stefan Dösinger stefan@codeweavers.com
---
This patch ignores that d3d9 has different behavior than ddraw. D3d9's behavior matches what we currently have (the device state during focus loss is D3DERR_DEVICENOTRESET, and only the final WM_ACTIVATEAPP message has D3DERR_DEVICELOST). This could be handled via a create flag. I am not doing it for now because I think it is less likely for a d3d9 app to depend on it (you can't destroy the device until the very end, but still can't do anything due to D3DERR_DEVICENOTRESET). --- dlls/wined3d/device.c | 2 -- dlls/wined3d/swapchain.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index abb2a893637..70d43e07e39 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5319,8 +5319,6 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
for (i = 0; i < device->swapchain_count; i++) wined3d_swapchain_activate(device->swapchains[i], wparam); - - device->device_parent->ops->activate(device->device_parent, wparam); } else if (message == WM_SYSCOMMAND) { diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index b068cf164cd..9c48de2193c 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -1162,6 +1162,9 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa device->adapter->ordinal, &swapchain->d3d_mode))) ERR("Failed to set display mode.\n"); } + + if (swapchain == device->swapchains[0]) + device->device_parent->ops->activate(device->device_parent, TRUE); } else { @@ -1171,6 +1174,17 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa
swapchain->reapply_mode = TRUE;
+ /* Some DDraw apps (Deus Ex: GOTY, and presumably all UT 1 based games) destroy the device + * during window minimization. Do our housekeeping now, as the device may not exist after + * the ShowWindow call. + * + * In d3d9, the device is marked lost after the window is minimized. If we find an app + * that needs this behavior (e.g. because it calls TestCooperativeLevel in the window proc) + * we'll have to control this via a create flag. Note that the device and swapchain are not + * safe to access after the ShowWindow call. */ + if (swapchain == device->swapchains[0]) + device->device_parent->ops->activate(device->device_parent, FALSE); + if (!(device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES) && IsWindowVisible(swapchain->device_window)) ShowWindow(swapchain->device_window, SW_MINIMIZE);