diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 03a97b6dc7c..7700dfb30a4 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2855,7 +2855,9 @@ HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapte if (!parameters->Windowed) { - if (!focus_window) focus_window = parameters->hDeviceWindow; + HWND device_window = parameters->hDeviceWindow; + + if (!focus_window) focus_window = device_window; if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(device->WineD3DDevice, focus_window))) { ERR("Failed to acquire focus window, hr %#x.\n", hr); @@ -2864,6 +2866,11 @@ HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapte HeapFree(GetProcessHeap(), 0, device->handle_table.entries); return hr; } + + if (!device_window) device_window = focus_window; + IWineD3DDevice_SetupFullscreenWindow(device->WineD3DDevice, device_window, + parameters->BackBufferWidth, + parameters->BackBufferHeight); } if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice); diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index c0b8b743ee0..b097ecec120 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3271,6 +3271,16 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte return hr; } + if (flags & D3DCREATE_ADAPTERGROUP_DEVICE) + { + WINED3DCAPS caps; + + IWineD3D_GetDeviceCaps(wined3d, adapter, device_type, &caps); + count = caps.NumberOfAdaptersInGroup; + } + + if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice); + if (!parameters->Windowed) { if (!focus_window) focus_window = parameters->hDeviceWindow; @@ -3281,18 +3291,18 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte wined3d_mutex_unlock(); return hr; } + + for (i = 0; i < count; ++i) + { + HWND device_window = parameters[i].hDeviceWindow; + + if (!device_window) device_window = focus_window; + IWineD3DDevice_SetupFullscreenWindow(device->WineD3DDevice, device_window, + parameters[i].BackBufferWidth, + parameters[i].BackBufferHeight); + } } - if (flags & D3DCREATE_ADAPTERGROUP_DEVICE) - { - WINED3DCAPS caps; - - IWineD3D_GetDeviceCaps(wined3d, adapter, device_type, &caps); - count = caps.NumberOfAdaptersInGroup; - } - - if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice); - wined3d_parameters = HeapAlloc(GetProcessHeap(), 0, sizeof(*wined3d_parameters) * count); if (!wined3d_parameters) { diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 20f743f784c..512fd8e10c4 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -644,24 +644,31 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, } /* Do we switch from fullscreen to non-fullscreen ? */ - - if( !(cooplevel & DDSCL_FULLSCREEN) && (This->cooperative_level & DDSCL_FULLSCREEN) ) + if (!(cooplevel & DDSCL_FULLSCREEN) && (This->cooperative_level & DDSCL_FULLSCREEN)) + { IWineD3DDevice_ReleaseFocusWindow(This->wineD3DDevice); + IWineD3DDevice_RestoreFullscreenWindow(This->wineD3DDevice, This->dest_window); + } /* Don't override focus windows or private device windows */ - if( hwnd && !This->focuswindow && !This->devicewindow && (hwnd != window)) + if (hwnd && !This->focuswindow && !This->devicewindow && (hwnd != window)) { - if( cooplevel & DDSCL_FULLSCREEN ) - { - 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; + if (cooplevel & DDSCL_FULLSCREEN) + { + WINED3DDISPLAYMODE display_mode; + HRESULT hr; + + IWineD3D_GetAdapterDisplayMode(This->wineD3D, WINED3DADAPTER_DEFAULT, &display_mode); + IWineD3DDevice_SetupFullscreenWindow(This->wineD3DDevice, hwnd, display_mode.Width, display_mode.Height); + 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; } if(cooplevel & DDSCL_CREATEDEVICEWINDOW) @@ -797,6 +804,8 @@ static HRESULT ddraw_set_display_mode(IDirectDraw7 *iface, DWORD Width, DWORD He hr = IWineD3DDevice_SetDisplayMode(This->wineD3DDevice, 0, /* First swapchain */ &Mode); + IWineD3DDevice_RestoreFullscreenWindow(This->wineD3DDevice, This->dest_window); + IWineD3DDevice_SetupFullscreenWindow(This->wineD3DDevice, This->dest_window, Width, Height); LeaveCriticalSection(&ddraw_cs); switch(hr) { diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index afa1d8427f1..9066e4e1b4b 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -3272,6 +3272,9 @@ static void test_wndproc(void) static const UINT messages[] = { + WM_WINDOWPOSCHANGING, + WM_MOVE, + WM_SIZE, WM_WINDOWPOSCHANGING, WM_ACTIVATE, WM_SETFOCUS, diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c index 0ced9dac886..a103d652dff 100644 --- a/dlls/ddraw/tests/ddrawmodes.c +++ b/dlls/ddraw/tests/ddrawmodes.c @@ -779,7 +779,7 @@ static void testcooperativelevels_exclusive(void) /* rect_before_create is assumed to hold the screen rect */ GetClientRect(hwnd, &window_rect); rc = EqualRect(&rect_before_create, &window_rect); - todo_wine ok(rc!=0, "Fullscreen window has wrong size\n"); + ok(rc, "Fullscreen window has wrong size.\n"); /* Set the focus window. Should fail */ rc = IDirectDraw_SetCooperativeLevel(lpDD, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8030bc3d649..ed3df0a4fda 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1767,8 +1767,9 @@ static LONG fullscreen_exstyle(LONG exstyle) return exstyle; } -void device_setup_fullscreen_window(IWineD3DDeviceImpl *device, HWND window, UINT w, UINT h) +static void WINAPI IWineD3DDeviceImpl_SetupFullscreenWindow(IWineD3DDevice *iface, HWND window, UINT w, UINT h) { + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface; BOOL filter_messages; LONG style, exstyle; @@ -1799,8 +1800,9 @@ void device_setup_fullscreen_window(IWineD3DDeviceImpl *device, HWND window, UIN device->filter_messages = filter_messages; } -void device_restore_fullscreen_window(IWineD3DDeviceImpl *device, HWND window) +static void WINAPI IWineD3DDeviceImpl_RestoreFullscreenWindow(IWineD3DDevice *iface, HWND window) { + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface; BOOL filter_messages; LONG style, exstyle; @@ -6454,7 +6456,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface, } /* switch from windowed to fs */ - device_setup_fullscreen_window(This, swapchain->device_window, + IWineD3DDevice_SetupFullscreenWindow(iface, swapchain->device_window, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight); } @@ -6469,7 +6471,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface, else if (!swapchain->presentParms.Windowed) { /* Fullscreen -> windowed switch */ - device_restore_fullscreen_window(This, swapchain->device_window); + IWineD3DDevice_RestoreFullscreenWindow(iface, swapchain->device_window); IWineD3DDevice_ReleaseFocusWindow(iface); } swapchain->presentParms.Windowed = pPresentationParameters->Windowed; @@ -6485,7 +6487,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface, */ This->style = 0; This->exStyle = 0; - device_setup_fullscreen_window(This, swapchain->device_window, + IWineD3DDevice_SetupFullscreenWindow(iface, swapchain->device_window, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight); This->style = style; @@ -6888,6 +6890,8 @@ static const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl = IWineD3DDeviceImpl_GetSurfaceFromDC, IWineD3DDeviceImpl_AcquireFocusWindow, IWineD3DDeviceImpl_ReleaseFocusWindow, + IWineD3DDeviceImpl_SetupFullscreenWindow, + IWineD3DDeviceImpl_RestoreFullscreenWindow, }; HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d, diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 006f353a965..c0467db17e5 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -581,13 +581,6 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface swapchain->win_handle = window; swapchain->device_window = window; - if (!present_parameters->Windowed && window) - { - device_setup_fullscreen_window(device, window, - present_parameters->BackBufferWidth, - present_parameters->BackBufferHeight); - } - IWineD3D_GetAdapterDisplayMode(device->wined3d, adapter->ordinal, &mode); swapchain->orig_width = mode.Width; swapchain->orig_height = mode.Height; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 39b57348619..f8550d15f4b 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1773,8 +1773,6 @@ LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, BOOL uni UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN; void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN; void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN; -void device_restore_fullscreen_window(IWineD3DDeviceImpl *device, HWND hwnd) DECLSPEC_HIDDEN; -void device_setup_fullscreen_window(IWineD3DDeviceImpl *device, HWND hwnd, UINT w, UINT h) DECLSPEC_HIDDEN; void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN; void device_switch_onscreen_ds(IWineD3DDeviceImpl *device, struct wined3d_context *context, diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index c816a292233..8876c3bbf17 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -3374,6 +3374,14 @@ interface IWineD3DDevice : IUnknown ); void ReleaseFocusWindow( ); + void SetupFullscreenWindow( + [in] HWND window, + [in] UINT w, + [in] UINT h + ); + void RestoreFullscreenWindow( + [in] HWND window + ); } IWineD3D * __stdcall WineDirect3DCreate(UINT dxVersion, void *parent);