From f8befb18a2e6442dea65a762541cfd6fe9ca6308 Mon Sep 17 00:00:00 2001
From: David Adam <david.adam.cnrs@gmail.com>
Date: Tue, 24 Aug 2010 15:16:15 +0200
Subject: SetCooperativeLevel with Full screen + exclusive + normal is authorized

---
 dlls/ddraw/ddraw.c            |    8 ++++----
 dlls/ddraw/tests/ddrawmodes.c |   39 ++++++++++++++++++++++++++++++++++++---
 2 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 572c790..8102054 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -621,13 +621,13 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
             This->devicewindow = NULL;
         }
     }
-    /* DDSCL_NORMAL or DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE */
+    /* DDSCL_NORMAL */
     if(cooplevel & DDSCL_NORMAL)
     {
-        /* Can't coexist with fullscreen or exclusive */
-        if(cooplevel & (DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) )
+        /* Can't coexist with  exclusive only*/
+        if(cooplevel == (DDSCL_NORMAL | DDSCL_EXCLUSIVE) )
         {
-            TRACE("(%p) DDSCL_NORMAL is not compative with DDSCL_FULLSCREEN or DDSCL_EXCLUSIVE\n", This);
+            TRACE("(%p) DDSCL_NORMAL is not compative with DDSCL_EXCLUSIVE only \n", This);
             LeaveCriticalSection(&ddraw_cs);
             return DDERR_INVALIDPARAMS;
         }
diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c
index 8235d86..d80bc40 100644
--- a/dlls/ddraw/tests/ddrawmodes.c
+++ b/dlls/ddraw/tests/ddrawmodes.c
@@ -558,11 +558,44 @@ static void testcooperativelevels_normal(void)
     surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
 
     /* Do some tests with DDSCL_NORMAL mode */
-
+    
+    /* Full screen mode + normal mode + exclusive mode */
+    rc = IDirectDraw_SetCooperativeLevel(lpDD,
+        hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
+    /* Try creating a double buffered primary in fulscreen + exclusive + normal mode */
+    rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
+    if (rc == DDERR_UNSUPPORTEDMODE)
+        skip("Unsupported mode\n");
+    else
+    {
+        ok(rc == DD_OK, "IDirectDraw_CreateSurface returned %08x\n", rc);
+        ok(surface!=NULL, "Returned NULL surface pointer \n");
+    }
+    
+    /* Exclusive mode + normal mode */
+    rc = IDirectDraw_SetCooperativeLevel(lpDD,
+        hwnd, DDSCL_EXCLUSIVE | DDSCL_NORMAL);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
+        
+    /* Full screen mode + normal mode */
+    rc = IDirectDraw_SetCooperativeLevel(lpDD,
+        hwnd, DDSCL_FULLSCREEN | DDSCL_NORMAL);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc);  
+    /* Try creating a double buffered primary in fulscreen + normal mode */
+    rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
+    if (rc == DDERR_UNSUPPORTEDMODE)
+        skip("Unsupported mode\n");
+    else
+    {
+        ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
+        ok(surface == NULL, "Returned surface pointer is %p\n", surface);
+    }
+    
+    /* Normal mode */
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_NORMAL);
     ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc);
-
     /* Try creating a double buffered primary in normal mode */
     rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
     if (rc == DDERR_UNSUPPORTEDMODE)
@@ -664,7 +697,7 @@ static void testcooperativelevels_exclusive(void)
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_FULLSCREEN);
     ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc);
-
+  
     /* Full screen mode + exclusive mode */
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-- 
1.7.1

