Commit 7e3985e1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Setup the device window in SetCooperativeLevel().

parent b898130a
......@@ -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);
......
......@@ -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,17 +3291,17 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte
wined3d_mutex_unlock();
return hr;
}
}
if (flags & D3DCREATE_ADAPTERGROUP_DEVICE)
for (i = 0; i < count; ++i)
{
WINED3DCAPS caps;
HWND device_window = parameters[i].hDeviceWindow;
IWineD3D_GetDeviceCaps(wined3d, adapter, device_type, &caps);
count = caps.NumberOfAdaptersInGroup;
if (!device_window) device_window = focus_window;
IWineD3DDevice_SetupFullscreenWindow(device->WineD3DDevice, device_window,
parameters[i].BackBufferWidth,
parameters[i].BackBufferHeight);
}
}
if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice);
wined3d_parameters = HeapAlloc(GetProcessHeap(), 0, sizeof(*wined3d_parameters) * count);
if (!wined3d_parameters)
......
......@@ -644,16 +644,23 @@ 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 )
if (cooplevel & DDSCL_FULLSCREEN)
{
HRESULT hr = IWineD3DDevice_AcquireFocusWindow(This->wineD3DDevice, hwnd);
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);
......@@ -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)
{
......
......@@ -3273,6 +3273,9 @@ static void test_wndproc(void)
static const UINT messages[] =
{
WM_WINDOWPOSCHANGING,
WM_MOVE,
WM_SIZE,
WM_WINDOWPOSCHANGING,
WM_ACTIVATE,
WM_SETFOCUS,
0,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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;
......
......@@ -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,
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment