ddraw: Get rid of the local "window" variable in ddraw7_SetCooperativeLevel().
Having both a "hwnd" and a "window" here doesn't exactly make things much easier to follow.
This commit is contained in:
parent
292522c4ad
commit
a7f4ac283b
|
@ -696,23 +696,19 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL win
|
||||||
* (Probably others too, have to investigate)
|
* (Probably others too, have to investigate)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, DWORD cooplevel)
|
static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND window, DWORD cooplevel)
|
||||||
{
|
{
|
||||||
struct ddraw *This = impl_from_IDirectDraw7(iface);
|
struct ddraw *This = impl_from_IDirectDraw7(iface);
|
||||||
struct wined3d_surface *rt = NULL, *ds = NULL;
|
struct wined3d_surface *rt = NULL, *ds = NULL;
|
||||||
struct wined3d_stateblock *stateblock;
|
struct wined3d_stateblock *stateblock;
|
||||||
BOOL restore_state = FALSE;
|
BOOL restore_state = FALSE;
|
||||||
HWND window;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, window %p, flags %#x.\n", iface, hwnd, cooplevel);
|
TRACE("iface %p, window %p, flags %#x.\n", iface, window, cooplevel);
|
||||||
DDRAW_dump_cooperativelevel(cooplevel);
|
DDRAW_dump_cooperativelevel(cooplevel);
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
|
|
||||||
/* Get the old window */
|
|
||||||
window = This->dest_window;
|
|
||||||
|
|
||||||
/* Tests suggest that we need one of them: */
|
/* Tests suggest that we need one of them: */
|
||||||
if(!(cooplevel & (DDSCL_SETFOCUSWINDOW |
|
if(!(cooplevel & (DDSCL_SETFOCUSWINDOW |
|
||||||
DDSCL_NORMAL |
|
DDSCL_NORMAL |
|
||||||
|
@ -749,14 +745,14 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
|
||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = ddraw_set_focus_window(This, hwnd);
|
hr = ddraw_set_focus_window(This, window);
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cooplevel & DDSCL_EXCLUSIVE)
|
if (cooplevel & DDSCL_EXCLUSIVE)
|
||||||
{
|
{
|
||||||
if (!(cooplevel & DDSCL_FULLSCREEN) || !(hwnd || (cooplevel & DDSCL_CREATEDEVICEWINDOW)))
|
if (!(cooplevel & DDSCL_FULLSCREEN) || !(window || (cooplevel & DDSCL_CREATEDEVICEWINDOW)))
|
||||||
{
|
{
|
||||||
WARN("DDSCL_EXCLUSIVE requires DDSCL_FULLSCREEN and a window.\n");
|
WARN("DDSCL_EXCLUSIVE requires DDSCL_FULLSCREEN and a window.\n");
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
@ -794,20 +790,20 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
|
||||||
|
|
||||||
if (cooplevel & DDSCL_SETFOCUSWINDOW)
|
if (cooplevel & DDSCL_SETFOCUSWINDOW)
|
||||||
{
|
{
|
||||||
if (!hwnd)
|
if (!window)
|
||||||
{
|
{
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
return DDERR_NOHWND;
|
return DDERR_NOHWND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr = ddraw_set_focus_window(This, hwnd)))
|
if (FAILED(hr = ddraw_set_focus_window(This, window)))
|
||||||
{
|
{
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hwnd = device_window;
|
window = device_window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -819,28 +815,28 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((This->cooperative_level & DDSCL_EXCLUSIVE)
|
if ((This->cooperative_level & DDSCL_EXCLUSIVE)
|
||||||
&& (hwnd != window || !(cooplevel & DDSCL_EXCLUSIVE)))
|
&& (window != This->dest_window || !(cooplevel & DDSCL_EXCLUSIVE)))
|
||||||
wined3d_device_release_focus_window(This->wined3d_device);
|
wined3d_device_release_focus_window(This->wined3d_device);
|
||||||
|
|
||||||
if ((cooplevel & DDSCL_FULLSCREEN) != (This->cooperative_level & DDSCL_FULLSCREEN) || hwnd != window)
|
if ((cooplevel & DDSCL_FULLSCREEN) != (This->cooperative_level & DDSCL_FULLSCREEN) || window != This->dest_window)
|
||||||
{
|
{
|
||||||
if (This->cooperative_level & DDSCL_FULLSCREEN)
|
if (This->cooperative_level & DDSCL_FULLSCREEN)
|
||||||
wined3d_device_restore_fullscreen_window(This->wined3d_device, window);
|
wined3d_device_restore_fullscreen_window(This->wined3d_device, This->dest_window);
|
||||||
|
|
||||||
if (cooplevel & DDSCL_FULLSCREEN)
|
if (cooplevel & DDSCL_FULLSCREEN)
|
||||||
{
|
{
|
||||||
struct wined3d_display_mode display_mode;
|
struct wined3d_display_mode display_mode;
|
||||||
|
|
||||||
wined3d_get_adapter_display_mode(This->wined3d, WINED3DADAPTER_DEFAULT, &display_mode, NULL);
|
wined3d_get_adapter_display_mode(This->wined3d, WINED3DADAPTER_DEFAULT, &display_mode, NULL);
|
||||||
wined3d_device_setup_fullscreen_window(This->wined3d_device, hwnd,
|
wined3d_device_setup_fullscreen_window(This->wined3d_device, window,
|
||||||
display_mode.width, display_mode.height);
|
display_mode.width, display_mode.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cooplevel & DDSCL_EXCLUSIVE)
|
if ((cooplevel & DDSCL_EXCLUSIVE)
|
||||||
&& (hwnd != window || !(This->cooperative_level & DDSCL_EXCLUSIVE)))
|
&& (window != This->dest_window || !(This->cooperative_level & DDSCL_EXCLUSIVE)))
|
||||||
{
|
{
|
||||||
hr = wined3d_device_acquire_focus_window(This->wined3d_device, hwnd);
|
hr = wined3d_device_acquire_focus_window(This->wined3d_device, window);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
ERR("Failed to acquire focus window, hr %#x.\n", hr);
|
ERR("Failed to acquire focus window, hr %#x.\n", hr);
|
||||||
|
@ -879,7 +875,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
|
||||||
ddraw_destroy_swapchain(This);
|
ddraw_destroy_swapchain(This);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr = ddraw_create_swapchain(This, hwnd, !(cooplevel & DDSCL_FULLSCREEN))))
|
if (FAILED(hr = ddraw_create_swapchain(This, window, !(cooplevel & DDSCL_FULLSCREEN))))
|
||||||
ERR("Failed to create swapchain, hr %#x.\n", hr);
|
ERR("Failed to create swapchain, hr %#x.\n", hr);
|
||||||
|
|
||||||
if (restore_state)
|
if (restore_state)
|
||||||
|
@ -915,7 +911,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
|
||||||
|
|
||||||
/* Store the cooperative_level */
|
/* Store the cooperative_level */
|
||||||
This->cooperative_level = cooplevel;
|
This->cooperative_level = cooplevel;
|
||||||
This->dest_window = hwnd;
|
This->dest_window = window;
|
||||||
TRACE("SetCooperativeLevel retuning DD_OK\n");
|
TRACE("SetCooperativeLevel retuning DD_OK\n");
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue