ReactOS 0.4.16-dev-336-gb667d82
ddraw_setcooperativelevel.c File Reference
#include "rosdraw.h"
Include dependency graph for ddraw_setcooperativelevel.c:

Go to the source code of this file.

Functions

HRESULT WINAPI Main_DirectDraw_SetCooperativeLevel (LPDDRAWI_DIRECTDRAW_INT This, HWND hwnd, DWORD cooplevel)
 

Function Documentation

◆ Main_DirectDraw_SetCooperativeLevel()

HRESULT WINAPI Main_DirectDraw_SetCooperativeLevel ( LPDDRAWI_DIRECTDRAW_INT  This,
HWND  hwnd,
DWORD  cooplevel 
)
  • Handle those levels first which set various hwnds *‍/
  • DDSCL_NORMAL or DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE *‍/

Definition at line 13 of file ddraw_setcooperativelevel.c.

14{
15 HRESULT retVal = DD_OK;
16
17
19
21 {
22
23 if (hwnd && !IsWindow(hwnd))
24 {
25 retVal = DDERR_INVALIDPARAMS;
27 }
28
29 // FIXME test if 0x20 exists as a flag and what thuse it do
33 {
34
35 retVal = DDERR_INVALIDPARAMS;
37 }
38
39 if (!( cooplevel & (DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_SETFOCUSWINDOW)))
40 {
41 retVal = DDERR_INVALIDPARAMS;
43 }
44
45 if ((cooplevel & DDSCL_FPUSETUP) && (cooplevel & DDSCL_FPUPRESERVE))
46 {
47 retVal = DDERR_INVALIDPARAMS;
49 }
50
51 if ((cooplevel & DDSCL_EXCLUSIVE) && (!(cooplevel & DDSCL_FULLSCREEN)))
52 {
53 retVal = DDERR_INVALIDPARAMS;
55 }
56
57 if ((cooplevel & DDSCL_ALLOWMODEX) && (!(cooplevel & DDSCL_FULLSCREEN)))
58 {
59 retVal = DDERR_INVALIDPARAMS;
61 }
62
64 {
65 retVal = DDERR_INVALIDPARAMS;
67 }
68
69 if (!cooplevel)
70 {
71 retVal = DDERR_INVALIDPARAMS;
73 }
74
75
76 /* NORMAL MODE */
77 if(!(cooplevel & (~DDSCL_NORMAL)))
78 {
79 /* FIXME in setup.c set DDRAWI_UMODELOADED | DDRAWI_DISPLAYDRV | DDRAWI_EMULATIONINITIALIZED | DDRAWI_GDIDRV | DDRAWI_ATTACHEDTODESKTOP */
80 /* FIXME in setup.c This->lpLcl->lpGbl->dwFlags = */
81
82 This->lpLcl->dwLocalFlags = DDRAWILCL_SETCOOPCALLED | DDRAWILCL_DIRECTDRAW7 ;
83 This->lpLcl->hWnd = (ULONG_PTR) hwnd;
84 This->lpLcl->hFocusWnd = (ULONG_PTR) hwnd;
85 This->lpLcl->lpGbl->lpExclusiveOwner=NULL;
86
87 retVal = DD_OK;
89 }
90
91 /* FULLSCREEN */
92 if ((!(cooplevel & (~(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN)))) ||
93 (!(cooplevel & (~(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX)))))
94
95 {
96 /* FIXME in setup.c This->lpLcl->lpGbl->dwFlags = */
97
98 if (hwnd == NULL)
99 {
100 retVal = DDERR_INVALIDPARAMS;
102 }
103
105 {
106 retVal = DDERR_INVALIDPARAMS;
108 }
109
110 if( (This->lpLcl->lpGbl->lpExclusiveOwner != NULL) &&
111 (This->lpLcl->lpGbl->lpExclusiveOwner != This->lpLcl) )
112 {
113 retVal = DDERR_INVALIDPARAMS;
115 }
116
117 This->lpLcl->lpGbl->lpExclusiveOwner = This-> lpLcl;
118
122
123 if (cooplevel & DDSCL_ALLOWMODEX)
124 {
125 This->lpLcl->dwLocalFlags = This->lpLcl->dwLocalFlags | DDRAWILCL_ALLOWMODEX;
126 }
127
128 This->lpLcl->hWnd = (ULONG_PTR) hwnd;
129 This->lpLcl->hFocusWnd = (ULONG_PTR) hwnd;
130
131
132 /* FIXME fullscreen are not finuish */
133
134 retVal = DD_OK;
136 }
137
138 /*
139 * Code from wine, this functions have been cut and paste from wine 0.9.35
140 * and have been modify allot and are still in devloping so it match with
141 * msdn document struct and flags
142 */
143
144
145
147 //if(cooplevel & DDSCL_SETFOCUSWINDOW)
148 //{
149 //
150
151 // if(This->lpLcl->dwLocalFlags & DDRAWILCL_SETCOOPCALLED)
152 // {
153 // retVal = DDERR_HWNDALREADYSET;
154 // _SEH2_LEAVE;
155 // }
156 // else if( (This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN) && window)
157 // {
158 // retVal = DDERR_HWNDALREADYSET;
159 // _SEH2_LEAVE;
160 // }
161
162 // This->lpLcl->hFocusWnd = (ULONG_PTR) hwnd;
163
164
165 // /* Won't use the hwnd param for anything else */
166 // hwnd = NULL;
167
168 // /* Use the focus window for drawing too */
169 // This->lpLcl->hWnd = This->lpLcl->hFocusWnd;
170
171 //}
172
174 //if(cooplevel & DDSCL_NORMAL)
175 //{
176 // /* Can't coexist with fullscreen or exclusive */
177 // if(cooplevel & (DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) )
178 // {
179 // retVal = DDERR_INVALIDPARAMS;
180 // _SEH2_LEAVE;
181 // }
182
183 // /* Switching from fullscreen? */
184 // if(This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN)
185 // {
186 // /* Restore the display mode */
187 // Main_DirectDraw_RestoreDisplayMode(iface);
188
189 // This->lpLcl->dwLocalFlags &= ~DDRAWILCL_ISFULLSCREEN;
190 // This->lpLcl->dwLocalFlags &= ~DDRAWILCL_HASEXCLUSIVEMODE;
191 // This->lpLcl->dwLocalFlags &= ~DDRAWILCL_ALLOWMODEX;
192 // }
193
194 // /* Don't override focus windows or private device windows */
195 // if( hwnd &&
196 // !(This->lpLcl->hFocusWnd) &&
197 // !(This->lpLcl->dwObsolete1) &&
198 // (hwnd != window) )
199 // {
200 // This->lpLcl->hWnd = (ULONG_PTR)hwnd;
201 // }
202
203 // /* FIXME GL
204 // IWineD3DDevice_SetFullscreen(This->wineD3DDevice,
205 // FALSE);
206 // */
207 // }
208 // else if(cooplevel & DDSCL_FULLSCREEN)
209 // {
210 // /* Needs DDSCL_EXCLUSIVE */
211 // if(!(cooplevel & DDSCL_EXCLUSIVE) )
212 // {
213 // retVal = DDERR_INVALIDPARAMS;
214 // _SEH2_LEAVE;
215 // }
216
217 // /* Switch from normal to full screen mode? */
218 // if (!(This->lpLcl->dwLocalFlags & DDRAWILCL_HASEXCLUSIVEMODE))
219 // {
220 // /* FIXME GL
221 // IWineD3DDevice_SetFullscreen(This->wineD3DDevice,
222 // TRUE);
223 // */
224 // }
225
226 // /* Don't override focus windows or private device windows */
227 // if( hwnd &&
228 // !(This->lpLcl->hFocusWnd) &&
229 // !(This->lpLcl->dwObsolete1) &&
230 // (hwnd != window) )
231 // {
232 // This->lpLcl->hWnd = (ULONG_PTR) hwnd;
233 // }
234 // }
235 // else if(cooplevel & DDSCL_EXCLUSIVE)
236 // {
237 // retVal = DDERR_INVALIDPARAMS;
238 // _SEH2_LEAVE;
239 // }
240
241 // if(cooplevel & DDSCL_CREATEDEVICEWINDOW)
242 // {
243 // /* Don't create a device window if a focus window is set */
244 // if( !This->lpLcl->hFocusWnd)
245 // {
246 // HWND devicewindow = CreateWindowExW(0, classname, L"DDraw device window",
247 // WS_POPUP, 0, 0,
248 // GetSystemMetrics(SM_CXSCREEN),
249 // GetSystemMetrics(SM_CYSCREEN),
250 // NULL, NULL, GetModuleHandleW(0), NULL);
251
252 // ShowWindow(devicewindow, SW_SHOW); /* Just to be sure */
253
254 // This->lpLcl->dwObsolete1 = (DWORD)devicewindow;
255 // }
256 // }
257
258 // if(cooplevel & DDSCL_MULTITHREADED && !(This->lpLcl->dwLocalFlags & DDRAWILCL_MULTITHREADED))
259 // {
260 // /* FIXME GL
261 // * IWineD3DDevice_SetMultithreaded(This->wineD3DDevice);
262 // */
263 // }
264
265
266
267 // /* Store the cooperative_level */
268
269 // /* FIXME GL
270 // * This->cooperative_level |= cooplevel;
271 // */
272 }
274 {
275 }
276 _SEH2_END;
277
278
279 return retVal;
280}
#define DDRAWILCL_ALLOWMODEX
Definition: ddrawi.h:1200
#define DDRAWILCL_DIRECTDRAW7
Definition: ddrawi.h:1211
#define DDRAWILCL_HOOKEDHWND
Definition: ddrawi.h:1199
#define DDRAWILCL_ISFULLSCREEN
Definition: ddrawi.h:1195
#define DDRAWILCL_ACTIVEYES
Definition: ddrawi.h:1197
#define DDRAWILCL_SETCOOPCALLED
Definition: ddrawi.h:1196
#define DDRAWILCL_CURSORCLIPPED
Definition: ddrawi.h:1206
#define DDRAWILCL_HASEXCLUSIVEMODE
Definition: ddrawi.h:1194
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define WS_CHILD
Definition: pedump.c:617
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define _SEH2_LEAVE
Definition: pseh2_64.h:167
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
#define DDSCL_SETDEVICEWINDOW
Definition: ddraw.h:539
#define DDSCL_SETFOCUSWINDOW
Definition: ddraw.h:538
#define DDSCL_FPUPRESERVE
Definition: ddraw.h:543
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define DDSCL_MULTITHREADED
Definition: ddraw.h:541
#define DDSCL_EXCLUSIVE
Definition: ddraw.h:536
#define DDSCL_ALLOWREBOOT
Definition: ddraw.h:533
#define DD_OK
Definition: ddraw.h:186
#define DDSCL_CREATEDEVICEWINDOW
Definition: ddraw.h:540
#define DDSCL_FPUSETUP
Definition: ddraw.h:542
#define DDSCL_NOWINDOWCHANGES
Definition: ddraw.h:534
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define DDSCL_ALLOWMODEX
Definition: ddraw.h:537
#define DDSCL_FULLSCREEN
Definition: ddraw.h:532
#define GetWindowLongPtr
Definition: treelist.c:73
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define GWL_STYLE
Definition: winuser.h:855

Referenced by ThunkDirectDraw2_SetCooperativeLevel(), ThunkDirectDraw4_SetCooperativeLevel(), and ThunkDirectDraw_SetCooperativeLevel().