VirtualBox

Ignore:
Timestamp:
Feb 6, 2013 6:36:38 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83616
Message:

Additions/WINNT/VBoxTray: Support for dynamic operations on virtual secondary monitors
1) Enabling/ Disabling
2) Repositioning
3) Resizing.

File:
1 edited

Legend:

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

    r44550 r44557  
    1616
    1717#include "VBoxTray.h"
    18 
     18#define _WIN32_WINNT 0x0601
    1919#include <iprt/log.h>
    2020#include <iprt/err.h>
     
    2626#include <iprt/asm.h>
    2727#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 */
     32typedef 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
     42static _VBOXDISPLAYWDDMAPICONTEXT gCtx = {0};
    2843
    2944/* display driver interface abstraction for XPDM & WDDM
     
    95110            Log((__FUNCTION__": VBoxDisplayInit: pfnEnumDisplayDevices = %p\n", pIf->modeData.wddm.pfnEnumDisplayDevices));
    96111            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            }
    97127
    98128            /* this is vista and up */
     
    11531183    Data.aScreenInfos[0].Mode.Height = pDeviceMode->dmPelsHeight;
    11541184    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    }
    11551189    DWORD err = vboxDispIfEscapeWDDM(pIf, &Data.EscapeHdr, sizeof (Data) - sizeof (Data.EscapeHdr), TRUE);
    11561190    if (err != NO_ERROR)
     
    11981232        pInfo->Height = paDeviceModes[i].dmPelsHeight;
    11991233        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        }
    12001242
    12011243        if (!hAdapter)
     
    12821324    return winEr;
    12831325}
     1326
     1327DWORD 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
    12841374#endif /* VBOX_WITH_WDDM */
    12851375
Note: See TracChangeset for help on using the changeset viewer.

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