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