Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenddraw_setcooperativelevel.c
Go to the documentation of this file.
00001 /* $Id: ddraw_setcooperativelevel.c 40864 2009-05-09 12:27:40Z dchapyshev $ 00002 * 00003 * COPYRIGHT: See COPYING in the top level directory 00004 * PROJECT: ReactOS DirectX 00005 * FILE: ddraw/ddraw/ddraw_main.c 00006 * PURPOSE: IDirectDraw7::SetCooperativeLevel Implementation 00007 * PROGRAMMER: Magnus Olsen 00008 * 00009 */ 00010 00011 #include "rosdraw.h" 00012 00013 HRESULT WINAPI 00014 Main_DirectDraw_SetCooperativeLevel (LPDDRAWI_DIRECTDRAW_INT This, HWND hwnd, DWORD cooplevel) 00015 { 00016 HRESULT retVal = DD_OK; 00017 00018 00019 DX_WINDBG_trace(); 00020 00021 _SEH2_TRY 00022 { 00023 00024 if (hwnd && !IsWindow(hwnd)) 00025 { 00026 retVal = DDERR_INVALIDPARAMS; 00027 _SEH2_LEAVE; 00028 } 00029 00030 // FIXME test if 0x20 exists as a flag and what thuse it do 00031 if ( cooplevel & (~(DDSCL_FPUPRESERVE | DDSCL_FPUSETUP | DDSCL_MULTITHREADED | DDSCL_CREATEDEVICEWINDOW | 00032 DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW | DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | 00033 DDSCL_NORMAL | DDSCL_NOWINDOWCHANGES | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN))) 00034 { 00035 00036 retVal = DDERR_INVALIDPARAMS; 00037 _SEH2_LEAVE; 00038 } 00039 00040 if (!( cooplevel & (DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_SETFOCUSWINDOW))) 00041 { 00042 retVal = DDERR_INVALIDPARAMS; 00043 _SEH2_LEAVE; 00044 } 00045 00046 if ((cooplevel & DDSCL_FPUSETUP) && (cooplevel & DDSCL_FPUPRESERVE)) 00047 { 00048 retVal = DDERR_INVALIDPARAMS; 00049 _SEH2_LEAVE; 00050 } 00051 00052 if ((cooplevel & DDSCL_EXCLUSIVE) && (!(cooplevel & DDSCL_FULLSCREEN))) 00053 { 00054 retVal = DDERR_INVALIDPARAMS; 00055 _SEH2_LEAVE; 00056 } 00057 00058 if ((cooplevel & DDSCL_ALLOWMODEX) && (!(cooplevel & DDSCL_FULLSCREEN))) 00059 { 00060 retVal = DDERR_INVALIDPARAMS; 00061 _SEH2_LEAVE; 00062 } 00063 00064 if ((cooplevel & (DDSCL_CREATEDEVICEWINDOW | DDSCL_SETFOCUSWINDOW))) 00065 { 00066 retVal = DDERR_INVALIDPARAMS; 00067 _SEH2_LEAVE; 00068 } 00069 00070 if (!cooplevel) 00071 { 00072 retVal = DDERR_INVALIDPARAMS; 00073 _SEH2_LEAVE; 00074 } 00075 00076 00077 /* NORMAL MODE */ 00078 if(!(cooplevel & (~DDSCL_NORMAL))) 00079 { 00080 /* FIXME in setup.c set DDRAWI_UMODELOADED | DDRAWI_DISPLAYDRV | DDRAWI_EMULATIONINITIALIZED | DDRAWI_GDIDRV | DDRAWI_ATTACHEDTODESKTOP */ 00081 /* FIXME in setup.c This->lpLcl->lpGbl->dwFlags = */ 00082 00083 This->lpLcl->dwLocalFlags = DDRAWILCL_SETCOOPCALLED | DDRAWILCL_DIRECTDRAW7 ; 00084 This->lpLcl->hWnd = (ULONG_PTR) hwnd; 00085 This->lpLcl->hFocusWnd = (ULONG_PTR) hwnd; 00086 This->lpLcl->lpGbl->lpExclusiveOwner=NULL; 00087 00088 retVal = DD_OK; 00089 _SEH2_LEAVE; 00090 } 00091 00092 /* FULLSCREEN */ 00093 if ((!(cooplevel & (~(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN)))) || 00094 (!(cooplevel & (~(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX))))) 00095 00096 { 00097 /* FIXME in setup.c This->lpLcl->lpGbl->dwFlags = */ 00098 00099 if (hwnd == NULL) 00100 { 00101 retVal = DDERR_INVALIDPARAMS; 00102 _SEH2_LEAVE; 00103 } 00104 00105 if( (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_CHILD) ) 00106 { 00107 retVal = DDERR_INVALIDPARAMS; 00108 _SEH2_LEAVE; 00109 } 00110 00111 if( (This->lpLcl->lpGbl->lpExclusiveOwner != NULL) && 00112 (This->lpLcl->lpGbl->lpExclusiveOwner != This->lpLcl) ) 00113 { 00114 retVal = DDERR_INVALIDPARAMS; 00115 _SEH2_LEAVE; 00116 } 00117 00118 This->lpLcl->lpGbl->lpExclusiveOwner = This-> lpLcl; 00119 00120 This->lpLcl->dwLocalFlags = DDRAWILCL_SETCOOPCALLED | DDRAWILCL_DIRECTDRAW7 | DDRAWILCL_HOOKEDHWND | 00121 DDRAWILCL_HASEXCLUSIVEMODE | DDRAWILCL_ISFULLSCREEN | DDRAWILCL_ACTIVEYES | 00122 DDRAWILCL_CURSORCLIPPED; 00123 00124 if (cooplevel & DDSCL_ALLOWMODEX) 00125 { 00126 This->lpLcl->dwLocalFlags = This->lpLcl->dwLocalFlags | DDRAWILCL_ALLOWMODEX; 00127 } 00128 00129 This->lpLcl->hWnd = (ULONG_PTR) hwnd; 00130 This->lpLcl->hFocusWnd = (ULONG_PTR) hwnd; 00131 00132 00133 /* FIXME fullscreen are not finuish */ 00134 00135 retVal = DD_OK; 00136 _SEH2_LEAVE; 00137 } 00138 00139 /* 00140 * Code from wine, this functions have been cut and paste from wine 0.9.35 00141 * and have been modify allot and are still in devloping so it match with 00142 * msdn document struct and flags 00143 */ 00144 00145 00146 00148 //if(cooplevel & DDSCL_SETFOCUSWINDOW) 00149 //{ 00150 // 00151 00152 // if(This->lpLcl->dwLocalFlags & DDRAWILCL_SETCOOPCALLED) 00153 // { 00154 // retVal = DDERR_HWNDALREADYSET; 00155 // _SEH2_LEAVE; 00156 // } 00157 // else if( (This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN) && window) 00158 // { 00159 // retVal = DDERR_HWNDALREADYSET; 00160 // _SEH2_LEAVE; 00161 // } 00162 00163 // This->lpLcl->hFocusWnd = (ULONG_PTR) hwnd; 00164 00165 00166 // /* Won't use the hwnd param for anything else */ 00167 // hwnd = NULL; 00168 00169 // /* Use the focus window for drawing too */ 00170 // This->lpLcl->hWnd = This->lpLcl->hFocusWnd; 00171 00172 //} 00173 00175 //if(cooplevel & DDSCL_NORMAL) 00176 //{ 00177 // /* Can't coexist with fullscreen or exclusive */ 00178 // if(cooplevel & (DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) ) 00179 // { 00180 // retVal = DDERR_INVALIDPARAMS; 00181 // _SEH2_LEAVE; 00182 // } 00183 00184 // /* Switching from fullscreen? */ 00185 // if(This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN) 00186 // { 00187 // /* Restore the display mode */ 00188 // Main_DirectDraw_RestoreDisplayMode(iface); 00189 00190 // This->lpLcl->dwLocalFlags &= ~DDRAWILCL_ISFULLSCREEN; 00191 // This->lpLcl->dwLocalFlags &= ~DDRAWILCL_HASEXCLUSIVEMODE; 00192 // This->lpLcl->dwLocalFlags &= ~DDRAWILCL_ALLOWMODEX; 00193 // } 00194 00195 // /* Don't override focus windows or private device windows */ 00196 // if( hwnd && 00197 // !(This->lpLcl->hFocusWnd) && 00198 // !(This->lpLcl->dwObsolete1) && 00199 // (hwnd != window) ) 00200 // { 00201 // This->lpLcl->hWnd = (ULONG_PTR)hwnd; 00202 // } 00203 00204 // /* FIXME GL 00205 // IWineD3DDevice_SetFullscreen(This->wineD3DDevice, 00206 // FALSE); 00207 // */ 00208 // } 00209 // else if(cooplevel & DDSCL_FULLSCREEN) 00210 // { 00211 // /* Needs DDSCL_EXCLUSIVE */ 00212 // if(!(cooplevel & DDSCL_EXCLUSIVE) ) 00213 // { 00214 // retVal = DDERR_INVALIDPARAMS; 00215 // _SEH2_LEAVE; 00216 // } 00217 00218 // /* Switch from normal to full screen mode? */ 00219 // if (!(This->lpLcl->dwLocalFlags & DDRAWILCL_HASEXCLUSIVEMODE)) 00220 // { 00221 // /* FIXME GL 00222 // IWineD3DDevice_SetFullscreen(This->wineD3DDevice, 00223 // TRUE); 00224 // */ 00225 // } 00226 00227 // /* Don't override focus windows or private device windows */ 00228 // if( hwnd && 00229 // !(This->lpLcl->hFocusWnd) && 00230 // !(This->lpLcl->dwObsolete1) && 00231 // (hwnd != window) ) 00232 // { 00233 // This->lpLcl->hWnd = (ULONG_PTR) hwnd; 00234 // } 00235 // } 00236 // else if(cooplevel & DDSCL_EXCLUSIVE) 00237 // { 00238 // retVal = DDERR_INVALIDPARAMS; 00239 // _SEH2_LEAVE; 00240 // } 00241 00242 // if(cooplevel & DDSCL_CREATEDEVICEWINDOW) 00243 // { 00244 // /* Don't create a device window if a focus window is set */ 00245 // if( !This->lpLcl->hFocusWnd) 00246 // { 00247 // HWND devicewindow = CreateWindowExW(0, classname, L"DDraw device window", 00248 // WS_POPUP, 0, 0, 00249 // GetSystemMetrics(SM_CXSCREEN), 00250 // GetSystemMetrics(SM_CYSCREEN), 00251 // NULL, NULL, GetModuleHandleW(0), NULL); 00252 00253 // ShowWindow(devicewindow, SW_SHOW); /* Just to be sure */ 00254 00255 // This->lpLcl->dwObsolete1 = (DWORD)devicewindow; 00256 // } 00257 // } 00258 00259 // if(cooplevel & DDSCL_MULTITHREADED && !(This->lpLcl->dwLocalFlags & DDRAWILCL_MULTITHREADED)) 00260 // { 00261 // /* FIXME GL 00262 // * IWineD3DDevice_SetMultithreaded(This->wineD3DDevice); 00263 // */ 00264 // } 00265 00266 00267 00268 // /* Store the cooperative_level */ 00269 00270 // /* FIXME GL 00271 // * This->cooperative_level |= cooplevel; 00272 // */ 00273 } 00274 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 00275 { 00276 } 00277 _SEH2_END; 00278 00279 00280 return retVal; 00281 } Generated on Sun May 27 2012 04:21:24 for ReactOS by
1.7.6.1
|