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