1 | /* $Id: display.cpp,v 1.8 2000-10-03 17:29:20 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Display/Monitor Win32 apis
|
---|
4 | *
|
---|
5 | * Based on Wine code (991031)
|
---|
6 | *
|
---|
7 | * Copyright 1993 Robert J. Amstadt
|
---|
8 | * 1996 Alex Korobka
|
---|
9 | * Copyright 1998 Turchanov Sergey
|
---|
10 | *
|
---|
11 | * Copyright 1999 Christoph Bratschi
|
---|
12 | *
|
---|
13 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
14 | *
|
---|
15 | */
|
---|
16 | #include <os2win.h>
|
---|
17 | #include <misc.h>
|
---|
18 | #include <string.h>
|
---|
19 | #include <heapstring.h>
|
---|
20 | #include "pmwindow.h"
|
---|
21 | #include "monitor.h"
|
---|
22 | #include "windef.h"
|
---|
23 |
|
---|
24 | #define DBG_LOCALLOG DBG_display
|
---|
25 | #include "dbglocal.h"
|
---|
26 |
|
---|
27 | #define NRMODES 5
|
---|
28 | #define NRDEPTHS 4
|
---|
29 | struct {
|
---|
30 | int w,h;
|
---|
31 | } modes[NRMODES]={{512,384},{640,400},{640,480},{800,600},{1024,768}};
|
---|
32 | int depths[4] = {8,16,24,32};
|
---|
33 |
|
---|
34 |
|
---|
35 | /**********************************************************************/
|
---|
36 |
|
---|
37 | #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
|
---|
38 |
|
---|
39 | MONITOR MONITOR_PrimaryMonitor;
|
---|
40 |
|
---|
41 | /* PM Monitor */
|
---|
42 |
|
---|
43 | /***********************************************************************
|
---|
44 | * PMDRV_MONITOR_Initialize
|
---|
45 | */
|
---|
46 | void PMDRV_MONITOR_Initialize(MONITOR *pMonitor)
|
---|
47 | {
|
---|
48 | dprintf(("MONITOR: PMDRV_Initialize"));
|
---|
49 |
|
---|
50 | pMonitor->pDriverData = NULL;
|
---|
51 | }
|
---|
52 |
|
---|
53 | /***********************************************************************
|
---|
54 | * PMDRV_MONITOR_Finalize
|
---|
55 | */
|
---|
56 | void PMDRV_MONITOR_Finalize(MONITOR *pMonitor)
|
---|
57 | {
|
---|
58 | dprintf(("MONITOR: PMDRV_Finalize"));
|
---|
59 | }
|
---|
60 |
|
---|
61 | /***********************************************************************
|
---|
62 | * PMDRV_MONITOR_IsSingleWindow
|
---|
63 | */
|
---|
64 | BOOL PMDRV_MONITOR_IsSingleWindow(MONITOR *pMonitor)
|
---|
65 | {
|
---|
66 | dprintf(("MONITOR: PMDRV_IsSingleWindow"));
|
---|
67 |
|
---|
68 | return TRUE; //CB: right???
|
---|
69 | }
|
---|
70 |
|
---|
71 | /***********************************************************************
|
---|
72 | * PMDRV_MONITOR_GetWidth
|
---|
73 | *
|
---|
74 | * Return the width of the monitor
|
---|
75 | */
|
---|
76 | int PMDRV_MONITOR_GetWidth(MONITOR *pMonitor)
|
---|
77 | {
|
---|
78 | dprintf(("MONITOR: PMDRV_GetWidth"));
|
---|
79 |
|
---|
80 | return GetSystemMetrics(SM_CXSCREEN);
|
---|
81 | }
|
---|
82 |
|
---|
83 | /***********************************************************************
|
---|
84 | * PMDRV_MONITOR_GetHeight
|
---|
85 | *
|
---|
86 | * Return the height of the monitor
|
---|
87 | */
|
---|
88 | int PMDRV_MONITOR_GetHeight(MONITOR *pMonitor)
|
---|
89 | {
|
---|
90 | dprintf(("MONITOR: PMDRV_GetHeight"));
|
---|
91 |
|
---|
92 | return GetSystemMetrics(SM_CYSCREEN);
|
---|
93 | }
|
---|
94 |
|
---|
95 | /***********************************************************************
|
---|
96 | * PMDRV_MONITOR_GetDepth
|
---|
97 | *
|
---|
98 | * Return the depth of the monitor
|
---|
99 | */
|
---|
100 | int PMDRV_MONITOR_GetDepth(MONITOR *pMonitor)
|
---|
101 | {
|
---|
102 | dprintf(("MONITOR: PMDRV_GetDepth"));
|
---|
103 |
|
---|
104 | return 24; //CB: change, right???
|
---|
105 | }
|
---|
106 |
|
---|
107 | /***********************************************************************
|
---|
108 | * PMDRV_MONITOR_GetScreenSaveActive
|
---|
109 | *
|
---|
110 | * Returns the active status of the screen saver
|
---|
111 | */
|
---|
112 | BOOL PMDRV_MONITOR_GetScreenSaveActive(MONITOR *pMonitor)
|
---|
113 | {
|
---|
114 | dprintf(("MONITOR: PMDRV_GetScreenSaveActive"));
|
---|
115 |
|
---|
116 | return FALSE;
|
---|
117 | }
|
---|
118 |
|
---|
119 | /***********************************************************************
|
---|
120 | * PMDRV_MONITOR_SetScreenSaveActive
|
---|
121 | *
|
---|
122 | * Activate/Deactivate the screen saver
|
---|
123 | */
|
---|
124 | void PMDRV_MONITOR_SetScreenSaveActive(MONITOR *pMonitor, BOOL bActivate)
|
---|
125 | {
|
---|
126 | dprintf(("MONITOR: PMDRV_SetScreenSaveActive"));
|
---|
127 | }
|
---|
128 |
|
---|
129 | /***********************************************************************
|
---|
130 | * PMDRV_MONITOR_GetScreenSaveTimeout
|
---|
131 | *
|
---|
132 | * Return the screen saver timeout
|
---|
133 | */
|
---|
134 | int PMDRV_MONITOR_GetScreenSaveTimeout(MONITOR *pMonitor)
|
---|
135 | {
|
---|
136 | dprintf(("MONITOR: PMDRV_GetScreenSaveTimeout"));
|
---|
137 |
|
---|
138 | return 60*1000; //CB: stub
|
---|
139 | }
|
---|
140 |
|
---|
141 | /***********************************************************************
|
---|
142 | * PMDRV_MONITOR_SetScreenSaveTimeout
|
---|
143 | *
|
---|
144 | * Set the screen saver timeout
|
---|
145 | */
|
---|
146 | void PMDRV_MONITOR_SetScreenSaveTimeout(
|
---|
147 | MONITOR *pMonitor, int nTimeout)
|
---|
148 | {
|
---|
149 | dprintf(("MONITOR: PMDRV_SetScreenSaveTimeout"));
|
---|
150 | }
|
---|
151 |
|
---|
152 | MONITOR_DRIVER PM_MONITOR_Driver =
|
---|
153 | {
|
---|
154 | PMDRV_MONITOR_Initialize,
|
---|
155 | PMDRV_MONITOR_Finalize,
|
---|
156 | PMDRV_MONITOR_IsSingleWindow,
|
---|
157 | PMDRV_MONITOR_GetWidth,
|
---|
158 | PMDRV_MONITOR_GetHeight,
|
---|
159 | PMDRV_MONITOR_GetDepth,
|
---|
160 | PMDRV_MONITOR_GetScreenSaveActive,
|
---|
161 | PMDRV_MONITOR_SetScreenSaveActive,
|
---|
162 | PMDRV_MONITOR_GetScreenSaveTimeout,
|
---|
163 | PMDRV_MONITOR_SetScreenSaveTimeout
|
---|
164 | };
|
---|
165 |
|
---|
166 | MONITOR_DRIVER *MONITOR_Driver = &PM_MONITOR_Driver;
|
---|
167 |
|
---|
168 | /***********************************************************************
|
---|
169 | * MONITOR_GetMonitor
|
---|
170 | */
|
---|
171 | static MONITOR *MONITOR_GetMonitor(HMONITOR hMonitor)
|
---|
172 | {
|
---|
173 | if(hMonitor == xPRIMARY_MONITOR)
|
---|
174 | {
|
---|
175 | return &MONITOR_PrimaryMonitor;
|
---|
176 | }
|
---|
177 | else
|
---|
178 | {
|
---|
179 | return NULL;
|
---|
180 | }
|
---|
181 | }
|
---|
182 |
|
---|
183 | /***********************************************************************
|
---|
184 | * MONITOR_Initialize
|
---|
185 | */
|
---|
186 | void MONITOR_Initialize(MONITOR *pMonitor)
|
---|
187 | {
|
---|
188 | MONITOR_Driver->pInitialize(pMonitor);
|
---|
189 | }
|
---|
190 |
|
---|
191 | /***********************************************************************
|
---|
192 | * MONITOR_Finalize
|
---|
193 | */
|
---|
194 | void MONITOR_Finalize(MONITOR *pMonitor)
|
---|
195 | {
|
---|
196 | MONITOR_Driver->pFinalize(pMonitor);
|
---|
197 | }
|
---|
198 |
|
---|
199 | /***********************************************************************
|
---|
200 | * MONITOR_IsSingleWindow
|
---|
201 | */
|
---|
202 | BOOL MONITOR_IsSingleWindow(MONITOR *pMonitor)
|
---|
203 | {
|
---|
204 | return MONITOR_Driver->pIsSingleWindow(pMonitor);
|
---|
205 | }
|
---|
206 |
|
---|
207 | /***********************************************************************
|
---|
208 | * MONITOR_GetWidth
|
---|
209 | */
|
---|
210 | int MONITOR_GetWidth(MONITOR *pMonitor)
|
---|
211 | {
|
---|
212 | return MONITOR_Driver->pGetWidth(pMonitor);
|
---|
213 | }
|
---|
214 |
|
---|
215 | /***********************************************************************
|
---|
216 | * MONITOR_GetHeight
|
---|
217 | */
|
---|
218 | int MONITOR_GetHeight(MONITOR *pMonitor)
|
---|
219 | {
|
---|
220 | return MONITOR_Driver->pGetHeight(pMonitor);
|
---|
221 | }
|
---|
222 |
|
---|
223 | /***********************************************************************
|
---|
224 | * MONITOR_GetDepth
|
---|
225 | */
|
---|
226 | int MONITOR_GetDepth(MONITOR *pMonitor)
|
---|
227 | {
|
---|
228 | return MONITOR_Driver->pGetDepth(pMonitor);
|
---|
229 | }
|
---|
230 |
|
---|
231 | /***********************************************************************
|
---|
232 | * MONITOR_GetScreenSaveActive
|
---|
233 | */
|
---|
234 | BOOL MONITOR_GetScreenSaveActive(MONITOR *pMonitor)
|
---|
235 | {
|
---|
236 | return MONITOR_Driver->pGetScreenSaveActive(pMonitor);
|
---|
237 | }
|
---|
238 |
|
---|
239 | /***********************************************************************
|
---|
240 | * MONITOR_SetScreenSaveActive
|
---|
241 | */
|
---|
242 | void MONITOR_SetScreenSaveActive(MONITOR *pMonitor, BOOL bActivate)
|
---|
243 | {
|
---|
244 | MONITOR_Driver->pSetScreenSaveActive(pMonitor, bActivate);
|
---|
245 | }
|
---|
246 |
|
---|
247 | /***********************************************************************
|
---|
248 | * MONITOR_GetScreenSaveTimeout
|
---|
249 | */
|
---|
250 | int MONITOR_GetScreenSaveTimeout(MONITOR *pMonitor)
|
---|
251 | {
|
---|
252 | return MONITOR_Driver->pGetScreenSaveTimeout(pMonitor);
|
---|
253 | }
|
---|
254 |
|
---|
255 | /***********************************************************************
|
---|
256 | * MONITOR_SetScreenSaveTimeout
|
---|
257 | */
|
---|
258 | void MONITOR_SetScreenSaveTimeout(MONITOR *pMonitor, int nTimeout)
|
---|
259 | {
|
---|
260 | MONITOR_Driver->pSetScreenSaveTimeout(pMonitor, nTimeout);
|
---|
261 | }
|
---|
262 |
|
---|
263 | /*****************************************************************************
|
---|
264 | * Name : BOOL WIN32API EnumDisplaySettingsA
|
---|
265 | * Purpose : The EnumDisplaySettings function obtains information about one
|
---|
266 | * of a display device's graphics modes. You can obtain information
|
---|
267 | * for all of a display device's graphics modes by making a series
|
---|
268 | * of calls to this function.
|
---|
269 | * Parameters: LPCTSTR lpszDeviceName specifies the display device
|
---|
270 | * DWORD iModeNum specifies the graphics mode
|
---|
271 | * LPDEVMODE lpDevMode points to structure to receive settings
|
---|
272 | * Variables :
|
---|
273 | * Result : If the function succeeds, the return value is TRUE.
|
---|
274 | * If the function fails, the return value is FALSE.
|
---|
275 | * Remark : Wine Port (991031)
|
---|
276 | * Status :
|
---|
277 | *
|
---|
278 | * Author :
|
---|
279 | *****************************************************************************/
|
---|
280 | BOOL WIN32API EnumDisplaySettingsA(
|
---|
281 | LPCSTR name, /* [in] huh? */
|
---|
282 | DWORD n, /* [in] nth entry in display settings list*/
|
---|
283 | LPDEVMODEA devmode) /* [out] devmode for that setting */
|
---|
284 | {
|
---|
285 | dprintf(("USER32: EnumDisplaySettingsA %s %d %x", name, n, devmode));
|
---|
286 | if(devmode == NULL) {
|
---|
287 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
288 | return FALSE;
|
---|
289 | }
|
---|
290 | //SvL: VMWare calls this with -1; valid in NT4, SP6
|
---|
291 | // Other negative numbers too. Don't know what they mean.
|
---|
292 | if(n == 0xFFFFFFFF) {
|
---|
293 | n = 0;
|
---|
294 | }
|
---|
295 | memset(devmode, 0, sizeof(*devmode));
|
---|
296 | devmode->dmSize = sizeof(*devmode);
|
---|
297 | if(n==0) {
|
---|
298 | devmode->dmBitsPerPel = ScreenBitsPerPel;
|
---|
299 | devmode->dmPelsHeight = ScreenHeight;
|
---|
300 | devmode->dmPelsWidth = ScreenWidth;
|
---|
301 | return TRUE;
|
---|
302 | }
|
---|
303 | if ((n-1)<NRMODES*NRDEPTHS) {
|
---|
304 | devmode->dmBitsPerPel = depths[(n-1)/NRMODES];
|
---|
305 | devmode->dmPelsHeight = modes[(n-1)%NRMODES].h;
|
---|
306 | devmode->dmPelsWidth = modes[(n-1)%NRMODES].w;
|
---|
307 | return TRUE;
|
---|
308 | }
|
---|
309 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
310 | return FALSE;
|
---|
311 | }
|
---|
312 |
|
---|
313 | /*****************************************************************************
|
---|
314 | * Name : BOOL WIN32API EnumDisplaySettingsW
|
---|
315 | * Purpose : The EnumDisplaySettings function obtains information about one
|
---|
316 | * of a display device's graphics modes. You can obtain information
|
---|
317 | * for all of a display device's graphics modes by making a series
|
---|
318 | * of calls to this function.
|
---|
319 | * Parameters: LPCTSTR lpszDeviceName specifies the display device
|
---|
320 | * DWORD iModeNum specifies the graphics mode
|
---|
321 | * LPDEVMODE lpDevMode points to structure to receive settings
|
---|
322 | * Variables :
|
---|
323 | * Result : If the function succeeds, the return value is TRUE.
|
---|
324 | * If the function fails, the return value is FALSE.
|
---|
325 | * Remark : Wine Port (991031)
|
---|
326 | * Status :
|
---|
327 | *
|
---|
328 | * Author :
|
---|
329 | *****************************************************************************/
|
---|
330 | BOOL WIN32API EnumDisplaySettingsW(LPCWSTR name,DWORD n,LPDEVMODEW devmode)
|
---|
331 | {
|
---|
332 | LPSTR nameA = NULL;
|
---|
333 | DEVMODEA devmodeA;
|
---|
334 | BOOL ret;
|
---|
335 |
|
---|
336 | if(name) {
|
---|
337 | nameA = HEAP_strdupWtoA(GetProcessHeap(),0,name);
|
---|
338 | }
|
---|
339 | ret = EnumDisplaySettingsA(nameA,n,&devmodeA);
|
---|
340 |
|
---|
341 | if (ret) {
|
---|
342 | devmode->dmBitsPerPel = devmodeA.dmBitsPerPel;
|
---|
343 | devmode->dmPelsHeight = devmodeA.dmPelsHeight;
|
---|
344 | devmode->dmPelsWidth = devmodeA.dmPelsWidth;
|
---|
345 | /* FIXME: convert rest too, if they are ever returned */
|
---|
346 | }
|
---|
347 | if(name)
|
---|
348 | HeapFree(GetProcessHeap(),0,nameA);
|
---|
349 | return ret;
|
---|
350 | }
|
---|
351 | //******************************************************************************
|
---|
352 | //******************************************************************************
|
---|
353 | LONG WIN32API ChangeDisplaySettingsA(LPDEVMODEA lpDevMode, DWORD dwFlags)
|
---|
354 | {
|
---|
355 | // lpDevMode might be NULL when change to default desktop mode
|
---|
356 | // is being requested, this was the cause of trap
|
---|
357 | if ( !lpDevMode )
|
---|
358 | {
|
---|
359 | return(DISP_CHANGE_SUCCESSFUL);
|
---|
360 | }
|
---|
361 | if(lpDevMode) {
|
---|
362 | dprintf(("USER32: ChangeDisplaySettingsA FAKED %X\n", dwFlags));
|
---|
363 | dprintf(("USER32: ChangeDisplaySettingsA lpDevMode->dmBitsPerPel %d\n", lpDevMode->dmBitsPerPel));
|
---|
364 | dprintf(("USER32: ChangeDisplaySettingsA lpDevMode->dmPelsWidth %d\n", lpDevMode->dmPelsWidth));
|
---|
365 | dprintf(("USER32: ChangeDisplaySettingsA lpDevMode->dmPelsHeight %d\n", lpDevMode->dmPelsHeight));
|
---|
366 | }
|
---|
367 | return(DISP_CHANGE_SUCCESSFUL);
|
---|
368 | }
|
---|
369 | /*****************************************************************************
|
---|
370 | * Name : LONG WIN32API ChangeDisplaySettingsW
|
---|
371 | * Purpose : The ChangeDisplaySettings function changes the display settings
|
---|
372 | * to the specified graphics mode.
|
---|
373 | * Parameters: LPDEVMODEW lpDevModeW
|
---|
374 | * DWORD dwFlags
|
---|
375 | * Variables :
|
---|
376 | * Result : DISP_CHANGE_SUCCESSFUL The settings change was successful.
|
---|
377 | * DISP_CHANGE_RESTART The computer must be restarted in order for the graphics mode to work.
|
---|
378 | * DISP_CHANGE_BADFLAGS An invalid set of flags was passed in.
|
---|
379 | * DISP_CHANGE_FAILED The display driver failed the specified graphics mode.
|
---|
380 | * DISP_CHANGE_BADMODE The graphics mode is not supported.
|
---|
381 | * DISP_CHANGE_NOTUPDATED Unable to write settings to the registry.
|
---|
382 | * Remark :
|
---|
383 | * Status : UNTESTED STUB
|
---|
384 | *
|
---|
385 | * Author : Patrick Haller [Wed, 1998/06/16 11:55]
|
---|
386 | *****************************************************************************/
|
---|
387 | LONG WIN32API ChangeDisplaySettingsW(LPDEVMODEW lpDevMode,
|
---|
388 | DWORD dwFlags)
|
---|
389 | {
|
---|
390 | dprintf(("USER32:ChangeDisplaySettingsW(%08xh,%08x) not implemented.\n",
|
---|
391 | lpDevMode,
|
---|
392 | dwFlags));
|
---|
393 |
|
---|
394 | return (ChangeDisplaySettingsA((LPDEVMODEA)lpDevMode,
|
---|
395 | dwFlags));
|
---|
396 | }
|
---|
397 | //******************************************************************************
|
---|
398 | //******************************************************************************
|
---|
399 | LONG WIN32API ChangeDisplaySettingsExA(LPCSTR devname, LPDEVMODEA lpDevMode,
|
---|
400 | HWND hwnd, DWORD dwFlags, LPARAM lparam)
|
---|
401 | {
|
---|
402 | // lpDevMode might be NULL when change to default desktop mode
|
---|
403 | // is being requested, this was the cause of trap
|
---|
404 | if ( !lpDevMode )
|
---|
405 | {
|
---|
406 | return(DISP_CHANGE_SUCCESSFUL);
|
---|
407 | }
|
---|
408 | if(lpDevMode) {
|
---|
409 | dprintf(("USER32: ChangeDisplaySettingsExA FAKED %X\n", dwFlags));
|
---|
410 | dprintf(("USER32: ChangeDisplaySettingsExA lpDevMode->dmBitsPerPel %d\n", lpDevMode->dmBitsPerPel));
|
---|
411 | dprintf(("USER32: ChangeDisplaySettingsExA lpDevMode->dmPelsWidth %d\n", lpDevMode->dmPelsWidth));
|
---|
412 | dprintf(("USER32: ChangeDisplaySettingsExA lpDevMode->dmPelsHeight %d\n", lpDevMode->dmPelsHeight));
|
---|
413 | }
|
---|
414 | return(DISP_CHANGE_SUCCESSFUL);
|
---|
415 | }
|
---|
416 | //******************************************************************************
|
---|
417 | //******************************************************************************
|
---|
418 | LONG WIN32API ChangeDisplaySettingsExW(LPCWSTR devname, LPDEVMODEW lpDevMode,
|
---|
419 | HWND hwnd, DWORD dwFlags, LPARAM lparam)
|
---|
420 | {
|
---|
421 | dprintf(("USER32:ChangeDisplaySettingsExW(%08xh,%08x) NOT implemented.\n",
|
---|
422 | lpDevMode,
|
---|
423 | dwFlags));
|
---|
424 |
|
---|
425 | //TODO: Need unicode translation
|
---|
426 | return (ChangeDisplaySettingsExA((LPCSTR)devname, (LPDEVMODEA)lpDevMode,
|
---|
427 | hwnd, dwFlags, lparam));
|
---|
428 | }
|
---|
429 | //******************************************************************************
|
---|
430 | //******************************************************************************
|
---|
431 | BOOL WIN32API GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
|
---|
432 | {
|
---|
433 | RECT rcWork;
|
---|
434 |
|
---|
435 | dprintf(("USER32: GetMonitorInfoA\n"));
|
---|
436 |
|
---|
437 | if ((hMonitor == xPRIMARY_MONITOR) &&
|
---|
438 | lpMonitorInfo &&
|
---|
439 | (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
|
---|
440 | SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0))
|
---|
441 | {
|
---|
442 | lpMonitorInfo->rcMonitor.left = 0;
|
---|
443 | lpMonitorInfo->rcMonitor.top = 0;
|
---|
444 | lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN);
|
---|
445 | lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
|
---|
446 | lpMonitorInfo->rcWork = rcWork;
|
---|
447 | lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
|
---|
448 |
|
---|
449 | if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXA))
|
---|
450 | lstrcpyA(((MONITORINFOEXA*)lpMonitorInfo)->szDevice, "DISPLAY");
|
---|
451 |
|
---|
452 | return TRUE;
|
---|
453 | }
|
---|
454 |
|
---|
455 | return FALSE;
|
---|
456 | }
|
---|
457 | //******************************************************************************
|
---|
458 | //******************************************************************************
|
---|
459 | BOOL WIN32API GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
|
---|
460 | {
|
---|
461 | RECT rcWork;
|
---|
462 |
|
---|
463 | dprintf(("USER32: GetMonitorInfoW\n"));
|
---|
464 |
|
---|
465 | if ((hMonitor == xPRIMARY_MONITOR) &&
|
---|
466 | lpMonitorInfo &&
|
---|
467 | (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
|
---|
468 | SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0))
|
---|
469 | {
|
---|
470 | lpMonitorInfo->rcMonitor.left = 0;
|
---|
471 | lpMonitorInfo->rcMonitor.top = 0;
|
---|
472 | lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN);
|
---|
473 | lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
|
---|
474 | lpMonitorInfo->rcWork = rcWork;
|
---|
475 | lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
|
---|
476 |
|
---|
477 | if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW))
|
---|
478 | lstrcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, (LPCWSTR)"D\0I\0S\0P\0L\0A\0Y\0\0");
|
---|
479 |
|
---|
480 | return TRUE;
|
---|
481 | }
|
---|
482 |
|
---|
483 | return FALSE;
|
---|
484 | }
|
---|
485 | //******************************************************************************
|
---|
486 | //******************************************************************************
|
---|
487 | HMONITOR WIN32API MonitorFromWindow(HWND hWnd, DWORD dwFlags)
|
---|
488 | {
|
---|
489 | WINDOWPLACEMENT wp;
|
---|
490 |
|
---|
491 | dprintf(("USER32: MonitorFromWindow\n"));
|
---|
492 |
|
---|
493 | if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
|
---|
494 | return xPRIMARY_MONITOR;
|
---|
495 |
|
---|
496 | if (IsIconic(hWnd) ?
|
---|
497 | GetWindowPlacement(hWnd, &wp) :
|
---|
498 | GetWindowRect(hWnd, &wp.rcNormalPosition)) {
|
---|
499 |
|
---|
500 | return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
|
---|
501 | }
|
---|
502 |
|
---|
503 | return NULL;
|
---|
504 | }
|
---|
505 | //******************************************************************************
|
---|
506 | //******************************************************************************
|
---|
507 | HMONITOR WIN32API MonitorFromRect(LPRECT lprcScreenCoords, DWORD dwFlags)
|
---|
508 | {
|
---|
509 | dprintf(("USER32: MonitorFromRect\n"));
|
---|
510 |
|
---|
511 | if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
|
---|
512 | ((lprcScreenCoords->right > 0) &&
|
---|
513 | (lprcScreenCoords->bottom > 0) &&
|
---|
514 | (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
|
---|
515 | (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
|
---|
516 | {
|
---|
517 | return xPRIMARY_MONITOR;
|
---|
518 | }
|
---|
519 | return NULL;
|
---|
520 | }
|
---|
521 | //******************************************************************************
|
---|
522 | //******************************************************************************
|
---|
523 | HMONITOR WIN32API MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
|
---|
524 | {
|
---|
525 | dprintf(("USER32: MonitorFromPoint\n"));
|
---|
526 |
|
---|
527 | if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
|
---|
528 | ((ptScreenCoords.x >= 0) &&
|
---|
529 | (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
|
---|
530 | (ptScreenCoords.y >= 0) &&
|
---|
531 | (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
|
---|
532 | {
|
---|
533 | return xPRIMARY_MONITOR;
|
---|
534 | }
|
---|
535 |
|
---|
536 | return NULL;
|
---|
537 | }
|
---|
538 | //******************************************************************************
|
---|
539 | //******************************************************************************
|
---|
540 | BOOL WIN32API EnumDisplayMonitors(
|
---|
541 | HDC hdcOptionalForPainting,
|
---|
542 | LPRECT lprcEnumMonitorsThatIntersect,
|
---|
543 | MONITORENUMPROC lpfnEnumProc,
|
---|
544 | LPARAM dwData)
|
---|
545 | {
|
---|
546 | dprintf(("USER32: EnumDisplayMonitors\n"));
|
---|
547 |
|
---|
548 | RECT rcLimit;
|
---|
549 |
|
---|
550 | if (!lpfnEnumProc)
|
---|
551 | return FALSE;
|
---|
552 |
|
---|
553 | rcLimit.left = 0;
|
---|
554 | rcLimit.top = 0;
|
---|
555 | rcLimit.right = GetSystemMetrics(SM_CXSCREEN);
|
---|
556 | rcLimit.bottom = GetSystemMetrics(SM_CYSCREEN);
|
---|
557 |
|
---|
558 | if (hdcOptionalForPainting)
|
---|
559 | {
|
---|
560 | RECT rcClip;
|
---|
561 | POINT ptOrg;
|
---|
562 |
|
---|
563 | switch (GetClipBox(hdcOptionalForPainting, &rcClip))
|
---|
564 | {
|
---|
565 | default:
|
---|
566 | if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
|
---|
567 | return FALSE;
|
---|
568 |
|
---|
569 | OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
|
---|
570 | if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
|
---|
571 | (!lprcEnumMonitorsThatIntersect ||
|
---|
572 | IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
|
---|
573 |
|
---|
574 | break;
|
---|
575 | }
|
---|
576 | /*fall thru */
|
---|
577 | case NULLREGION:
|
---|
578 | return TRUE;
|
---|
579 | case ERROR:
|
---|
580 | return FALSE;
|
---|
581 | }
|
---|
582 | } else {
|
---|
583 | if ( lprcEnumMonitorsThatIntersect &&
|
---|
584 | !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
|
---|
585 |
|
---|
586 | return TRUE;
|
---|
587 | }
|
---|
588 | }
|
---|
589 |
|
---|
590 | return lpfnEnumProc(
|
---|
591 | xPRIMARY_MONITOR,
|
---|
592 | hdcOptionalForPainting,
|
---|
593 | &rcLimit,
|
---|
594 | dwData);
|
---|
595 | }
|
---|
596 | //******************************************************************************
|
---|
597 | //******************************************************************************
|
---|