mirror of
https://github.com/reactos/reactos.git
synced 2025-06-13 13:28:30 +00:00
adpabte wine SetCooperativeLevel to reactis ddraw. allot test need be done, I also took DDRAWI_DIRECTDRAW_LCL->dwObsolete1 as device windows.
memory leak can exists and some value I forget free as well. svn path=/trunk/; revision=26467
This commit is contained in:
parent
84234a9add
commit
2189a28c87
3 changed files with 293 additions and 108 deletions
|
@ -38,7 +38,7 @@ Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,
|
|||
}
|
||||
|
||||
Main_DirectDraw_AddRef(iface);
|
||||
return S_OK;
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -315,15 +315,170 @@ Main_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface)
|
|||
}
|
||||
|
||||
/*
|
||||
* IMPLEMENT
|
||||
* Status ok
|
||||
*/
|
||||
HRESULT WINAPI
|
||||
Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD cooplevel)
|
||||
{
|
||||
DX_WINDBG_trace();
|
||||
|
||||
DX_STUB;
|
||||
/*
|
||||
* Code from wine, this functions have been cut and paste from wine 0.9.35
|
||||
* and have been modify allot and are still in devloping so it match with
|
||||
* msdn document struct and flags
|
||||
*/
|
||||
|
||||
HWND window;
|
||||
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
||||
|
||||
|
||||
/* Get the old window */
|
||||
window = (HWND) This->lpLcl->hWnd;
|
||||
if(!window)
|
||||
{
|
||||
return DDERR_NOHWND;
|
||||
}
|
||||
|
||||
/* Tests suggest that we need one of them: */
|
||||
if(!(cooplevel & (DDSCL_SETFOCUSWINDOW |
|
||||
DDSCL_NORMAL |
|
||||
DDSCL_EXCLUSIVE )))
|
||||
{
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
/* Handle those levels first which set various hwnds */
|
||||
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 ) )
|
||||
{
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
else if(This->lpLcl->dwLocalFlags & DDRAWILCL_SETCOOPCALLED)
|
||||
{
|
||||
return DDERR_HWNDALREADYSET;
|
||||
}
|
||||
else if( (This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN) && window)
|
||||
{
|
||||
return DDERR_HWNDALREADYSET;
|
||||
}
|
||||
|
||||
This->lpLcl->hFocusWnd = (ULONG_PTR) hwnd;
|
||||
|
||||
|
||||
/* Won't use the hwnd param for anything else */
|
||||
hwnd = NULL;
|
||||
|
||||
/* Use the focus window for drawing too */
|
||||
This->lpLcl->hWnd = This->lpLcl->hFocusWnd;
|
||||
|
||||
}
|
||||
|
||||
/* DDSCL_NORMAL or DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE */
|
||||
if(cooplevel & DDSCL_NORMAL)
|
||||
{
|
||||
/* Can't coexist with fullscreen or exclusive */
|
||||
if(cooplevel & (DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) )
|
||||
return DDERR_INVALIDPARAMS;
|
||||
|
||||
|
||||
/* Switching from fullscreen? */
|
||||
if(This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN)
|
||||
{
|
||||
/* Restore the display mode */
|
||||
Main_DirectDraw_RestoreDisplayMode(iface);
|
||||
|
||||
This->lpLcl->dwLocalFlags &= ~DDRAWILCL_ISFULLSCREEN;
|
||||
This->lpLcl->dwLocalFlags &= ~DDRAWILCL_HASEXCLUSIVEMODE;
|
||||
This->lpLcl->dwLocalFlags &= ~DDRAWILCL_ALLOWMODEX;
|
||||
}
|
||||
|
||||
/* Don't override focus windows or private device windows */
|
||||
if( hwnd &&
|
||||
!(This->lpLcl->hFocusWnd) &&
|
||||
!(This->lpLcl->dwObsolete1) &&
|
||||
(hwnd != window) )
|
||||
{
|
||||
This->lpLcl->hWnd = (ULONG_PTR)hwnd;
|
||||
}
|
||||
|
||||
/* FIXME GL
|
||||
IWineD3DDevice_SetFullscreen(This->wineD3DDevice,
|
||||
FALSE);
|
||||
*/
|
||||
}
|
||||
else if(cooplevel & DDSCL_FULLSCREEN)
|
||||
{
|
||||
/* Needs DDSCL_EXCLUSIVE */
|
||||
if(!(cooplevel & DDSCL_EXCLUSIVE) )
|
||||
return DDERR_INVALIDPARAMS;
|
||||
|
||||
/* Switch from normal to full screen mode? */
|
||||
if (!(This->lpLcl->dwLocalFlags & DDRAWILCL_HASEXCLUSIVEMODE))
|
||||
{
|
||||
/* FIXME GL
|
||||
IWineD3DDevice_SetFullscreen(This->wineD3DDevice,
|
||||
TRUE);
|
||||
*/
|
||||
}
|
||||
|
||||
/* Don't override focus windows or private device windows */
|
||||
if( hwnd &&
|
||||
!(This->lpLcl->hFocusWnd) &&
|
||||
!(This->lpLcl->dwObsolete1) &&
|
||||
(hwnd != window) )
|
||||
{
|
||||
This->lpLcl->hWnd = (ULONG_PTR) hwnd;
|
||||
}
|
||||
}
|
||||
else if(cooplevel & DDSCL_EXCLUSIVE)
|
||||
{
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
if(cooplevel & DDSCL_CREATEDEVICEWINDOW)
|
||||
{
|
||||
/* Don't create a device window if a focus window is set */
|
||||
if( !This->lpLcl->hFocusWnd)
|
||||
{
|
||||
HWND devicewindow = CreateWindowExW(0, classname, L"DDraw device window",
|
||||
WS_POPUP, 0, 0,
|
||||
GetSystemMetrics(SM_CXSCREEN),
|
||||
GetSystemMetrics(SM_CYSCREEN),
|
||||
NULL, NULL, GetModuleHandleW(0), NULL);
|
||||
|
||||
ShowWindow(devicewindow, SW_SHOW); /* Just to be sure */
|
||||
|
||||
This->lpLcl->dwObsolete1 = (DWORD)devicewindow;
|
||||
}
|
||||
}
|
||||
|
||||
if(cooplevel & DDSCL_MULTITHREADED && !(This->lpLcl->dwLocalFlags & DDRAWILCL_MULTITHREADED))
|
||||
{
|
||||
/* FIXME GL
|
||||
* IWineD3DDevice_SetMultithreaded(This->wineD3DDevice);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Store the cooperative_level */
|
||||
|
||||
/* FIXME GL
|
||||
* This->cooperative_level |= cooplevel;
|
||||
*/
|
||||
|
||||
return DD_OK;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
/* DirectDraw startup code only internal use */
|
||||
extern DDRAWI_DIRECTDRAW_GBL ddgbl;
|
||||
extern DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
|
||||
extern WCHAR classname[128];
|
||||
extern WNDCLASSW wnd_class;
|
||||
|
||||
|
||||
HRESULT WINAPI StartDirectDraw(LPDIRECTDRAW* iface, LPGUID pGUID, BOOL reenable);
|
||||
|
|
|
@ -13,10 +13,12 @@
|
|||
#include "d3dhal.h"
|
||||
#include "ddrawgdi.h"
|
||||
|
||||
#include "ddrawi.h"
|
||||
DDRAWI_DIRECTDRAW_GBL ddgbl;
|
||||
DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
|
||||
|
||||
WCHAR classname[128];
|
||||
WNDCLASSW wnd_class;
|
||||
|
||||
|
||||
|
||||
HRESULT
|
||||
|
@ -74,8 +76,26 @@ Create_DirectDraw (LPGUID pGUID,
|
|||
if (Main_DirectDraw_QueryInterface((LPDIRECTDRAW7)This, id, (void**)&pIface))
|
||||
{
|
||||
if (StartDirectDraw((LPDIRECTDRAW*)This, pGUID, FALSE) == DD_OK);
|
||||
{
|
||||
RtlZeroMemory(&wnd_class, sizeof(wnd_class));
|
||||
wnd_class.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wnd_class.lpfnWndProc = DefWindowProcW;
|
||||
wnd_class.cbClsExtra = 0;
|
||||
wnd_class.cbWndExtra = 0;
|
||||
wnd_class.hInstance = GetModuleHandleW(0);
|
||||
wnd_class.hIcon = 0;
|
||||
wnd_class.hCursor = 0;
|
||||
wnd_class.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
|
||||
wnd_class.lpszMenuName = NULL;
|
||||
wnd_class.lpszClassName = classname;
|
||||
if(!RegisterClassW(&wnd_class))
|
||||
{
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
@ -92,6 +112,7 @@ StartDirectDraw(LPDIRECTDRAW* iface, LPGUID lpGuid, BOOL reenable)
|
|||
|
||||
DX_WINDBG_trace();
|
||||
|
||||
|
||||
/*
|
||||
* ddgbl.dwPDevice is not longer in use in windows 2000 and higher
|
||||
* I am using it for device type
|
||||
|
@ -127,7 +148,8 @@ StartDirectDraw(LPDIRECTDRAW* iface, LPGUID lpGuid, BOOL reenable)
|
|||
devicetypes= 1;
|
||||
|
||||
/* Create HDC for default, hal and hel driver */
|
||||
This->lpLcl->hDC = (ULONG_PTR) GetDC(GetActiveWindow());
|
||||
This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
|
||||
This->lpLcl->hDC = (ULONG_PTR) GetDC((HWND)This->lpLcl->hWnd);
|
||||
|
||||
/* cObsolete is undoc in msdn it being use in CreateDCA */
|
||||
RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
|
||||
|
@ -138,7 +160,8 @@ StartDirectDraw(LPDIRECTDRAW* iface, LPGUID lpGuid, BOOL reenable)
|
|||
{
|
||||
devicetypes = 2;
|
||||
/* Create HDC for default, hal driver */
|
||||
This->lpLcl->hDC = (ULONG_PTR) GetDC(GetActiveWindow());
|
||||
This->lpLcl->hWnd =(ULONG_PTR) GetActiveWindow();
|
||||
This->lpLcl->hDC = (ULONG_PTR) GetDC((HWND)This->lpLcl->hWnd);
|
||||
|
||||
/* cObsolete is undoc in msdn it being use in CreateDCA */
|
||||
RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
|
||||
|
@ -150,7 +173,8 @@ StartDirectDraw(LPDIRECTDRAW* iface, LPGUID lpGuid, BOOL reenable)
|
|||
devicetypes = 3;
|
||||
|
||||
/* Create HDC for default, hal and hel driver */
|
||||
This->lpLcl->hDC = (ULONG_PTR) GetDC(GetActiveWindow());
|
||||
This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
|
||||
This->lpLcl->hDC = (ULONG_PTR) GetDC((HWND)This->lpLcl->hWnd);
|
||||
|
||||
/* cObsolete is undoc in msdn it being use in CreateDCA */
|
||||
RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
|
||||
|
@ -165,6 +189,7 @@ StartDirectDraw(LPDIRECTDRAW* iface, LPGUID lpGuid, BOOL reenable)
|
|||
*/
|
||||
devicetypes = 4;
|
||||
This->lpLcl->hDC = (ULONG_PTR) NULL ;
|
||||
This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
|
||||
}
|
||||
|
||||
if ( (HDC)This->lpLcl->hDC == NULL)
|
||||
|
@ -223,6 +248,7 @@ StartDirectDraw(LPDIRECTDRAW* iface, LPGUID lpGuid, BOOL reenable)
|
|||
This->lpLcl->hDD = This->lpLcl->lpGbl->hDD;
|
||||
ddgbl.hDD = This->lpLcl->lpGbl->hDD;
|
||||
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
|
@ -318,12 +344,12 @@ StartDirectDrawHal(LPDIRECTDRAW* iface, BOOL reenable)
|
|||
DDHAL_DDEXEBUFCALLBACKS mD3dBufferCallbacks;
|
||||
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
||||
|
||||
|
||||
RtlZeroMemory(&mHALInfo, sizeof(DDHALINFO));
|
||||
RtlZeroMemory(&mD3dCallbacks, sizeof(D3DHAL_CALLBACKS));
|
||||
RtlZeroMemory(&mD3dDriverData, sizeof(D3DHAL_GLOBALDRIVERDATA));
|
||||
RtlZeroMemory(&mD3dBufferCallbacks, sizeof(DDHAL_DDEXEBUFCALLBACKS));
|
||||
|
||||
|
||||
if (reenable == FALSE)
|
||||
{
|
||||
ddgbl.lpDDCBtmp = DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS));
|
||||
|
@ -346,6 +372,8 @@ StartDirectDrawHal(LPDIRECTDRAW* iface, BOOL reenable)
|
|||
return DD_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Some card disable the dx after it have been created so
|
||||
* we are force reanble it
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue