VirtualBox

Changeset 73724 in vbox for trunk


Ignore:
Timestamp:
Aug 16, 2018 6:54:12 PM (6 years ago)
Author:
vboxsync
Message:

VMMDev: multimonitor resize for Windows guests, bugref:8444

Location:
trunk/src/VBox/Additions/WINNT/VBoxTray
Files:
2 edited

Legend:

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

    r72618 r73724  
    17051705    VBOXDISPIF_OP Op;
    17061706    DWORD winEr = ERROR_SUCCESS;
    1707     uint32_t id;
     1707    uint32_t i;
    17081708    int iPath;
    17091709
    17101710    vboxDispIfOpBegin(pIf, &Op);
    17111711
    1712     for (id = 0; id < cDispDef; ++id)
    1713     {
    1714         pDispDef = &paDispDef[id];
     1712    for (i = 0; i < cDispDef; ++i)
     1713    {
     1714        pDispDef = &paDispDef[i];
    17151715
    17161716        if (!(pDispDef->fDisplayFlags & VMMDEV_DISPLAY_DISABLED) &&
     
    17231723            Size.cy = pDispDef->cy;
    17241724
    1725             vboxDispIfUpdateModesWDDM(&Op, id, &Size);
     1725            vboxDispIfUpdateModesWDDM(&Op, pDispDef->idDisplay, &Size);
    17261726        }
    17271727    }
     
    17331733    vboxDispIfWddmDcCreate(&DispCfg, QDC_ALL_PATHS);
    17341734
    1735     for (id = 0; id < cDispDef; ++id)
     1735    for (i = 0; i < cDispDef; ++i)
    17361736    {
    17371737        DISPLAYCONFIG_PATH_INFO *pPathInfo;
    17381738
    1739         pDispDef = &paDispDef[id];
    1740         iPath = vboxDispIfWddmDcSearchPath(&DispCfg, id, id);
     1739        pDispDef = &paDispDef[i];
     1740        iPath = vboxDispIfWddmDcSearchPath(&DispCfg, pDispDef->idDisplay, pDispDef->idDisplay);
    17411741
    17421742        if (iPath < 0)
    17431743        {
    1744             WARN(("VBoxTray:(WDDM) Unexpected iPath(%d) between src(%d) and tgt(%d)\n", iPath, id, id));
     1744            WARN(("VBoxTray:(WDDM) Unexpected iPath(%d) between src(%d) and tgt(%d)\n", iPath, pDispDef->idDisplay, pDispDef->idDisplay));
    17451745            continue;
    17461746        }
     
    18271827
    18281828                *pPathInfo = DispCfg.pPathInfoArray[0];
    1829                 pPathInfo->sourceInfo.id = id;
    1830                 pPathInfo->targetInfo.id = id;
     1829                pPathInfo->sourceInfo.id = pDispDef->idDisplay;
     1830                pPathInfo->targetInfo.id = pDispDef->idDisplay;
    18311831
    18321832                pModeInfoNew = &pModeInfo[DispCfg.cModeInfoArray];
    18331833                pModeInfoNew->infoType = DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE;
    1834                 pModeInfoNew->id = id;
     1834                pModeInfoNew->id = pDispDef->idDisplay;
    18351835                pModeInfoNew->adapterId = pModeInfo[0].adapterId;
    18361836                pSrcMode = &pModeInfoNew->sourceMode;
     
    18441844                pModeInfoNew++;
    18451845                pModeInfoNew->infoType = DISPLAYCONFIG_MODE_INFO_TYPE_TARGET;
    1846                 pModeInfoNew->id = id;
     1846                pModeInfoNew->id = pDispDef->idDisplay;
    18471847                pModeInfoNew->adapterId = pModeInfo[0].adapterId;
    18481848                pModeInfoNew->targetMode = pModeInfo[0].targetMode;
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp

    r72611 r73724  
    819819}
    820820
     821static BOOL DisplayChangeRequestHandler(PVBOXDISPLAYCONTEXT pCtx)
     822{
     823    VMMDevDisplayDef aDisplays[64];
     824    uint32_t cDisplays = RT_ELEMENTS(aDisplays);
     825    int rc = VINF_SUCCESS;
     826
     827    rc = VbglR3GetDisplayChangeRequestMulti(cDisplays, &cDisplays, &aDisplays[0], true /* fAck */);
     828
     829    if (RT_SUCCESS(rc))
     830    {
     831        uint32_t i;
     832
     833        LogRel(("Got multi resize request %d displays\n", cDisplays));
     834
     835        for (i = 0; i < cDisplays; ++i)
     836        {
     837            LogRel(("[%d]: %d 0x%02X %d,%d %dx%d %d\n",
     838                i, aDisplays[i].idDisplay,
     839                aDisplays[i].fDisplayFlags,
     840                aDisplays[i].xOrigin,
     841                aDisplays[i].yOrigin,
     842                aDisplays[i].cx,
     843                aDisplays[i].cy,
     844                aDisplays[i].cBitsPerPixel));
     845        }
     846
     847        /* Multidisplay resize is still implemented only for Win7 and newer guests.
     848           Single display resize request still goes old way. */
     849        if (pCtx->pEnv->dispIf.enmMode < VBOXDISPIF_MODE_WDDM_W7 || cDisplays == 1)
     850        {
     851            for (i = 0; i < cDisplays; ++i)
     852            {
     853                doResize(pCtx,
     854                    aDisplays[i].idDisplay,
     855                    aDisplays[i].cx,
     856                    aDisplays[i].cy,
     857                    aDisplays[i].cBitsPerPixel,
     858                    !RT_BOOL(aDisplays[i].fDisplayFlags & VMMDEV_DISPLAY_DISABLED),
     859                    aDisplays[i].xOrigin,
     860                    aDisplays[i].yOrigin,
     861                    RT_BOOL(aDisplays[i].fDisplayFlags & VMMDEV_DISPLAY_ORIGIN));
     862            }
     863        }
     864        else
     865        {
     866            rc = VBoxDispIfResizeDisplayWin7(&pCtx->pEnv->dispIf, cDisplays, &aDisplays[0]);
     867        }
     868
     869        return rc;
     870    }
     871
     872
     873    /* Fall back to the single monitor resize request. */
     874
     875    /*
     876    * We got at least one event. (bird: What does that mean actually?  The driver wakes us up immediately upon
     877    * receiving the event.  Or are we refering to mouse & display?  In the latter case it's misleading.)
     878    *
     879    * Read the requested resolution and try to set it until success.
     880    * New events will not be seen but a new resolution will be read in
     881    * this poll loop.
     882    *
     883    * Note! The interface we're using here was added in VBox 4.2.4.  As of 2017-08-16, this
     884    *       version has been unsupported for a long time and we therefore don't bother
     885    *       implementing fallbacks using VMMDevDisplayChangeRequest2 and VMMDevDisplayChangeRequest.
     886    */
     887    uint32_t cx = 0;
     888    uint32_t cy = 0;
     889    uint32_t cBits = 0;
     890    uint32_t iDisplay = 0;
     891    uint32_t cxOrigin = 0;
     892    uint32_t cyOrigin = 0;
     893    bool     fChangeOrigin = false;
     894    bool     fEnabled = false;
     895    rc = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBits, &iDisplay, &cxOrigin, &cyOrigin, &fEnabled, &fChangeOrigin,
     896        true /*fAck*/);
     897    if (RT_SUCCESS(rc))
     898    {
     899        /* Try to set the requested video mode. Repeat until it is successful or is rejected by the driver. */
     900        LogFlowFunc(("DisplayChangeReqEx parameters  iDisplay=%d x cx=%d x cy=%d x cBits=%d x SecondayMonEnb=%d x NewOriginX=%d x NewOriginY=%d x ChangeOrigin=%d\n",
     901            iDisplay, cx, cy, cBits, fEnabled, cxOrigin, cyOrigin, fChangeOrigin));
     902
     903        doResize(pCtx,
     904            iDisplay,
     905            cx,
     906            cy,
     907            cBits,
     908            fEnabled,
     909            cxOrigin,
     910            cyOrigin,
     911            fChangeOrigin);
     912    }
     913
     914    return rc;
     915}
     916
    821917/**
    822918 * Thread function to wait for and process display change requests.
     
    869965        {
    870966            if (fEvents & VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
    871             {
    872                 LogFlowFunc(("going to get display change information\n"));
    873 
    874 #if 0
    875                 /* Prototype code which processes the multimonitor resize request. */
    876                 VMMDevDisplayDef aDisplays[64];
    877                 uint32_t cDisplays = VBoxDisplayGetCount();
    878                 rc = VbglR3GetDisplayChangeRequestMulti(cDisplays, &cDisplays, &aDisplays[0], true /* fAck */);
    879                 if (RT_SUCCESS(rc))
    880                 {
    881                     LogRel(("Got multi resize request %d displays\n", cDisplays));
    882 
    883                     uint32_t i;
    884                     for (i = 0; i < cDisplays; ++i)
    885                     {
    886                         LogRel(("[%d]: %d 0x%02X %d,%d %dx%d %d\n",
    887                                  i, aDisplays[i].idDisplay,
    888                                  aDisplays[i].fDisplayFlags,
    889                                  aDisplays[i].xOrigin,
    890                                  aDisplays[i].yOrigin,
    891                                  aDisplays[i].cx,
    892                                  aDisplays[i].cy,
    893                                  aDisplays[i].cBitsPerPixel));
    894                     }
    895 
    896                     if (pCtx->pEnv->dispIf.enmMode >= VBOXDISPIF_MODE_WDDM_W7)
    897                     {
    898                         VBoxDispIfResizeDisplayWin7(&pCtx->pEnv->dispIf, cDisplays, &aDisplays[0]);
    899                     }
    900                     else if (pCtx->pEnv->dispIf.enmMode == VBOXDISPIF_MODE_WDDM)
    901                     {
    902                         VBoxDispIfResizeDisplayVista(&pCtx->pEnv->dispIf, cDisplays, &aDisplays[0]);
    903                     }
    904 
    905                     continue; /* Done */
    906                 }
    907                 /* Fall back to the single monitor resize request. */
    908 #endif
    909 
    910                 /*
    911                  * We got at least one event. (bird: What does that mean actually?  The driver wakes us up immediately upon
    912                  * receiving the event.  Or are we refering to mouse & display?  In the latter case it's misleading.)
    913                  *
    914                  * Read the requested resolution and try to set it until success.
    915                  * New events will not be seen but a new resolution will be read in
    916                  * this poll loop.
    917                  *
    918                  * Note! The interface we're using here was added in VBox 4.2.4.  As of 2017-08-16, this
    919                  *       version has been unsupported for a long time and we therefore don't bother
    920                  *       implementing fallbacks using VMMDevDisplayChangeRequest2 and VMMDevDisplayChangeRequest.
    921                  */
    922                 uint32_t cx             = 0;
    923                 uint32_t cy             = 0;
    924                 uint32_t cBits          = 0;
    925                 uint32_t iDisplay       = 0;
    926                 uint32_t cxOrigin       = 0;
    927                 uint32_t cyOrigin       = 0;
    928                 bool     fChangeOrigin  = false;
    929                 bool     fEnabled       = false;
    930                 rc = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBits, &iDisplay, &cxOrigin, &cyOrigin, &fEnabled, &fChangeOrigin,
    931                                                    true /*fAck*/);
    932                 if (RT_SUCCESS(rc))
    933                 {
    934                     /* Try to set the requested video mode. Repeat until it is successful or is rejected by the driver. */
    935                     LogFlowFunc(("DisplayChangeReqEx parameters  iDisplay=%d x cx=%d x cy=%d x cBits=%d x SecondayMonEnb=%d x NewOriginX=%d x NewOriginY=%d x ChangeOrigin=%d\n",
    936                                  iDisplay, cx, cy, cBits, fEnabled, cxOrigin, cyOrigin, fChangeOrigin));
    937 
    938                     doResize(pCtx,
    939                              iDisplay,
    940                              cx,
    941                              cy,
    942                              cBits,
    943                              fEnabled,
    944                              cxOrigin,
    945                              cyOrigin,
    946                              fChangeOrigin);
    947                 }
    948             } // if (fDisplayChangeQueried)
     967                DisplayChangeRequestHandler(pCtx);
    949968
    950969            if (fEvents & VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED)
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