| 1 | /* $Id: display.cpp,v 1.13 2003-04-02 12:58:02 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 | devmode->dmDisplayFrequency = 70; //todo: get real refresh rate | 
|---|
| 298 | if(n==0) { | 
|---|
| 299 | devmode->dmBitsPerPel = ScreenBitsPerPel; | 
|---|
| 300 | devmode->dmPelsHeight = ScreenHeight; | 
|---|
| 301 | devmode->dmPelsWidth = ScreenWidth; | 
|---|
| 302 | return TRUE; | 
|---|
| 303 | } | 
|---|
| 304 | if ((n-1)<NRMODES*NRDEPTHS) { | 
|---|
| 305 | devmode->dmBitsPerPel   = depths[(n-1)/NRMODES]; | 
|---|
| 306 | devmode->dmPelsHeight   = modes[(n-1)%NRMODES].h; | 
|---|
| 307 | devmode->dmPelsWidth    = modes[(n-1)%NRMODES].w; | 
|---|
| 308 | return TRUE; | 
|---|
| 309 | } | 
|---|
| 310 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 311 | return FALSE; | 
|---|
| 312 | } | 
|---|
| 313 |  | 
|---|
| 314 | /***************************************************************************** | 
|---|
| 315 | * Name      : BOOL WIN32API EnumDisplaySettingsW | 
|---|
| 316 | * Purpose   : The EnumDisplaySettings function obtains information about one | 
|---|
| 317 | *             of a display device's graphics modes. You can obtain information | 
|---|
| 318 | *             for all of a display device's graphics modes by making a series | 
|---|
| 319 | *             of calls to this function. | 
|---|
| 320 | * Parameters: LPCTSTR   lpszDeviceName specifies the display device | 
|---|
| 321 | *             DWORD     iModeNum       specifies the graphics mode | 
|---|
| 322 | *             LPDEVMODE lpDevMode      points to structure to receive settings | 
|---|
| 323 | * Variables : | 
|---|
| 324 | * Result    : If the function succeeds, the return value is TRUE. | 
|---|
| 325 | *             If the function fails, the return value is FALSE. | 
|---|
| 326 | * Remark    : Wine Port (991031) | 
|---|
| 327 | * Status    : | 
|---|
| 328 | * | 
|---|
| 329 | * Author    : | 
|---|
| 330 | *****************************************************************************/ | 
|---|
| 331 | BOOL WIN32API EnumDisplaySettingsW(LPCWSTR name,DWORD n,LPDEVMODEW devmode) | 
|---|
| 332 | { | 
|---|
| 333 | LPSTR    nameA = NULL; | 
|---|
| 334 | DEVMODEA devmodeA; | 
|---|
| 335 | BOOL     ret; | 
|---|
| 336 |  | 
|---|
| 337 | if(name) { | 
|---|
| 338 | nameA = HEAP_strdupWtoA(GetProcessHeap(),0,name); | 
|---|
| 339 | } | 
|---|
| 340 | ret = EnumDisplaySettingsA(nameA,n,&devmodeA); | 
|---|
| 341 |  | 
|---|
| 342 | if (ret) { | 
|---|
| 343 | devmode->dmBitsPerPel   = devmodeA.dmBitsPerPel; | 
|---|
| 344 | devmode->dmPelsHeight   = devmodeA.dmPelsHeight; | 
|---|
| 345 | devmode->dmPelsWidth    = devmodeA.dmPelsWidth; | 
|---|
| 346 | /* FIXME: convert rest too, if they are ever returned */ | 
|---|
| 347 | } | 
|---|
| 348 | if(name) | 
|---|
| 349 | HeapFree(GetProcessHeap(),0,nameA); | 
|---|
| 350 | return ret; | 
|---|
| 351 | } | 
|---|
| 352 | //****************************************************************************** | 
|---|
| 353 | //****************************************************************************** | 
|---|
| 354 | LONG WIN32API ChangeDisplaySettingsA(LPDEVMODEA  lpDevMode, DWORD dwFlags) | 
|---|
| 355 | { | 
|---|
| 356 | // lpDevMode might be NULL when change to default desktop mode | 
|---|
| 357 | // is being requested, this was the cause of trap | 
|---|
| 358 | if ( !lpDevMode ) | 
|---|
| 359 | { | 
|---|
| 360 | return(DISP_CHANGE_SUCCESSFUL); | 
|---|
| 361 | } | 
|---|
| 362 | if(lpDevMode) { | 
|---|
| 363 | dprintf(("USER32:  ChangeDisplaySettingsA FAKED %X\n", dwFlags)); | 
|---|
| 364 | dprintf(("USER32:  ChangeDisplaySettingsA lpDevMode->dmBitsPerPel %d\n", lpDevMode->dmBitsPerPel)); | 
|---|
| 365 | dprintf(("USER32:  ChangeDisplaySettingsA lpDevMode->dmPelsWidth  %d\n", lpDevMode->dmPelsWidth)); | 
|---|
| 366 | dprintf(("USER32:  ChangeDisplaySettingsA lpDevMode->dmPelsHeight %d\n", lpDevMode->dmPelsHeight)); | 
|---|
| 367 | } | 
|---|
| 368 | return(DISP_CHANGE_SUCCESSFUL); | 
|---|
| 369 | } | 
|---|
| 370 | /***************************************************************************** | 
|---|
| 371 | * Name      : LONG WIN32API ChangeDisplaySettingsW | 
|---|
| 372 | * Purpose   : The ChangeDisplaySettings function changes the display settings | 
|---|
| 373 | *             to the specified graphics mode. | 
|---|
| 374 | * Parameters: LPDEVMODEW lpDevModeW | 
|---|
| 375 | *             DWORD      dwFlags | 
|---|
| 376 | * Variables : | 
|---|
| 377 | * Result    : DISP_CHANGE_SUCCESSFUL The settings change was successful. | 
|---|
| 378 | *             DISP_CHANGE_RESTART    The computer must be restarted in order for the graphics mode to work. | 
|---|
| 379 | *             DISP_CHANGE_BADFLAGS   An invalid set of flags was passed in. | 
|---|
| 380 | *             DISP_CHANGE_FAILED     The display driver failed the specified graphics mode. | 
|---|
| 381 | *             DISP_CHANGE_BADMODE    The graphics mode is not supported. | 
|---|
| 382 | *             DISP_CHANGE_NOTUPDATED Unable to write settings to the registry. | 
|---|
| 383 | * Remark    : | 
|---|
| 384 | * Status    : UNTESTED STUB | 
|---|
| 385 | * | 
|---|
| 386 | * Author    : Patrick Haller [Wed, 1998/06/16 11:55] | 
|---|
| 387 | *****************************************************************************/ | 
|---|
| 388 | LONG WIN32API ChangeDisplaySettingsW(LPDEVMODEW lpDevMode, | 
|---|
| 389 | DWORD      dwFlags) | 
|---|
| 390 | { | 
|---|
| 391 | dprintf(("USER32:ChangeDisplaySettingsW(%08xh,%08x) not implemented.\n", | 
|---|
| 392 | lpDevMode, | 
|---|
| 393 | dwFlags)); | 
|---|
| 394 |  | 
|---|
| 395 | return (ChangeDisplaySettingsA((LPDEVMODEA)lpDevMode, | 
|---|
| 396 | dwFlags)); | 
|---|
| 397 | } | 
|---|
| 398 | //****************************************************************************** | 
|---|
| 399 | //****************************************************************************** | 
|---|
| 400 | LONG WIN32API ChangeDisplaySettingsExA(LPCSTR devname, LPDEVMODEA lpDevMode, | 
|---|
| 401 | HWND hwnd, DWORD dwFlags, LPARAM lparam) | 
|---|
| 402 | { | 
|---|
| 403 | // lpDevMode might be NULL when change to default desktop mode | 
|---|
| 404 | // is being requested, this was the cause of trap | 
|---|
| 405 | if ( !lpDevMode ) | 
|---|
| 406 | { | 
|---|
| 407 | return(DISP_CHANGE_SUCCESSFUL); | 
|---|
| 408 | } | 
|---|
| 409 | if(lpDevMode) { | 
|---|
| 410 | dprintf(("USER32:  ChangeDisplaySettingsExA FAKED %X\n", dwFlags)); | 
|---|
| 411 | dprintf(("USER32:  ChangeDisplaySettingsExA lpDevMode->dmBitsPerPel %d\n", lpDevMode->dmBitsPerPel)); | 
|---|
| 412 | dprintf(("USER32:  ChangeDisplaySettingsExA lpDevMode->dmPelsWidth  %d\n", lpDevMode->dmPelsWidth)); | 
|---|
| 413 | dprintf(("USER32:  ChangeDisplaySettingsExA lpDevMode->dmPelsHeight %d\n", lpDevMode->dmPelsHeight)); | 
|---|
| 414 | } | 
|---|
| 415 | return(DISP_CHANGE_SUCCESSFUL); | 
|---|
| 416 | } | 
|---|
| 417 | //****************************************************************************** | 
|---|
| 418 | //****************************************************************************** | 
|---|
| 419 | LONG WIN32API ChangeDisplaySettingsExW(LPCWSTR devname, LPDEVMODEW lpDevMode, | 
|---|
| 420 | HWND hwnd, DWORD dwFlags, LPARAM lparam) | 
|---|
| 421 | { | 
|---|
| 422 | dprintf(("USER32:ChangeDisplaySettingsExW(%08xh,%08x) NOT implemented.\n", | 
|---|
| 423 | lpDevMode, | 
|---|
| 424 | dwFlags)); | 
|---|
| 425 |  | 
|---|
| 426 | //TODO: Need unicode translation | 
|---|
| 427 | return (ChangeDisplaySettingsExA((LPCSTR)devname, (LPDEVMODEA)lpDevMode, | 
|---|
| 428 | hwnd, dwFlags, lparam)); | 
|---|
| 429 | } | 
|---|
| 430 | //****************************************************************************** | 
|---|
| 431 | //****************************************************************************** | 
|---|
| 432 | BOOL WIN32API GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo) | 
|---|
| 433 | { | 
|---|
| 434 | RECT rcWork; | 
|---|
| 435 |  | 
|---|
| 436 | dprintf(("USER32: GetMonitorInfoA %x %x", hMonitor, lpMonitorInfo)); | 
|---|
| 437 |  | 
|---|
| 438 | if ((hMonitor == xPRIMARY_MONITOR) && | 
|---|
| 439 | lpMonitorInfo && | 
|---|
| 440 | (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) && | 
|---|
| 441 | SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0)) | 
|---|
| 442 | { | 
|---|
| 443 | lpMonitorInfo->rcMonitor.left = 0; | 
|---|
| 444 | lpMonitorInfo->rcMonitor.top  = 0; | 
|---|
| 445 | lpMonitorInfo->rcMonitor.right  = GetSystemMetrics(SM_CXSCREEN); | 
|---|
| 446 | lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN); | 
|---|
| 447 | lpMonitorInfo->rcWork = rcWork; | 
|---|
| 448 | lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY; | 
|---|
| 449 |  | 
|---|
| 450 | if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXA)) | 
|---|
| 451 | lstrcpyA(((MONITORINFOEXA*)lpMonitorInfo)->szDevice, "DISPLAY"); | 
|---|
| 452 |  | 
|---|
| 453 | return TRUE; | 
|---|
| 454 | } | 
|---|
| 455 | dprintf(("returning failure\n")); | 
|---|
| 456 | return FALSE; | 
|---|
| 457 | } | 
|---|
| 458 | //****************************************************************************** | 
|---|
| 459 | //****************************************************************************** | 
|---|
| 460 | BOOL WIN32API GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo) | 
|---|
| 461 | { | 
|---|
| 462 | RECT rcWork; | 
|---|
| 463 |  | 
|---|
| 464 | dprintf(("USER32: GetMonitorInfoW %x %x", hMonitor, lpMonitorInfo)); | 
|---|
| 465 |  | 
|---|
| 466 | if ((hMonitor == xPRIMARY_MONITOR) && | 
|---|
| 467 | lpMonitorInfo && | 
|---|
| 468 | (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) && | 
|---|
| 469 | SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0)) | 
|---|
| 470 | { | 
|---|
| 471 | lpMonitorInfo->rcMonitor.left = 0; | 
|---|
| 472 | lpMonitorInfo->rcMonitor.top  = 0; | 
|---|
| 473 | lpMonitorInfo->rcMonitor.right  = GetSystemMetrics(SM_CXSCREEN); | 
|---|
| 474 | lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN); | 
|---|
| 475 | lpMonitorInfo->rcWork = rcWork; | 
|---|
| 476 | lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY; | 
|---|
| 477 |  | 
|---|
| 478 | if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW)) | 
|---|
| 479 | lstrcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, (LPCWSTR)"D\0I\0S\0P\0L\0A\0Y\0\0"); | 
|---|
| 480 |  | 
|---|
| 481 | return TRUE; | 
|---|
| 482 | } | 
|---|
| 483 | dprintf(("returning failure\n")); | 
|---|
| 484 | return FALSE; | 
|---|
| 485 | } | 
|---|
| 486 | //****************************************************************************** | 
|---|
| 487 | //****************************************************************************** | 
|---|
| 488 | HMONITOR WIN32API MonitorFromWindow(HWND hWnd, DWORD dwFlags) | 
|---|
| 489 | { | 
|---|
| 490 | WINDOWPLACEMENT wp; | 
|---|
| 491 |  | 
|---|
| 492 | dprintf(("USER32: MonitorFromWindow %x %x", hWnd, dwFlags)); | 
|---|
| 493 |  | 
|---|
| 494 | if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) | 
|---|
| 495 | return xPRIMARY_MONITOR; | 
|---|
| 496 |  | 
|---|
| 497 | if (IsIconic(hWnd) ? | 
|---|
| 498 | GetWindowPlacement(hWnd, &wp) : | 
|---|
| 499 | GetWindowRect(hWnd, &wp.rcNormalPosition)) { | 
|---|
| 500 |  | 
|---|
| 501 | return MonitorFromRect(&wp.rcNormalPosition, dwFlags); | 
|---|
| 502 | } | 
|---|
| 503 |  | 
|---|
| 504 | dprintf(("USER32: MonitorFromWindow failed")); | 
|---|
| 505 | return NULL; | 
|---|
| 506 | } | 
|---|
| 507 | //****************************************************************************** | 
|---|
| 508 | //****************************************************************************** | 
|---|
| 509 | HMONITOR WIN32API MonitorFromRect(LPCRECT lprcScreenCoords, DWORD dwFlags) | 
|---|
| 510 | { | 
|---|
| 511 | dprintf(("USER32: MonitorFromRect (%d,%d)(%d,%d) %x", lprcScreenCoords->left, lprcScreenCoords->top, lprcScreenCoords->right, lprcScreenCoords->bottom, dwFlags)); | 
|---|
| 512 |  | 
|---|
| 513 | if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) || | 
|---|
| 514 | ((lprcScreenCoords->right > 0) && | 
|---|
| 515 | (lprcScreenCoords->bottom > 0) && | 
|---|
| 516 | (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) && | 
|---|
| 517 | (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN)))) | 
|---|
| 518 | { | 
|---|
| 519 | return xPRIMARY_MONITOR; | 
|---|
| 520 | } | 
|---|
| 521 | dprintf(("USER32: MonitorFromRect failed")); | 
|---|
| 522 | return NULL; | 
|---|
| 523 | } | 
|---|
| 524 | //****************************************************************************** | 
|---|
| 525 | //****************************************************************************** | 
|---|
| 526 | HMONITOR WIN32API MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags) | 
|---|
| 527 | { | 
|---|
| 528 | dprintf(("USER32: MonitorFromPoint (%d,%d) %x", ptScreenCoords.x, ptScreenCoords.y, dwFlags)); | 
|---|
| 529 |  | 
|---|
| 530 | if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) || | 
|---|
| 531 | ((ptScreenCoords.x >= 0) && | 
|---|
| 532 | (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) && | 
|---|
| 533 | (ptScreenCoords.y >= 0) && | 
|---|
| 534 | (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN)))) | 
|---|
| 535 | { | 
|---|
| 536 | return xPRIMARY_MONITOR; | 
|---|
| 537 | } | 
|---|
| 538 |  | 
|---|
| 539 | dprintf(("USER32: MonitorFromPoint failed")); | 
|---|
| 540 | return NULL; | 
|---|
| 541 | } | 
|---|
| 542 | //****************************************************************************** | 
|---|
| 543 | //****************************************************************************** | 
|---|
| 544 | BOOL WIN32API EnumDisplayMonitors( | 
|---|
| 545 | HDC             hdcOptionalForPainting, | 
|---|
| 546 | LPRECT         lprcEnumMonitorsThatIntersect, | 
|---|
| 547 | MONITORENUMPROC lpfnEnumProc, | 
|---|
| 548 | LPARAM          dwData) | 
|---|
| 549 | { | 
|---|
| 550 | RECT rcLimit; | 
|---|
| 551 |  | 
|---|
| 552 | dprintf(("USER32: EnumDisplayMonitors %x %x %x %x", hdcOptionalForPainting, lprcEnumMonitorsThatIntersect, lpfnEnumProc, dwData)); | 
|---|
| 553 |  | 
|---|
| 554 | if (!lpfnEnumProc) | 
|---|
| 555 | return FALSE; | 
|---|
| 556 |  | 
|---|
| 557 | rcLimit.left   = 0; | 
|---|
| 558 | rcLimit.top    = 0; | 
|---|
| 559 | rcLimit.right  = GetSystemMetrics(SM_CXSCREEN); | 
|---|
| 560 | rcLimit.bottom = GetSystemMetrics(SM_CYSCREEN); | 
|---|
| 561 |  | 
|---|
| 562 | if (hdcOptionalForPainting) | 
|---|
| 563 | { | 
|---|
| 564 | RECT    rcClip; | 
|---|
| 565 | POINT   ptOrg; | 
|---|
| 566 |  | 
|---|
| 567 | switch (GetClipBox(hdcOptionalForPainting, &rcClip)) | 
|---|
| 568 | { | 
|---|
| 569 | default: | 
|---|
| 570 | if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg)) | 
|---|
| 571 | return FALSE; | 
|---|
| 572 |  | 
|---|
| 573 | OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y); | 
|---|
| 574 | if (IntersectRect(&rcLimit, &rcLimit, &rcClip) && | 
|---|
| 575 | (!lprcEnumMonitorsThatIntersect || | 
|---|
| 576 | IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) { | 
|---|
| 577 |  | 
|---|
| 578 | break; | 
|---|
| 579 | } | 
|---|
| 580 | /*fall thru */ | 
|---|
| 581 | case NULLREGION: | 
|---|
| 582 | return TRUE; | 
|---|
| 583 | case ERROR: | 
|---|
| 584 | return FALSE; | 
|---|
| 585 | } | 
|---|
| 586 | } else { | 
|---|
| 587 | if (    lprcEnumMonitorsThatIntersect && | 
|---|
| 588 | !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) { | 
|---|
| 589 |  | 
|---|
| 590 | return TRUE; | 
|---|
| 591 | } | 
|---|
| 592 | } | 
|---|
| 593 |  | 
|---|
| 594 | return lpfnEnumProc( | 
|---|
| 595 | xPRIMARY_MONITOR, | 
|---|
| 596 | hdcOptionalForPainting, | 
|---|
| 597 | &rcLimit, | 
|---|
| 598 | dwData); | 
|---|
| 599 | } | 
|---|
| 600 | /*********************************************************************** | 
|---|
| 601 | *           EnumDisplayDevicesA   (USER32.184) | 
|---|
| 602 | */ | 
|---|
| 603 | BOOL WINAPI EnumDisplayDevicesA( | 
|---|
| 604 | LPVOID unused,DWORD i,LPDISPLAY_DEVICEA lpDisplayDevice,DWORD dwFlags) | 
|---|
| 605 | { | 
|---|
| 606 | dprintf(("EnumDisplayDevicesA: %x %d %x %x", unused, i, lpDisplayDevice, dwFlags)); | 
|---|
| 607 | if (i) | 
|---|
| 608 | return FALSE; | 
|---|
| 609 |  | 
|---|
| 610 | strcpy((char *)lpDisplayDevice->DeviceName,"OS/2-PM"); | 
|---|
| 611 | strcpy((char *)lpDisplayDevice->DeviceString,"OS/2 Presentation Manager Display"); | 
|---|
| 612 | lpDisplayDevice->StateFlags = | 
|---|
| 613 | DISPLAY_DEVICE_ATTACHED_TO_DESKTOP      | | 
|---|
| 614 | DISPLAY_DEVICE_PRIMARY_DEVICE           | | 
|---|
| 615 | DISPLAY_DEVICE_VGA_COMPATIBLE; | 
|---|
| 616 | return TRUE; | 
|---|
| 617 | } | 
|---|
| 618 |  | 
|---|
| 619 | /*********************************************************************** | 
|---|
| 620 | *           EnumDisplayDevicesW   (USER32.185) | 
|---|
| 621 | */ | 
|---|
| 622 | BOOL WINAPI EnumDisplayDevicesW( | 
|---|
| 623 | LPVOID unused,DWORD i,LPDISPLAY_DEVICEW lpDisplayDevice,DWORD dwFlags) | 
|---|
| 624 | { | 
|---|
| 625 | dprintf(("EnumDisplayDevicesW: %x %d %x %x", unused, i, lpDisplayDevice, dwFlags)); | 
|---|
| 626 | if (i) | 
|---|
| 627 | return FALSE; | 
|---|
| 628 |  | 
|---|
| 629 | lstrcpyAtoW(lpDisplayDevice->DeviceName,"OS/2-PM"); | 
|---|
| 630 | lstrcpyAtoW(lpDisplayDevice->DeviceString,"OS/2 Presentation Manager Display"); | 
|---|
| 631 | lpDisplayDevice->StateFlags = | 
|---|
| 632 | DISPLAY_DEVICE_ATTACHED_TO_DESKTOP      | | 
|---|
| 633 | DISPLAY_DEVICE_PRIMARY_DEVICE           | | 
|---|
| 634 | DISPLAY_DEVICE_VGA_COMPATIBLE; | 
|---|
| 635 | return TRUE; | 
|---|
| 636 | } | 
|---|
| 637 | //****************************************************************************** | 
|---|
| 638 | //****************************************************************************** | 
|---|