Commit 71af04b6 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

- Add handling for DDSCL_SETFOCUSWINDOW in SetCooperativeLevel.

- Print a fixme for DDSCL_CREATEDEVICEWINDOW and DDSCL_SETDEVICEWINDOW. - Don't allow DDSCL_EXCLUSIVE without DDSCL_FULLSCREEN.
parent fb3a9ed1
...@@ -1116,13 +1116,65 @@ Main_DirectDraw_SetCooperativeLevel(LPDIRECTDRAW7 iface, HWND hwnd, ...@@ -1116,13 +1116,65 @@ Main_DirectDraw_SetCooperativeLevel(LPDIRECTDRAW7 iface, HWND hwnd,
* created." Otherwise the window can be changed??? * created." Otherwise the window can be changed???
* *
* This appears to be wrong - comment it out for now. * This appears to be wrong - comment it out for now.
* This seems to be true at least for DDSCL_SETFOCUSWINDOW
* It looks like Windows doesn't store the HWND in all cases,
* probably if DDSCL_NORMAL is specified, but that's not sure
if (This->window) if (This->window)
return DDERR_HWNDALREADYSET; return DDERR_HWNDALREADYSET;
*/ */
if (!(cooplevel & (DDSCL_EXCLUSIVE|DDSCL_NORMAL))) /* DDSCL_EXCLUSIVE or DDSCL_NORMAL or DDSCL_SETFOCUSWINDOW must be given */
return DDERR_INVALIDPARAMS; if (!(cooplevel & (DDSCL_EXCLUSIVE|DDSCL_NORMAL|DDSCL_SETFOCUSWINDOW)))
{
ERR("(%p) : Call to SetCooperativeLevel failed: cooplevel != DDSCL_EXCLUSIVE|DDSCL_NORMAL|DDSCL_SETFOCUSWINDOW, returning DDERR_INVALIDPARAMS\n", This);
return DDERR_INVALIDPARAMS;
}
/* Device window and focus Window. They only really matter in a
* Multi-Monitor application, but some games specify them and we
* have to react correctly. */
if(cooplevel & DDSCL_SETFOCUSWINDOW)
{
/* This flag is a biest: It is only valid when DDSCL_NORMAL has been set
* or no hwnd is set and no other flags are allowed, except DDSCL_NOWINDOWCHANGES
*/
if(This->window)
if(!(This->cooperative_level & DDSCL_NORMAL))
{
ERR("(%p) : Call to SetCooperativeLevel failed: DDSCL_SETFOCUSWINDOW may not be used in Cooplevel %08lx, returning DDERR_HWNDALREADYSET\n",
This, This->cooperative_level);
return DDERR_HWNDALREADYSET;
}
if((cooplevel != DDSCL_SETFOCUSWINDOW))
if(cooplevel != (DDSCL_SETFOCUSWINDOW | DDSCL_NOWINDOWCHANGES) )
{
ERR("(%p) : Call to SetCooperativeLevel failed: Invalid use of DDSCL_SETFOCUSWINDOW, returning DDERR_INVALIDPARAMS\n", This);
return DDERR_INVALIDPARAMS;
}
/* Don't know what exactly to do, but it's perfectly valid
* to pass DDSCL_SETFOCUSWINDOW only */
FIXME("(%p) : Poorly handled flag DDSCL_SETFOCUSWINDOW\n", This);
/* Store the flag in the cooperative level. I don't think that all other
* flags should be overwritten, so just add it
* (In the most cases this will be DDSCL_SETFOCUSWINDOW | DDSCL_NORMAL) */
cooplevel |= DDSCL_SETFOCUSWINDOW;
return DD_OK;
}
/* DDSCL_EXCLUSE mode requires DDSCL_FULLSCREEN and vice versa */
if((cooplevel & DDSCL_EXCLUSIVE) && !(cooplevel & DDSCL_FULLSCREEN))
return DDERR_INVALIDPARAMS;
/* The other case is checked above */
/* Unhandled flags. Give a warning */
if(cooplevel & DDSCL_SETDEVICEWINDOW)
FIXME("(%p) : Unhandled flag DDSCL_SETDEVICEWINDOW.\n", This);
if(cooplevel & DDSCL_CREATEDEVICEWINDOW)
FIXME("(%p) : Unhandled flag DDSCL_CREATEDEVICEWINDOW.\n", This);
/* Perhaps the hwnd is only set in DDSCL_EXLUSIVE and DDSCL_FULLSCREEN mode. Not sure */
This->window = hwnd; This->window = hwnd;
This->cooperative_level = cooplevel; This->cooperative_level = cooplevel;
......
...@@ -31,10 +31,8 @@ static int modes_cnt; ...@@ -31,10 +31,8 @@ static int modes_cnt;
static int modes_size; static int modes_size;
static LPDDSURFACEDESC modes; static LPDDSURFACEDESC modes;
static void createdirectdraw(void) static void createwindow(void)
{ {
HRESULT rc;
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = DefWindowProcA; wc.lpfnWndProc = DefWindowProcA;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
...@@ -59,6 +57,12 @@ static void createdirectdraw(void) ...@@ -59,6 +57,12 @@ static void createdirectdraw(void)
UpdateWindow(hwnd); UpdateWindow(hwnd);
SetFocus(hwnd); SetFocus(hwnd);
}
static void createdirectdraw(void)
{
HRESULT rc;
rc = DirectDrawCreate(NULL, &lpDD, NULL); rc = DirectDrawCreate(NULL, &lpDD, NULL);
ok(rc==DD_OK,"DirectDrawCreate returned: %lx\n",rc); ok(rc==DD_OK,"DirectDrawCreate returned: %lx\n",rc);
} }
...@@ -210,11 +214,122 @@ static void testdisplaymodes(void) ...@@ -210,11 +214,122 @@ static void testdisplaymodes(void)
} }
} }
static void testcooperativelevels_normal(void)
{
HRESULT rc;
/* Do some tests with DDSCL_NORMAL mode */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_NORMAL);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %lx\n",rc);
/* Set the focus window */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_SETFOCUSWINDOW);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
/* Set the focus window a secound time*/
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_SETFOCUSWINDOW);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the secound time returned: %lx\n",rc);
/* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
/* This one succeeds */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
/* Set the device window without any other flags. Should give an error */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_SETDEVICEWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %lx\n",rc);
/* Set device window with DDSCL_NORMAL */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %lx\n",rc);
/* Also set the focus window. Should give an error */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
/* All done */
}
static void testcooperativelevels_exclusive(void)
{
HRESULT rc;
/* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */
/* Try to set exclusive mode only */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_EXCLUSIVE);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %lx\n",rc);
/* Full screen mode only */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_FULLSCREEN);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %lx\n",rc);
/* Full screen mode + exclusive mode */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %lx\n",rc);
/* Set the focus window. Should fail */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_HWNDALREADYSET,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
/* All done */
}
START_TEST(ddrawmodes) START_TEST(ddrawmodes)
{ {
createwindow();
createdirectdraw(); createdirectdraw();
enumdisplaymodes(); enumdisplaymodes();
testdisplaymodes(); testdisplaymodes();
flushdisplaymodes(); flushdisplaymodes();
releasedirectdraw(); releasedirectdraw();
createdirectdraw();
testcooperativelevels_normal();
releasedirectdraw();
createdirectdraw();
testcooperativelevels_exclusive();
releasedirectdraw();
} }
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