From 0a90271d6984d047893b6d93d2baa5d20dadfac7 Mon Sep 17 00:00:00 2001 From: David Adam Date: Fri, 22 Oct 2010 08:32:39 +0200 Subject: [PATCH] ddraw: SETFOCUSWINDOW lives independently of other flags. --- dlls/ddraw/ddraw.c | 24 ++++++++++++++---------- dlls/ddraw/tests/ddrawmodes.c | 7 +++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 346c7c5754c..1f88fa53922 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -586,21 +586,23 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, if(cooplevel & DDSCL_SETFOCUSWINDOW) { /* This isn't compatible with a lot of flags */ - if(cooplevel & ( DDSCL_MULTITHREADED | - DDSCL_FPUSETUP | - DDSCL_FPUPRESERVE | - DDSCL_ALLOWREBOOT | - DDSCL_ALLOWMODEX | - DDSCL_SETDEVICEWINDOW | - DDSCL_NORMAL | - DDSCL_EXCLUSIVE | - DDSCL_FULLSCREEN ) ) + if(cooplevel & ( DDSCL_MULTITHREADED | + DDSCL_CREATEDEVICEWINDOW | + DDSCL_FPUSETUP | + DDSCL_FPUPRESERVE | + DDSCL_ALLOWREBOOT | + DDSCL_ALLOWMODEX | + DDSCL_SETDEVICEWINDOW | + DDSCL_NORMAL | + DDSCL_EXCLUSIVE | + DDSCL_FULLSCREEN ) ) { TRACE("Called with incompatible flags, returning DDERR_INVALIDPARAMS\n"); LeaveCriticalSection(&ddraw_cs); return DDERR_INVALIDPARAMS; } - else if( (This->cooperative_level & DDSCL_FULLSCREEN) && window) + + if( (This->cooperative_level & DDSCL_FULLSCREEN) && window ) { TRACE("Setting DDSCL_SETFOCUSWINDOW with an already set window, returning DDERR_HWNDALREADYSET\n"); LeaveCriticalSection(&ddraw_cs); @@ -620,6 +622,8 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, DestroyWindow(This->devicewindow); This->devicewindow = NULL; } + + return DD_OK; } /* DDSCL_NORMAL or DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE */ if(cooplevel & DDSCL_NORMAL) diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c index 709ea5d308f..b6491f3e74c 100644 --- a/dlls/ddraw/tests/ddrawmodes.c +++ b/dlls/ddraw/tests/ddrawmodes.c @@ -557,6 +557,9 @@ static void testcooperativelevels_normal(void) surfacedesc.dwBackBufferCount = 1; surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; + rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW); + ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc); + /* Do some tests with DDSCL_NORMAL mode */ /* Fullscreen mode + normal mode + exclusive mode */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL); @@ -604,6 +607,10 @@ static void testcooperativelevels_normal(void) if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface); /* Set the focus window */ + + rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW); + ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc); + rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW);