Commit 7661e898 authored by David Adam's avatar David Adam Committed by Alexandre Julliard

ddraw: Exclusive mode is the corner case for SetCooperative, not the normal mode.

parent 7b8ac6a2
...@@ -602,7 +602,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, ...@@ -602,7 +602,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
if( (This->cooperative_level & DDSCL_FULLSCREEN) && window ) if( (This->cooperative_level & DDSCL_EXCLUSIVE) && window )
{ {
TRACE("Setting DDSCL_SETFOCUSWINDOW with an already set window, returning DDERR_HWNDALREADYSET\n"); TRACE("Setting DDSCL_SETFOCUSWINDOW with an already set window, returning DDERR_HWNDALREADYSET\n");
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
...@@ -626,76 +626,42 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, ...@@ -626,76 +626,42 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return DD_OK; return DD_OK;
} }
/* DDSCL_NORMAL or DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE */
if(cooplevel & DDSCL_NORMAL)
{
/* Can't coexist with fullscreen or exclusive */
if(cooplevel & (DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) )
{
TRACE("(%p) DDSCL_NORMAL is not compative with DDSCL_FULLSCREEN or DDSCL_EXCLUSIVE\n", This);
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
/* Switching from fullscreen? */
if(This->cooperative_level & DDSCL_FULLSCREEN)
{
This->cooperative_level &= ~DDSCL_FULLSCREEN;
This->cooperative_level &= ~DDSCL_EXCLUSIVE;
This->cooperative_level &= ~DDSCL_ALLOWMODEX;
IWineD3DDevice_ReleaseFocusWindow(This->wineD3DDevice); if(cooplevel & DDSCL_EXCLUSIVE)
}
/* Don't override focus windows or private device windows */
if( hwnd &&
!(This->focuswindow) &&
!(This->devicewindow) &&
(hwnd != window) )
{
This->dest_window = hwnd;
}
}
else if(cooplevel & DDSCL_FULLSCREEN)
{ {
/* Needs DDSCL_EXCLUSIVE */ if( !(cooplevel & DDSCL_FULLSCREEN) || !hwnd )
if(!(cooplevel & DDSCL_EXCLUSIVE) )
{ {
TRACE("(%p) DDSCL_FULLSCREEN needs DDSCL_EXCLUSIVE\n", This); TRACE("(%p) DDSCL_EXCLUSIVE needs DDSCL_FULLSCREEN and a window\n", This);
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
/* Need a HWND
if(hwnd == 0)
{
TRACE("(%p) DDSCL_FULLSCREEN needs a HWND\n", This);
return DDERR_INVALIDPARAMS;
}
*/
This->cooperative_level &= ~DDSCL_NORMAL;
/* Don't override focus windows or private device windows */
if( hwnd &&
!(This->focuswindow) &&
!(This->devicewindow) &&
(hwnd != window) )
{
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;
}
This->dest_window = hwnd;
}
} }
else if(cooplevel & DDSCL_EXCLUSIVE) else if( !(cooplevel & DDSCL_NORMAL) )
{ {
TRACE("(%p) DDSCL_EXCLUSIVE needs DDSCL_FULLSCREEN\n", This); TRACE("(%p) SetCooperativeLevel needs at least SetFocusWindow or Exclusive or Normal mode\n", This);
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
}
/* Do we switch from fullscreen to non-fullscreen ? */
if( !(cooplevel & DDSCL_FULLSCREEN) && (This->cooperative_level & DDSCL_FULLSCREEN) )
IWineD3DDevice_ReleaseFocusWindow(This->wineD3DDevice);
/* Don't override focus windows or private device windows */
if( hwnd && !This->focuswindow && !This->devicewindow && (hwnd != window))
{
if( cooplevel & DDSCL_FULLSCREEN )
{
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;
}
}
This->dest_window = hwnd;
} }
if(cooplevel & DDSCL_CREATEDEVICEWINDOW) if(cooplevel & DDSCL_CREATEDEVICEWINDOW)
...@@ -736,7 +702,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, ...@@ -736,7 +702,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
WARN("(%p) Unhandled flag DDSCL_FPUSETUP, harmless\n", This); WARN("(%p) Unhandled flag DDSCL_FPUSETUP, harmless\n", This);
/* Store the cooperative_level */ /* Store the cooperative_level */
This->cooperative_level |= cooplevel; This->cooperative_level = cooplevel;
TRACE("SetCooperativeLevel retuning DD_OK\n"); TRACE("SetCooperativeLevel retuning DD_OK\n");
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return DD_OK; return DD_OK;
......
...@@ -565,10 +565,10 @@ static void testcooperativelevels_normal(void) ...@@ -565,10 +565,10 @@ static void testcooperativelevels_normal(void)
skip("Failed to create the second window\n"); skip("Failed to create the second window\n");
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
todo_wine ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
if(sfw) if(sfw)
todo_wine ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2); ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2);
/* Try creating a double buffered primary in fullscreen + exclusive + normal mode */ /* Try creating a double buffered primary in fullscreen + exclusive + normal mode */
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL); rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
...@@ -577,8 +577,8 @@ static void testcooperativelevels_normal(void) ...@@ -577,8 +577,8 @@ static void testcooperativelevels_normal(void)
skip("Unsupported mode\n"); skip("Unsupported mode\n");
else else
{ {
todo_wine ok(rc == DD_OK, "IDirectDraw_CreateSurface returned %08x\n", rc); ok(rc == DD_OK, "IDirectDraw_CreateSurface returned %08x\n", rc);
todo_wine ok(surface!=NULL, "Returned NULL surface pointer\n"); ok(surface!=NULL, "Returned NULL surface pointer\n");
} }
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface); if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
...@@ -592,13 +592,13 @@ static void testcooperativelevels_normal(void) ...@@ -592,13 +592,13 @@ static void testcooperativelevels_normal(void)
if(hwnd2) sfw=SetForegroundWindow(hwnd2); if(hwnd2) sfw=SetForegroundWindow(hwnd2);
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_NORMAL); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_NORMAL);
todo_wine ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc);
if(sfw) if(sfw)
ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd); ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_NORMAL); rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_NORMAL);
todo_wine ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc); ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
/* Try creating a double buffered primary in fullscreen + normal mode */ /* Try creating a double buffered primary in fullscreen + normal mode */
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL); rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
...@@ -645,13 +645,13 @@ static void testcooperativelevels_normal(void) ...@@ -645,13 +645,13 @@ static void testcooperativelevels_normal(void)
rc = IDirectDraw_SetCooperativeLevel(lpDD, rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_NORMAL | DDSCL_FULLSCREEN); hwnd, DDSCL_NORMAL | DDSCL_FULLSCREEN);
todo_wine ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | FULLSCREEN) returned: %x\n",rc); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | FULLSCREEN) returned: %x\n",rc);
if(sfw) if(sfw)
ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd); ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL | DDSCL_FULLSCREEN); rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL | DDSCL_FULLSCREEN);
todo_wine ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc); ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
/* Set the focus window */ /* Set the focus window */
...@@ -761,7 +761,7 @@ static void testcooperativelevels_exclusive(void) ...@@ -761,7 +761,7 @@ static void testcooperativelevels_exclusive(void)
/* Full screen mode + exclusive mode */ /* Full screen mode + exclusive mode */
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE); rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
todo_wine ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received %x\n", rc); ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received %x\n", rc);
sfw=FALSE; sfw=FALSE;
if(hwnd2) if(hwnd2)
......
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