Changeset 42108 in vbox
- Timestamp:
- Jul 11, 2012 1:05:29 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
r42098 r42108 478 478 } 479 479 480 static DWORD vboxDispIfAdjustMode(DISPLAY_DEVICE *pDisplayDevice, DEVMODE *pDeviceMode) 481 { 482 DEVMODE CurMode; 483 DEVMODE BestMatchMode; 484 DWORD i = 0; 485 int64_t diffWH = INT64_MAX; 486 int diffBpp = INT32_MAX; 487 for (; ; ++i) 488 { 489 CurMode.dmSize = sizeof (CurMode); 490 CurMode.dmDriverExtra = 0; 491 492 if (!EnumDisplaySettings(pDisplayDevice->DeviceName, i, &CurMode)) 493 break; 494 495 if (CurMode.dmPelsWidth == pDeviceMode->dmPelsWidth 496 && CurMode.dmPelsHeight == pDeviceMode->dmPelsHeight 497 && CurMode.dmBitsPerPel == pDeviceMode->dmBitsPerPel) 498 { 499 Log(("Exact match found")); 500 *pDeviceMode = CurMode; 501 return NO_ERROR; 502 } 503 504 int diffCurrW = RT_ABS((int)(CurMode.dmPelsWidth - pDeviceMode->dmPelsWidth)); 505 int diffCurrH = RT_ABS((int)(CurMode.dmPelsHeight - pDeviceMode->dmPelsHeight)); 506 int diffCurrBpp = RT_ABS((int)(CurMode.dmBitsPerPel - pDeviceMode->dmBitsPerPel) 507 - 1 /* <- to make higher bpp take precedence over lower ones */ 508 ); 509 510 int64_t diffCurrHW = (int64_t)diffCurrW*diffCurrW + (int64_t)diffCurrH*diffCurrH; 511 512 if (i == 0 513 || diffCurrHW < diffWH 514 || (diffCurrHW == diffWH && diffCurrBpp < diffBpp)) 515 { 516 /* first run */ 517 BestMatchMode = CurMode; 518 diffWH = diffCurrHW; 519 diffBpp = diffCurrBpp; 520 continue; 521 } 522 } 523 524 if (i == 0) 525 { 526 Log(("No modes found!")); 527 return NO_ERROR; 528 } 529 530 *pDeviceMode = BestMatchMode; 531 return NO_ERROR; 532 } 533 480 534 DWORD vboxDispIfResizeModesWDDM(PCVBOXDISPIF const pIf, DISPLAY_DEVICE *paDisplayDevices, DEVMODE *paDeviceModes, UINT cDevModes) 481 535 { … … 591 645 paDeviceModes[i].dmPosition.y)); 592 646 593 if (!fAbleToInvalidateVidPn) 594 { 595 /* @todo: the miniport might have been adjusted the display mode stuff, 596 * adjust the paDeviceModes[i] by picking the closest available one */ 597 } 647 /* the miniport might have been adjusted the display mode stuff, 648 * adjust the paDeviceModes[i] by picking the closest available one */ 649 DEVMODE AdjustedMode = paDeviceModes[i]; 650 vboxDispIfAdjustMode(&paDisplayDevices[i], &AdjustedMode); 598 651 599 652 LONG status = pIf->modeData.wddm.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 600 & paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL);653 &AdjustedMode, NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 601 654 Log(("VBoxTray: ResizeDisplayDevice: ChangeDisplaySettingsEx position status %d, err %d\n", status, GetLastError ())); 602 655 }
Note:
See TracChangeset
for help on using the changeset viewer.