Changeset 27955 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
- Timestamp:
- Apr 2, 2010 9:12:26 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 59659
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
r27912 r27955 39 39 /* EnumDisplayDevices does not exist in NT. isVBoxDisplayDriverActive et al. are using these functions. */ 40 40 BOOL (WINAPI * pfnEnumDisplayDevices)(IN LPCSTR lpDevice, IN DWORD iDevNum, OUT PDISPLAY_DEVICEA lpDisplayDevice, IN DWORD dwFlags); 41 42 41 } VBOXDISPLAYCONTEXT; 43 42 44 43 static VBOXDISPLAYCONTEXT gCtx = {0}; 44 45 #ifdef VBOXWDDM 46 static bool vboxWddmReinitVideoModes(VBOXDISPLAYCONTEXT *pCtx) 47 { 48 VBOXDISPIFESCAPE escape = {0}; 49 escape.escapeCode = VBOXESC_REINITVIDEOMODES; 50 DWORD err = VBoxDispIfEscape(&pCtx->pEnv->dispIf, &escape, 0); 51 if (err != NO_ERROR) 52 { 53 Log((__FUNCTION__": VBoxDispIfEscape failed with err (%d)\n", err)); 54 return false; 55 } 56 return true; 57 } 58 59 typedef enum 60 { 61 VBOXDISPLAY_DRIVER_TYPE_UNKNOWN = 0, 62 VBOXDISPLAY_DRIVER_TYPE_XPDM = 1, 63 VBOXDISPLAY_DRIVER_TYPE_WDDM = 2 64 } VBOXDISPLAY_DRIVER_TYPE; 65 66 static VBOXDISPLAY_DRIVER_TYPE getVBoxDisplayDriverType (VBOXDISPLAYCONTEXT *pCtx); 67 #endif 45 68 46 69 int VBoxDisplayInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread) … … 66 89 *(uintptr_t *)&gCtx.pfnEnumDisplayDevices = (uintptr_t)GetProcAddress(hUser, "EnumDisplayDevicesA"); 67 90 Log(("VBoxTray: pfnEnumDisplayDevices = %p\n", gCtx.pfnEnumDisplayDevices)); 91 92 #ifdef VBOXWDDM 93 if (OSinfo.dwMajorVersion >= 6) 94 { 95 /* this is vista and up, check if we need to switch the display driver if to WDDM mode */ 96 Log(("VBoxTray: this is vista and up\n")); 97 VBOXDISPLAY_DRIVER_TYPE enmType = getVBoxDisplayDriverType (&gCtx); 98 if (enmType == VBOXDISPLAY_DRIVER_TYPE_WDDM) 99 { 100 Log(("VBoxTray: WDDM driver is installed, switching display driver if to WDDM mode\n")); 101 /* this is hacky, but the most easiest way */ 102 DWORD err = VBoxDispIfSwitchMode(const_cast<PVBOXDISPIF>(&pEnv->dispIf), VBOXDISPIF_MODE_WDDM, NULL /* old mode, we don't care about it */); 103 if (err == NO_ERROR) 104 Log(("VBoxTray: DispIf switched to WDDM mode successfully\n")); 105 else 106 Log(("VBoxTray: failed to switch DispIf to WDDM mode, err (%d)\n", err)); 107 } 108 } 109 #endif 68 110 } 69 111 else if (OSinfo.dwMajorVersion <= 4) /* Windows NT 4.0 */ … … 89 131 } 90 132 133 #ifdef VBOXWDDM 134 static VBOXDISPLAY_DRIVER_TYPE getVBoxDisplayDriverType (VBOXDISPLAYCONTEXT *pCtx) 135 #else 91 136 static bool isVBoxDisplayDriverActive (VBOXDISPLAYCONTEXT *pCtx) 137 #endif 92 138 { 139 #ifdef VBOXWDDM 140 VBOXDISPLAY_DRIVER_TYPE enmType = VBOXDISPLAY_DRIVER_TYPE_UNKNOWN; 141 #else 93 142 bool result = false; 143 #endif 94 144 95 145 if( pCtx->pfnEnumDisplayDevices ) … … 120 170 121 171 if (strcmp(&dispDevice.DeviceString[0], "VirtualBox Graphics Adapter") == 0) 172 #ifndef VBOXWDDM 122 173 result = true; 123 #ifdef VBOXWDDM 124 if (strcmp(&dispDevice.DeviceString[0], "VirtualBox Graphics Adapter (Microsoft Corporation - WDDM)") == 0) 125 result = true; 174 #else 175 enmType = VBOXDISPLAY_DRIVER_TYPE_XPDM; 176 else if (strcmp(&dispDevice.DeviceString[0], "VirtualBox Graphics Adapter (Microsoft Corporation - WDDM)") == 0) 177 enmType = VBOXDISPLAY_DRIVER_TYPE_WDDM; 126 178 #endif 127 179 break; … … 146 198 /* Check for the short name, because all long stuff would be truncated */ 147 199 if (strcmp((char*)&tempDevMode.dmDeviceName[0], "VBoxDisp") == 0) 200 #ifndef VBOXWDDM 148 201 result = true; 149 } 150 202 #else 203 enmType = VBOXDISPLAY_DRIVER_TYPE_XPDM; 204 #endif 205 } 206 207 #ifndef VBOXWDDM 151 208 return result; 209 #else 210 return enmType; 211 #endif 152 212 } 153 213 154 214 /* Returns TRUE to try again. */ 155 static BOOL ResizeDisplayDevice(ULONG Id, DWORD Width, DWORD Height, DWORD BitsPerPixel) 215 static BOOL ResizeDisplayDevice( 216 #ifdef VBOXWDDM 217 VBOXDISPLAYCONTEXT *pCtx, VBOXDISPLAY_DRIVER_TYPE enmType, 218 #endif 219 ULONG Id, DWORD Width, DWORD Height, DWORD BitsPerPixel 220 ) 156 221 { 157 222 BOOL fModeReset = (Width == 0 && Height == 0 && BitsPerPixel == 0); … … 334 399 Log(("ResizeDisplayDevice: EnumDisplaySettings last error %d\n", GetLastError ())); 335 400 } 401 402 #ifdef VBOXWDDM 403 if (enmType == VBOXDISPLAY_DRIVER_TYPE_WDDM) 404 vboxWddmReinitVideoModes(pCtx); 405 #endif 336 406 337 407 /* Assign the new rectangles to displays. */ … … 472 542 * Only try to change video mode if the active display driver is VBox additions. 473 543 */ 544 #ifdef VBOXWDDM 545 VBOXDISPLAY_DRIVER_TYPE enmDriverType = getVBoxDisplayDriverType (pCtx); 546 547 if (enmDriverType == VBOXDISPLAY_DRIVER_TYPE_WDDM) 548 Log(("VBoxDisplayThread : Detected WDDM Driver\n")); 549 550 if (enmDriverType != VBOXDISPLAY_DRIVER_TYPE_UNKNOWN) 551 #else 474 552 if (isVBoxDisplayDriverActive (pCtx)) 553 #endif 475 554 { 476 555 Log(("VBoxDisplayThread : Display driver is active!\n")); … … 481 560 482 561 /* W2K or later. */ 483 if (!ResizeDisplayDevice(displayChangeRequest.display, 562 if (!ResizeDisplayDevice( 563 #ifdef VBOXWDDM 564 pCtx, enmDriverType , 565 #endif 566 displayChangeRequest.display, 484 567 displayChangeRequest.xres, 485 568 displayChangeRequest.yres, 486 displayChangeRequest.bpp)) 569 displayChangeRequest.bpp 570 )) 487 571 { 488 572 break;
Note:
See TracChangeset
for help on using the changeset viewer.