VirtualBox

Changeset 3110 in vbox for trunk/src


Ignore:
Timestamp:
Jun 14, 2007 4:18:18 PM (18 years ago)
Author:
vboxsync
Message:

Added the display index parameter to the SetVideoModeHint (in the guest all hints are still processed only for the primary monitor).

Location:
trunk/src/VBox
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxService/VBoxService.cpp

    r3109 r3110  
    420420}
    421421
    422 static bool isVBoxDisplayDriverActive (void)
     422static bool isVBoxDisplayDriverActive (TCHAR *paszDeviceName)
    423423{
    424424    bool result = false;
     
    452452            {
    453453                DDCLOG(("VBox display driver is active.\n"));
     454                strcpy (paszDeviceName, dispDevice.DeviceName);
    454455                result = true;
    455456            }
     
    463464
    464465        devNum++;
     466    }
     467
     468    return result;
     469}
     470
     471static 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];
    465525    }
    466526
     
    477537    VBoxGuestFilterMaskInfo maskInfo;
    478538    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    }
    479554
    480555    maskInfo.u32OrMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
     
    518593                {
    519594                    /* 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);
    522597                    displayChangeRequest.header.version     = VMMDEV_REQUEST_HEADER_VERSION;
    523                     displayChangeRequest.header.requestType = VMMDevReq_GetDisplayChangeRequest;
     598                    displayChangeRequest.header.requestType = VMMDevReq_GetDisplayChangeRequest2;
    524599                    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)
    527603                    {
    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));
    529616
    530617                        /*
    531618                         * Only try to change video mode if the active display driver is VBox additions.
    532619                         */
    533                         if (isVBoxDisplayDriverActive ())
     620                        TCHAR DeviceName[32];
     621                        if (isVBoxDisplayDriverActive (DeviceName))
    534622                        {
     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
    535632                            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))
    539640                            {
    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);
    541642
    542643                                /* Horizontal resolution must be a multiple of 8, round down. */
     
    584685                                    devMode.dmBitsPerPel = displayChangeRequest.bpp;
    585686
     687                                if (lpszDeviceName) devMode.dmFields |= DM_POSITION;
     688
    586689                                DDCLOG(("VBoxService: setting the new mode %dx%dx%d\n", devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel));
    587690
    588691                                /* set the new mode */
    589692                                LONG status;
    590                                 status = ChangeDisplaySettings(&devMode, CDS_UPDATEREGISTRY);
     693                                status = pChangeDisplaySettingsEx?
     694                                             pChangeDisplaySettingsEx(lpszDeviceName, &devMode, NULL, CDS_UPDATEREGISTRY, NULL):
     695                                             ChangeDisplaySettings(&devMode, CDS_UPDATEREGISTRY);
    591696                                if (status != DISP_CHANGE_SUCCESSFUL)
    592697                                {
  • trunk/src/VBox/Devices/VMMDev/VBoxDev.cpp

    r2981 r3110  
    773773        }
    774774
     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
    775803        /*
    776804         * Query whether the given video mode is supported
     
    13741402
    13751403
    1376 static DECLCALLBACK(int) vmmdevRequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t xres, uint32_t yres, uint32_t bpp)
     1404static DECLCALLBACK(int) vmmdevRequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t xres, uint32_t yres, uint32_t bpp, uint32_t display)
    13771405{
    13781406    VMMDevState *pData = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
     
    13811409    bool fSameResolution = (!xres || (pData->lastReadDisplayChangeRequest.xres == xres)) &&
    13821410                           (!yres || (pData->lastReadDisplayChangeRequest.yres == yres)) &&
    1383                            (!bpp || (pData->lastReadDisplayChangeRequest.bpp == bpp));
     1411                           (!bpp || (pData->lastReadDisplayChangeRequest.bpp == bpp)) &&
     1412                           pData->lastReadDisplayChangeRequest.display == display;
    13841413
    13851414    if (!xres && !yres && !bpp)
     
    13901419
    13911420#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));
    13941423#endif /* DEBUG_sunlover */
    13951424
    13961425    if (!fSameResolution)
    13971426    {
    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));
    14001429
    14011430        /* 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;
    14051435
    14061436        /* IRQ so the guest knows what's going on */
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r2981 r3110  
    108108        uint32_t yres;
    109109        uint32_t bpp;
     110        uint32_t display;
    110111    } displayChangeRequest,
    111112      lastReadDisplayChangeRequest;
  • trunk/src/VBox/Frontends/VBoxBFE/DisplayImpl.cpp

    r2981 r3110  
    824824}
    825825
    826 void VMDisplay::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aColorDepth)
     826void VMDisplay::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aColorDepth, ULONG aDisplay)
    827827{
    828828    PPDMIVMMDEVPORT pVMMDevPort = gVMMDev->getVMMDevPort ();
    829829
    830830    if (pVMMDevPort)
    831         pVMMDevPort->pfnRequestDisplayChange(pVMMDevPort, aWidth, aHeight, aColorDepth);
     831        pVMMDevPort->pfnRequestDisplayChange(pVMMDevPort, aWidth, aHeight, aColorDepth, aDisplay);
    832832}
    833833
  • trunk/src/VBox/Frontends/VBoxBFE/DisplayImpl.h

    r2981 r3110  
    4747
    4848    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);
    5050
    5151    static const PDMDRVREG  DrvReg;
  • trunk/src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp

    r3086 r3110  
    730730                          * gFramebuffer->getHostYres()
    731731                          * (gDisplay->getColorDepth() / 8))
    732         gDisplay->SetVideoModeHint(gFramebuffer->getHostXres(), gFramebuffer->getHostYres(), 0);
     732        gDisplay->SetVideoModeHint(gFramebuffer->getHostXres(), gFramebuffer->getHostYres(), 0, 0);
    733733#endif
    734734
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r3101 r3110  
    395395                 "                            dvdattach none|<uuid>|<filename>|host:<drive> |\n"
    396396                 "                            floppyattach none|<uuid>|<filename>|host:<drive> |\n"
    397                  "                            setvideomodehint <xres> <yres> <bpp> |\n"
     397                 "                            setvideomodehint <xres> <yres> <bpp> [display]|\n"
    398398                 "                            setcredentials <username> <password> <domain>\n"
    399399                 "                                           [-allowlocallogon <yes|no>]\n"
     
    42774277        else if (strcmp(argv[1], "setvideomodehint") == 0)
    42784278        {
    4279             if (argc != 5)
     4279            if (argc != 5 && argc != 6)
    42804280            {
    42814281                errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
     
    42864286            uint32_t yres = atoi(argv[3]);
    42874287            uint32_t bpp  = atoi(argv[4]);
     4288            uint32_t displayIdx = 0;
     4289            if (argc == 6)
     4290                displayIdx = atoi(argv[5]);
    42884291
    42894292            ComPtr<IDisplay> display;
    42904293            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));
    42924295        }
    42934296        else if (strcmp(argv[1], "setcredentials") == 0)
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r3098 r3110  
    22882288                 */
    22892289                /* communicate the resize event to the guest */
    2290                 gDisplay->SetVideoModeHint(uResizeWidth, uResizeHeight, 0);
     2290                gDisplay->SetVideoModeHint(uResizeWidth, uResizeHeight, 0, 0);
    22912291                break;
    22922292
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r3078 r3110  
    30103010        LogFlowFunc (("Will suggest %d,%d\n", sz.width(), sz.height()));
    30113011
    3012         cconsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0);
     3012        cconsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0);
    30133013    }
    30143014}
  • trunk/src/VBox/Main/DisplayImpl.cpp

    r2981 r3110  
    13341334}
    13351335
    1336 STDMETHODIMP Display::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aColorDepth)
     1336STDMETHODIMP Display::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aColorDepth, ULONG aDisplay)
    13371337{
    13381338    AutoLock lock(this);
     
    13581358        bpp = cBits;
    13591359    }
    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"));
    13651373
    13661374    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);
    13681376    return S_OK;
    13691377}
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r3001 r3110  
    62986298    <interface
    62996299        name="IDisplay" extends="$unknown"
    6300         uuid="FD443EC1-0012-4F5B-9282-D72760A66916"
     6300        uuid="0a6a7746-5469-47e4-9a00-8b1ea28891b8"
    63016301        wsmap="suppress"
    63026302    >
     
    63536353                Specifying "0" for either width and height or the color depth
    63546354                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.
    63556358            </desc>
    63566359            <param name="width" type="unsigned long" dir="in"/>
    63576360            <param name="height" type="unsigned long" dir="in"/>
    63586361            <param name="colorDepth" type="unsigned long" dir="in"/>
     6362            <param name="display" type="unsigned long" dir="in"/>
    63596363        </method>
    63606364
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r3001 r3110  
    138138    STDMETHOD(UnlockFramebuffer)();
    139139    STDMETHOD(RegisterExternalFramebuffer)(IFramebuffer *frameBuf);
    140     STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG colorDepth);
     140    STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG colorDepth, ULONG display);
    141141    STDMETHOD(TakeScreenShot)(BYTE *address, ULONG width, ULONG height);
    142142    STDMETHOD(DrawToScreen)(BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette