From a59d0f45c1ab26c4754c9eb5d8c730a5dc997ba1 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 6 Oct 2010 12:01:29 +0200 Subject: [PATCH] wined3d: Acquire / release the focus window during reset. --- dlls/wined3d/device.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 7b2b8ced704..97acd5f9946 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -6354,15 +6354,30 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface, if (!pPresentationParameters->Windowed != !swapchain->presentParms.Windowed || DisplayModeChanged) { + BOOL filter = This->filter_messages; + This->filter_messages = TRUE; + IWineD3DDevice_SetDisplayMode(iface, 0, &mode); if (!pPresentationParameters->Windowed) { - if(swapchain->presentParms.Windowed) { + if (swapchain->presentParms.Windowed) + { + HWND focus_window = This->createParms.hFocusWindow; + if (!focus_window) focus_window = pPresentationParameters->hDeviceWindow; + if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(iface, focus_window))) + { + ERR("Failed to acquire focus window, hr %#x.\n", hr); + IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain); + return hr; + } + /* switch from windowed to fs */ swapchain_setup_fullscreen_window(swapchain, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight); - } else { + } + else + { /* Fullscreen -> fullscreen mode change */ MoveWindow(swapchain->device_window, 0, 0, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight, @@ -6373,9 +6388,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface, { /* Fullscreen -> windowed switch */ swapchain_restore_fullscreen_window(swapchain); + IWineD3DDevice_ReleaseFocusWindow(iface); } swapchain->presentParms.Windowed = pPresentationParameters->Windowed; - } else if(!pPresentationParameters->Windowed) { + + This->filter_messages = filter; + } + else if (!pPresentationParameters->Windowed) + { DWORD style = This->style, exStyle = This->exStyle; /* If we're in fullscreen, and the mode wasn't changed, we have to get the window back into * the right position. Some applications(Battlefield 2, Guild Wars) move it and then call