- Timestamp:
- Jun 14, 2007 4:18:18 PM (18 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxService.cpp
r3109 r3110 420 420 } 421 421 422 static bool isVBoxDisplayDriverActive ( void)422 static bool isVBoxDisplayDriverActive (TCHAR *paszDeviceName) 423 423 { 424 424 bool result = false; … … 452 452 { 453 453 DDCLOG(("VBox display driver is active.\n")); 454 strcpy (paszDeviceName, dispDevice.DeviceName); 454 455 result = true; 455 456 } … … 463 464 464 465 devNum++; 466 } 467 468 return result; 469 } 470 471 static LPCTSTR vboxQueryMonitorName (TCHAR *DeviceName, TCHAR *MonitorName, INT idx) 472 { 473 LPCTSTR result = NULL; 474 475 DISPLAY_DEVICE dispDevice; 476 #ifdef DEBUG_DISPLAY_CHANGE 477 FillMemory(&dispDevice, sizeof(DISPLAY_DEVICE), 0); 478 479 dispDevice.cb = sizeof(DISPLAY_DEVICE); 480 481 INT devNum = 0; 482 483 while (EnumDisplayDevices(DeviceName, 484 devNum, 485 &dispDevice, 486 0)) 487 { 488 DDCLOG(("DevNum:%d\nName:%s\nString:%s\nID:%s\nKey:%s\nFlags=%08X\n\n", 489 devNum, 490 &dispDevice.DeviceName[0], 491 &dispDevice.DeviceString[0], 492 &dispDevice.DeviceID[0], 493 &dispDevice.DeviceKey[0], 494 dispDevice.StateFlags)); 495 496 FillMemory(&dispDevice, sizeof(DISPLAY_DEVICE), 0); 497 498 dispDevice.cb = sizeof(DISPLAY_DEVICE); 499 500 devNum++; 501 } 502 #endif /* DEBUG_DISPLAY_CHANGE */ 503 504 FillMemory(&dispDevice, sizeof(DISPLAY_DEVICE), 0); 505 506 dispDevice.cb = sizeof(DISPLAY_DEVICE); 507 508 DDCLOG(("VBoxService: vboxQueryMonitorName: DeviceName: %s, idx %d (sizeof (TCHAR) %d)\n", DeviceName, idx, sizeof (TCHAR))); 509 510 if (EnumDisplayDevices(DeviceName, 511 idx, 512 &dispDevice, 513 0)) 514 { 515 DDCLOG(("DevNum:%d\nName:%s\nString:%s\nID:%s\nKey:%s\nFlags=%08X\n\n", 516 devNum, 517 &dispDevice.DeviceName[0], 518 &dispDevice.DeviceString[0], 519 &dispDevice.DeviceID[0], 520 &dispDevice.DeviceKey[0], 521 dispDevice.StateFlags)); 522 523 strcpy (MonitorName, dispDevice.DeviceName); 524 result = &MonitorName[0]; 465 525 } 466 526 … … 477 537 VBoxGuestFilterMaskInfo maskInfo; 478 538 DWORD cbReturned; 539 540 typedef LONG WINAPI defChangeDisplaySettingsEx(LPCTSTR lpszDeviceName, LPDEVMODE lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam); 541 typedef BOOL WINAPI defEnumDisplaySettingsEx(LPCTSTR lpszDeviceName, DWORD iModeNum, LPDEVMODE lpDevMode, DWORD dwFlags); 542 543 defChangeDisplaySettingsEx *pChangeDisplaySettingsEx = NULL; 544 defEnumDisplaySettingsEx *pEnumDisplaySettingsEx = NULL; 545 546 HMODULE hUser = GetModuleHandle("USER32"); 547 548 if (hUser) 549 { 550 pChangeDisplaySettingsEx = (defChangeDisplaySettingsEx *)GetProcAddress(hUser, "ChangeDisplaySettingsExA"); 551 pEnumDisplaySettingsEx = (defEnumDisplaySettingsEx *)GetProcAddress(hUser, "EnumDisplaySettingsExA"); 552 DDCLOG(("VBoxService: pChangeDisplaySettingsEx = %p, pEnumDisplaySettingsEx = %p\n", pChangeDisplaySettingsEx, pEnumDisplaySettingsEx)); 553 } 479 554 480 555 maskInfo.u32OrMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST; … … 518 593 { 519 594 /* get the display change request */ 520 VMMDevDisplayChangeRequest displayChangeRequest = {0};521 displayChangeRequest.header.size = sizeof(VMMDevDisplayChangeRequest );595 VMMDevDisplayChangeRequest2 displayChangeRequest = {0}; 596 displayChangeRequest.header.size = sizeof(VMMDevDisplayChangeRequest2); 522 597 displayChangeRequest.header.version = VMMDEV_REQUEST_HEADER_VERSION; 523 displayChangeRequest.header.requestType = VMMDevReq_GetDisplayChangeRequest ;598 displayChangeRequest.header.requestType = VMMDevReq_GetDisplayChangeRequest2; 524 599 displayChangeRequest.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST; 525 if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, &displayChangeRequest, sizeof(displayChangeRequest), 526 &displayChangeRequest, sizeof(displayChangeRequest), &cbReturned, NULL)) 600 BOOL fDisplayChangeQueried = DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, &displayChangeRequest, sizeof(VMMDevDisplayChangeRequest2), 601 &displayChangeRequest, sizeof(VMMDevDisplayChangeRequest2), &cbReturned, NULL); 602 if (!fDisplayChangeQueried) 527 603 { 528 DDCLOG(("VBoxService: VMMDevReq_GetDisplayChangeRequest: %dx%dx%d\n", displayChangeRequest.xres, displayChangeRequest.yres, displayChangeRequest.bpp)); 604 /* Try the old version of the request for old VBox hosts. */ 605 displayChangeRequest.header.size = sizeof(VMMDevDisplayChangeRequest); 606 displayChangeRequest.header.version = VMMDEV_REQUEST_HEADER_VERSION; 607 displayChangeRequest.header.requestType = VMMDevReq_GetDisplayChangeRequest; 608 displayChangeRequest.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST; 609 fDisplayChangeQueried = DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, &displayChangeRequest, sizeof(VMMDevDisplayChangeRequest), 610 &displayChangeRequest, sizeof(VMMDevDisplayChangeRequest), &cbReturned, NULL); 611 displayChangeRequest.display = 0; 612 } 613 if (fDisplayChangeQueried) 614 { 615 DDCLOG(("VBoxService: VMMDevReq_GetDisplayChangeRequest2: %dx%dx%d at %d\n", displayChangeRequest.xres, displayChangeRequest.yres, displayChangeRequest.bpp, displayChangeRequest.display)); 529 616 530 617 /* 531 618 * Only try to change video mode if the active display driver is VBox additions. 532 619 */ 533 if (isVBoxDisplayDriverActive ()) 620 TCHAR DeviceName[32]; 621 if (isVBoxDisplayDriverActive (DeviceName)) 534 622 { 623 TCHAR MonitorName[32]; 624 LPCTSTR lpszDeviceName = NULL; 625 if (displayChangeRequest.display > 0 && pChangeDisplaySettingsEx != NULL) 626 { 627 lpszDeviceName = vboxQueryMonitorName (DeviceName, MonitorName, displayChangeRequest.display); 628 } 629 630 DDCLOG(("VBoxService: lpszDeviceName: %s\n", lpszDeviceName? lpszDeviceName: "(empty)")); 631 535 632 DEVMODE devMode; 536 537 /* get the current screen setup */ 538 if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode)) 633 memset (&devMode, 0, sizeof (devMode)); 634 devMode.dmSize = sizeof(DEVMODE); 635 636 /* get the current screen setup, using Ex to get dmPosition if available. */ 637 if (pEnumDisplaySettingsEx? 638 pEnumDisplaySettingsEx(lpszDeviceName, ENUM_CURRENT_SETTINGS, &devMode, 0): 639 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode)) 539 640 { 540 SvcDebugOut2("VBoxService: Current mode: %dx%dx%d \n", devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel);641 SvcDebugOut2("VBoxService: Current mode: %dx%dx%d at %d,%d\n", devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmPosition.x, devMode.dmPosition.y); 541 642 542 643 /* Horizontal resolution must be a multiple of 8, round down. */ … … 584 685 devMode.dmBitsPerPel = displayChangeRequest.bpp; 585 686 687 if (lpszDeviceName) devMode.dmFields |= DM_POSITION; 688 586 689 DDCLOG(("VBoxService: setting the new mode %dx%dx%d\n", devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel)); 587 690 588 691 /* set the new mode */ 589 692 LONG status; 590 status = ChangeDisplaySettings(&devMode, CDS_UPDATEREGISTRY); 693 status = pChangeDisplaySettingsEx? 694 pChangeDisplaySettingsEx(lpszDeviceName, &devMode, NULL, CDS_UPDATEREGISTRY, NULL): 695 ChangeDisplaySettings(&devMode, CDS_UPDATEREGISTRY); 591 696 if (status != DISP_CHANGE_SUCCESSFUL) 592 697 { -
trunk/src/VBox/Devices/VMMDev/VBoxDev.cpp
r2981 r3110 773 773 } 774 774 775 case VMMDevReq_GetDisplayChangeRequest2: 776 { 777 if (requestHeader->size != sizeof(VMMDevDisplayChangeRequest2)) 778 { 779 requestHeader->rc = VERR_INVALID_PARAMETER; 780 } 781 else 782 { 783 VMMDevDisplayChangeRequest2 *displayChangeRequest = (VMMDevDisplayChangeRequest2*)requestHeader; 784 /* just pass on the information */ 785 Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d at %d\n", 786 pData->displayChangeRequest.xres, pData->displayChangeRequest.yres, pData->displayChangeRequest.bpp, pData->displayChangeRequest.display)); 787 displayChangeRequest->xres = pData->displayChangeRequest.xres; 788 displayChangeRequest->yres = pData->displayChangeRequest.yres; 789 displayChangeRequest->bpp = pData->displayChangeRequest.bpp; 790 displayChangeRequest->display = pData->displayChangeRequest.display; 791 792 if (displayChangeRequest->eventAck == VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST) 793 { 794 /* Remember which resolution the client have queried. */ 795 pData->lastReadDisplayChangeRequest = pData->displayChangeRequest; 796 } 797 798 requestHeader->rc = VINF_SUCCESS; 799 } 800 break; 801 } 802 775 803 /* 776 804 * Query whether the given video mode is supported … … 1374 1402 1375 1403 1376 static DECLCALLBACK(int) vmmdevRequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t xres, uint32_t yres, uint32_t bpp )1404 static DECLCALLBACK(int) vmmdevRequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t xres, uint32_t yres, uint32_t bpp, uint32_t display) 1377 1405 { 1378 1406 VMMDevState *pData = IVMMDEVPORT_2_VMMDEVSTATE(pInterface); … … 1381 1409 bool fSameResolution = (!xres || (pData->lastReadDisplayChangeRequest.xres == xres)) && 1382 1410 (!yres || (pData->lastReadDisplayChangeRequest.yres == yres)) && 1383 (!bpp || (pData->lastReadDisplayChangeRequest.bpp == bpp)); 1411 (!bpp || (pData->lastReadDisplayChangeRequest.bpp == bpp)) && 1412 pData->lastReadDisplayChangeRequest.display == display; 1384 1413 1385 1414 if (!xres && !yres && !bpp) … … 1390 1419 1391 1420 #ifdef DEBUG_sunlover 1392 Log(("vmmdevRequestDisplayChange: same=%d. new: xres=%d, yres=%d, bpp=%d . old: xres=%d, yres=%d, bpp=%d.\n",1393 fSameResolution, xres, yres, bpp, pData->lastReadDisplayChangeRequest.xres, pData->lastReadDisplayChangeRequest.yres, pData->lastReadDisplayChangeRequest.bpp));1421 Log(("vmmdevRequestDisplayChange: same=%d. new: xres=%d, yres=%d, bpp=%d, display=%d. old: xres=%d, yres=%d, bpp=%d, display=%d.\n", 1422 fSameResolution, xres, yres, bpp, display, pData->lastReadDisplayChangeRequest.xres, pData->lastReadDisplayChangeRequest.yres, pData->lastReadDisplayChangeRequest.bpp, pData->lastReadDisplayChangeRequest.display)); 1394 1423 #endif /* DEBUG_sunlover */ 1395 1424 1396 1425 if (!fSameResolution) 1397 1426 { 1398 LogRel(("VMMDev::SetVideoModeHint: got a video mode hint (%dx%dx%d) \n",1399 xres, yres, bpp ));1427 LogRel(("VMMDev::SetVideoModeHint: got a video mode hint (%dx%dx%d) at %d\n", 1428 xres, yres, bpp, display)); 1400 1429 1401 1430 /* we could validate the information here but hey, the guest can do that as well! */ 1402 pData->displayChangeRequest.xres = xres; 1403 pData->displayChangeRequest.yres = yres; 1404 pData->displayChangeRequest.bpp = bpp; 1431 pData->displayChangeRequest.xres = xres; 1432 pData->displayChangeRequest.yres = yres; 1433 pData->displayChangeRequest.bpp = bpp; 1434 pData->displayChangeRequest.display = display; 1405 1435 1406 1436 /* IRQ so the guest knows what's going on */ -
trunk/src/VBox/Devices/VMMDev/VMMDevState.h
r2981 r3110 108 108 uint32_t yres; 109 109 uint32_t bpp; 110 uint32_t display; 110 111 } displayChangeRequest, 111 112 lastReadDisplayChangeRequest; -
trunk/src/VBox/Frontends/VBoxBFE/DisplayImpl.cpp
r2981 r3110 824 824 } 825 825 826 void VMDisplay::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aColorDepth )826 void VMDisplay::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aColorDepth, ULONG aDisplay) 827 827 { 828 828 PPDMIVMMDEVPORT pVMMDevPort = gVMMDev->getVMMDevPort (); 829 829 830 830 if (pVMMDevPort) 831 pVMMDevPort->pfnRequestDisplayChange(pVMMDevPort, aWidth, aHeight, aColorDepth );831 pVMMDevPort->pfnRequestDisplayChange(pVMMDevPort, aWidth, aHeight, aColorDepth, aDisplay); 832 832 } 833 833 -
trunk/src/VBox/Frontends/VBoxBFE/DisplayImpl.h
r2981 r3110 47 47 48 48 void updatePointerShape(bool fVisible, bool fAlpha, uint32_t xHot, uint32_t yHot, uint32_t width, uint32_t height, void *pShape); 49 void SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aColorDepth );49 void SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aColorDepth, ULONG aDisplay); 50 50 51 51 static const PDMDRVREG DrvReg; -
trunk/src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp
r3086 r3110 730 730 * gFramebuffer->getHostYres() 731 731 * (gDisplay->getColorDepth() / 8)) 732 gDisplay->SetVideoModeHint(gFramebuffer->getHostXres(), gFramebuffer->getHostYres(), 0 );732 gDisplay->SetVideoModeHint(gFramebuffer->getHostXres(), gFramebuffer->getHostYres(), 0, 0); 733 733 #endif 734 734 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r3101 r3110 395 395 " dvdattach none|<uuid>|<filename>|host:<drive> |\n" 396 396 " floppyattach none|<uuid>|<filename>|host:<drive> |\n" 397 " setvideomodehint <xres> <yres> <bpp> |\n"397 " setvideomodehint <xres> <yres> <bpp> [display]|\n" 398 398 " setcredentials <username> <password> <domain>\n" 399 399 " [-allowlocallogon <yes|no>]\n" … … 4277 4277 else if (strcmp(argv[1], "setvideomodehint") == 0) 4278 4278 { 4279 if (argc != 5 )4279 if (argc != 5 && argc != 6) 4280 4280 { 4281 4281 errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters"); … … 4286 4286 uint32_t yres = atoi(argv[3]); 4287 4287 uint32_t bpp = atoi(argv[4]); 4288 uint32_t displayIdx = 0; 4289 if (argc == 6) 4290 displayIdx = atoi(argv[5]); 4288 4291 4289 4292 ComPtr<IDisplay> display; 4290 4293 CHECK_ERROR_BREAK(console, COMGETTER(Display)(display.asOutParam())); 4291 CHECK_ERROR_BREAK(display, SetVideoModeHint(xres, yres, bpp ));4294 CHECK_ERROR_BREAK(display, SetVideoModeHint(xres, yres, bpp, displayIdx)); 4292 4295 } 4293 4296 else if (strcmp(argv[1], "setcredentials") == 0) -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r3098 r3110 2288 2288 */ 2289 2289 /* communicate the resize event to the guest */ 2290 gDisplay->SetVideoModeHint(uResizeWidth, uResizeHeight, 0 );2290 gDisplay->SetVideoModeHint(uResizeWidth, uResizeHeight, 0, 0); 2291 2291 break; 2292 2292 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r3078 r3110 3010 3010 LogFlowFunc (("Will suggest %d,%d\n", sz.width(), sz.height())); 3011 3011 3012 cconsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0 );3012 cconsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0); 3013 3013 } 3014 3014 } -
trunk/src/VBox/Main/DisplayImpl.cpp
r2981 r3110 1334 1334 } 1335 1335 1336 STDMETHODIMP Display::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aColorDepth )1336 STDMETHODIMP Display::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aColorDepth, ULONG aDisplay) 1337 1337 { 1338 1338 AutoLock lock(this); … … 1358 1358 bpp = cBits; 1359 1359 } 1360 ULONG vramSize; 1361 mParent->machine()->COMGETTER(VRAMSize)(&vramSize); 1362 /* enough VRAM? */ 1363 if ((width * height * (bpp / 8)) > (vramSize * 1024 * 1024)) 1364 return setError(E_FAIL, tr("Not enough VRAM for the selected video mode")); 1360 ULONG cMonitors; 1361 mParent->machine()->COMGETTER(MonitorCount)(&cMonitors); 1362 if (cMonitors == 0 && aDisplay > 0) 1363 return E_INVALIDARG; 1364 if (aDisplay >= cMonitors) 1365 return E_INVALIDARG; 1366 1367 // sunlover 20070614: It is up to the guest to decide whether the hint is valid. 1368 // ULONG vramSize; 1369 // mParent->machine()->COMGETTER(VRAMSize)(&vramSize); 1370 // /* enough VRAM? */ 1371 // if ((width * height * (bpp / 8)) > (vramSize * 1024 * 1024)) 1372 // return setError(E_FAIL, tr("Not enough VRAM for the selected video mode")); 1365 1373 1366 1374 if (mParent->getVMMDev()) 1367 mParent->getVMMDev()->getVMMDevPort()->pfnRequestDisplayChange(mParent->getVMMDev()->getVMMDevPort(), aWidth, aHeight, aColorDepth );1375 mParent->getVMMDev()->getVMMDevPort()->pfnRequestDisplayChange(mParent->getVMMDev()->getVMMDevPort(), aWidth, aHeight, aColorDepth, aDisplay); 1368 1376 return S_OK; 1369 1377 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r3001 r3110 6298 6298 <interface 6299 6299 name="IDisplay" extends="$unknown" 6300 uuid=" FD443EC1-0012-4F5B-9282-D72760A66916"6300 uuid="0a6a7746-5469-47e4-9a00-8b1ea28891b8" 6301 6301 wsmap="suppress" 6302 6302 > … … 6353 6353 Specifying "0" for either width and height or the color depth 6354 6354 means that the dimensions or color depth should not be changed. 6355 It is possible to specify the number of the guest display 6356 that has to be resized, if guest supports multimonitor configuration. 6357 The display value 0 means primary display, 1 - first secondary. 6355 6358 </desc> 6356 6359 <param name="width" type="unsigned long" dir="in"/> 6357 6360 <param name="height" type="unsigned long" dir="in"/> 6358 6361 <param name="colorDepth" type="unsigned long" dir="in"/> 6362 <param name="display" type="unsigned long" dir="in"/> 6359 6363 </method> 6360 6364 -
trunk/src/VBox/Main/include/DisplayImpl.h
r3001 r3110 138 138 STDMETHOD(UnlockFramebuffer)(); 139 139 STDMETHOD(RegisterExternalFramebuffer)(IFramebuffer *frameBuf); 140 STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG colorDepth );140 STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG colorDepth, ULONG display); 141 141 STDMETHOD(TakeScreenShot)(BYTE *address, ULONG width, ULONG height); 142 142 STDMETHOD(DrawToScreen)(BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
Note:
See TracChangeset
for help on using the changeset viewer.