Changeset 44557 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
- Timestamp:
- Feb 6, 2013 6:36:38 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83616
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
r44550 r44557 16 16 17 17 #include "VBoxTray.h" 18 18 #define _WIN32_WINNT 0x0601 19 19 #include <iprt/log.h> 20 20 #include <iprt/err.h> … … 26 26 #include <iprt/asm.h> 27 27 #endif 28 29 /* APIs specific to win7 and above WDDM architecture. Not available for Vista WDDM. 30 * This is the reason they have not been put in the VBOXDISPIF struct in VBoxDispIf.h 31 */ 32 typedef struct _VBOXDISPLAYWDDMAPICONTEXT 33 { 34 LONG (WINAPI * pfnSetDisplayConfig)(UINT numPathArrayElements,DISPLAYCONFIG_PATH_INFO *pathArray,UINT numModeInfoArrayElements, 35 DISPLAYCONFIG_MODE_INFO *modeInfoArray, UINT Flags); 36 LONG (WINAPI * pfnQueryDisplayConfig)(UINT Flags,UINT *pNumPathArrayElements, DISPLAYCONFIG_PATH_INFO *pPathInfoArray, 37 UINT *pNumModeInfoArrayElements, DISPLAYCONFIG_MODE_INFO *pModeInfoArray, 38 DISPLAYCONFIG_TOPOLOGY_ID *pCurrentTopologyId); 39 LONG (WINAPI * pfnGetDisplayConfigBufferSizes)(UINT Flags, UINT *pNumPathArrayElements, UINT *pNumModeInfoArrayElements); 40 } _VBOXDISPLAYWDDMAPICONTEXT; 41 42 static _VBOXDISPLAYWDDMAPICONTEXT gCtx = {0}; 28 43 29 44 /* display driver interface abstraction for XPDM & WDDM … … 95 110 Log((__FUNCTION__": VBoxDisplayInit: pfnEnumDisplayDevices = %p\n", pIf->modeData.wddm.pfnEnumDisplayDevices)); 96 111 bSupported &= !!(pIf->modeData.wddm.pfnEnumDisplayDevices); 112 /* for win 7 and above */ 113 if (OSinfo.dwMinorVersion >= 1) 114 { 115 *(uintptr_t *)&gCtx.pfnSetDisplayConfig = (uintptr_t)GetProcAddress(hUser, "SetDisplayConfig"); 116 Log((__FUNCTION__": VBoxDisplayInit: pfnSetDisplayConfig = %p\n", gCtx.pfnSetDisplayConfig)); 117 bSupported &= !!(gCtx.pfnSetDisplayConfig); 118 119 *(uintptr_t *)&gCtx.pfnQueryDisplayConfig = (uintptr_t)GetProcAddress(hUser, "QueryDisplayConfig"); 120 Log((__FUNCTION__": VBoxDisplayInit: pfnQueryDisplayConfig = %p\n", gCtx.pfnQueryDisplayConfig)); 121 bSupported &= !!(gCtx.pfnQueryDisplayConfig); 122 123 *(uintptr_t *)&gCtx.pfnGetDisplayConfigBufferSizes = (uintptr_t)GetProcAddress(hUser, "GetDisplayConfigBufferSizes"); 124 Log((__FUNCTION__": VBoxDisplayInit: pfnGetDisplayConfigBufferSizes = %p\n", gCtx.pfnGetDisplayConfigBufferSizes)); 125 bSupported &= !!(gCtx.pfnGetDisplayConfigBufferSizes); 126 } 97 127 98 128 /* this is vista and up */ … … 1153 1183 Data.aScreenInfos[0].Mode.Height = pDeviceMode->dmPelsHeight; 1154 1184 Data.aScreenInfos[0].Mode.BitsPerPixel = pDeviceMode->dmBitsPerPel; 1185 if (pDeviceMode->dmPosition.x != 0 || pDeviceMode->dmPosition.y != 0) { 1186 Data.aScreenInfos[0].Mode.PosX = pDeviceMode->dmPosition.x; 1187 Data.aScreenInfos[0].Mode.PosY = pDeviceMode->dmPosition.y; 1188 } 1155 1189 DWORD err = vboxDispIfEscapeWDDM(pIf, &Data.EscapeHdr, sizeof (Data) - sizeof (Data.EscapeHdr), TRUE); 1156 1190 if (err != NO_ERROR) … … 1198 1232 pInfo->Height = paDeviceModes[i].dmPelsHeight; 1199 1233 pInfo->BitsPerPixel = paDeviceModes[i].dmBitsPerPel; 1234 1235 if (i == iChangedMode && (paDeviceModes[i].dmPosition.x != 0 || paDeviceModes[i].dmPosition.y != 0) ) 1236 { 1237 /* change position values only if not equal to 0*/ 1238 LogRel(("VBoxTray: (WDDM) Change Position x=%d*y=%d Display Device ID=%d\n", paDeviceModes[i].dmPosition.x, paDeviceModes[i].dmPosition.y, i)); 1239 pInfo->PosX = paDeviceModes[i].dmPosition.x; 1240 pInfo->PosY = paDeviceModes[i].dmPosition.y; 1241 } 1200 1242 1201 1243 if (!hAdapter) … … 1282 1324 return winEr; 1283 1325 } 1326 1327 DWORD vboxDispIfWddmEnableDisplay(PCVBOXDISPIF const pIf, UINT Id, bool fEnabled) 1328 { 1329 DISPLAYCONFIG_PATH_INFO PathInfoArray[10]; 1330 DISPLAYCONFIG_MODE_INFO ModeInfoArray[10]; 1331 UINT NumPathArrayElements = 0; 1332 UINT NumModeInfoArrayElements = 0; 1333 ULONG dwStatus; 1334 UINT uFlag; 1335 1336 dwStatus = gCtx.pfnGetDisplayConfigBufferSizes(fEnabled ? QDC_ALL_PATHS : QDC_ONLY_ACTIVE_PATHS,&NumPathArrayElements,&NumModeInfoArrayElements); 1337 if (dwStatus != ERROR_SUCCESS) 1338 { 1339 LogFlow(("VBoxTray: (WDDM) Failed GetDisplayConfigBufferSizes \n")); 1340 return dwStatus; 1341 } 1342 dwStatus = gCtx.pfnQueryDisplayConfig(fEnabled ? QDC_ALL_PATHS : QDC_ONLY_ACTIVE_PATHS,&NumPathArrayElements, &PathInfoArray[0],&NumModeInfoArrayElements, &ModeInfoArray[0],NULL); 1343 if (dwStatus != ERROR_SUCCESS) 1344 { 1345 LogFlow(("VBoxTray: (WDDM) Failed QueryDisplayConfig \n")); 1346 return dwStatus; 1347 } 1348 for (unsigned int i=0; i < NumPathArrayElements; ++i) 1349 { 1350 if (PathInfoArray[i].sourceInfo.id == Id) 1351 { 1352 if (fEnabled) 1353 { 1354 LogRel(("VBoxTray: (WDDM) Enable the Display Device i =%d \n", i)); 1355 PathInfoArray[i].flags=DISPLAYCONFIG_PATH_ACTIVE; 1356 break; 1357 } 1358 else 1359 { 1360 LogRel(("VBoxTray: (WDDM) Disable the Display Device ID=%d and Sourceid=%d\n", i, PathInfoArray[i].sourceInfo.id)); 1361 PathInfoArray[i].flags=0; 1362 break; 1363 } 1364 } 1365 } 1366 dwStatus = gCtx.pfnSetDisplayConfig(NumPathArrayElements, &PathInfoArray[0],NumModeInfoArrayElements, &ModeInfoArray[0],(SDC_APPLY | SDC_SAVE_TO_DATABASE| SDC_ALLOW_CHANGES | SDC_USE_SUPPLIED_DISPLAY_CONFIG)); 1367 if (dwStatus != ERROR_SUCCESS) { 1368 LogRel(("VBoxTray:(WDDM) Failed to disable the monitor.")); 1369 return dwStatus; 1370 } 1371 return ERROR_SUCCESS; 1372 } 1373 1284 1374 #endif /* VBOX_WITH_WDDM */ 1285 1375
Note:
See TracChangeset
for help on using the changeset viewer.