Commit 6fcb33f5 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Window proc replacement depends on DDSCL_EXCLUSIVE, not DDSCL_FULLSCREEN.

parent 4503d0cb
......@@ -641,12 +641,15 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
TRACE("(%p) SetCooperativeLevel needs at least SetFocusWindow or Exclusive or Normal mode\n", This);
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
}
if ((This->cooperative_level & DDSCL_EXCLUSIVE)
&& (hwnd != window || !(cooplevel & DDSCL_EXCLUSIVE)))
IWineD3DDevice_ReleaseFocusWindow(This->wineD3DDevice);
/* Do we switch from fullscreen to non-fullscreen ? */
if (!(cooplevel & DDSCL_FULLSCREEN) && (This->cooperative_level & DDSCL_FULLSCREEN))
{
IWineD3DDevice_ReleaseFocusWindow(This->wineD3DDevice);
IWineD3DDevice_RestoreFullscreenWindow(This->wineD3DDevice, This->dest_window);
}
......@@ -656,21 +659,25 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND 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_EXCLUSIVE)
&& (hwnd != window || !(This->cooperative_level & DDSCL_EXCLUSIVE)))
{
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;
}
}
if(cooplevel & DDSCL_CREATEDEVICEWINDOW)
{
/* Don't create a device window if a focus window is set */
......
......@@ -3281,6 +3281,7 @@ static void test_wndproc(void)
0,
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
hr = pDirectDrawCreateEx(NULL, (void **)&ddraw7, &IID_IDirectDraw7, NULL);
if (FAILED(hr))
{
......@@ -3323,6 +3324,39 @@ static void test_wndproc(void)
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
/* DDSCL_NORMAL doesn't. */
hr = pDirectDrawCreateEx(NULL, (void **)&ddraw7, &IID_IDirectDraw7, NULL);
if (FAILED(hr))
{
skip("Failed to create IDirectDraw7 object (%#x), skipping tests.\n", hr);
return;
}
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
hr = IDirectDraw7_SetCooperativeLevel(ddraw7, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
if (FAILED(hr))
{
IDirectDraw7_Release(ddraw7);
goto done;
}
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
ref = IDirectDraw7_Release(ddraw7);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
/* The original window proc is only restored by ddraw if the current
* window proc matches the one ddraw set. */
hr = pDirectDrawCreateEx(NULL, (void **)&ddraw7, &IID_IDirectDraw7, NULL);
if (FAILED(hr))
{
......
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