VirtualBox

Ignore:
Timestamp:
May 14, 2009 3:58:41 PM (16 years ago)
Author:
vboxsync
Message:

VBoxTray: Display debug stuff. Added check for setting display mode.

File:
1 edited

Legend:

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

    r19701 r19703  
    169169        if (DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
    170170        {
    171             Log(("Found primary device. err %d\n", GetLastError ()));
     171            Log(("ResizeDisplayDevice: Found primary device. err %d\n", GetLastError ()));
    172172            NumDevices++;
    173173        }
     
    175175        {
    176176           
    177             Log(("Found secondary device. err %d\n", GetLastError ()));
     177            Log(("ResizeDisplayDevice: Found secondary device. err %d\n", GetLastError ()));
    178178            NumDevices++;
    179179        }
     
    184184    }
    185185   
    186     Log(("Found total %d devices. err %d\n", NumDevices, GetLastError ()));
     186    Log(("ResizeDisplayDevice: Found total %d devices. err %d\n", NumDevices, GetLastError ()));
    187187   
    188188    if (NumDevices == 0 || Id >= NumDevices)
    189189    {
    190         Log(("Requested identifier %d is invalid. err %d\n", Id, GetLastError ()));
     190        Log(("ResizeDisplayDevice: Requested identifier %d is invalid. err %d\n", Id, GetLastError ()));
    191191        return FALSE;
    192192    }
     
    206206    while (EnumDisplayDevices (NULL, i, &DisplayDevice, 0))
    207207    {
    208         Log(("[%d(%d)] %s\n", i, DevNum, DisplayDevice.DeviceName));
     208        Log(("ResizeDisplayDevice: [%d(%d)] %s\n", i, DevNum, DisplayDevice.DeviceName));
    209209       
    210210        BOOL bFetchDevice = FALSE;
     
    212212        if (DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
    213213        {
    214             Log(("Found primary device. err %d\n", GetLastError ()));
     214            Log(("ResizeDisplayDevice: Found primary device. err %d\n", GetLastError ()));
    215215            DevPrimaryNum = DevNum;
    216216            bFetchDevice = TRUE;
     
    219219        {
    220220           
    221             Log(("Found secondary device. err %d\n", GetLastError ()));
     221            Log(("ResizeDisplayDevice: Found secondary device. err %d\n", GetLastError ()));
    222222            bFetchDevice = TRUE;
    223223        }
     
    227227            if (DevNum >= NumDevices)
    228228            {
    229                 Log(("%d >= %d\n", NumDevices, DevNum));
     229                Log(("ResizeDisplayDevice: %d >= %d\n", NumDevices, DevNum));
    230230                return FALSE;
    231231            }
     
    238238                 ENUM_REGISTRY_SETTINGS, &paDeviceModes[DevNum]))
    239239            {
    240                 Log(("EnumDisplaySettings err %d\n", GetLastError ()));
     240                Log(("ResizeDisplayDevice: EnumDisplaySettings err %d\n", GetLastError ()));
    241241                return FALSE;
    242242            }
    243243           
    244             Log(("%dx%d at %d,%d\n",
     244            Log(("ResizeDisplayDevice: %dx%d at %d,%d\n",
    245245                    paDeviceModes[DevNum].dmPelsWidth,
    246246                    paDeviceModes[DevNum].dmPelsHeight,
     
    281281        && paDeviceModes[Id].dmBitsPerPel == BitsPerPixel)
    282282    {
    283         Log(("VBoxDisplayThread : already at desired resolution.\n"));
     283        Log(("ResizeDisplayDevice: Already at desired resolution.\n"));
    284284        return FALSE;
    285285    }
     
    289289    for (i = 0; i < NumDevices; i++)
    290290    {
    291         Log(("[%d]: %d,%d %dx%d\n",
     291        Log(("ResizeDisplayDevice: [%d]: %d,%d %dx%d\n",
    292292                i, paRects[i].left, paRects[i].top,
    293293                paRects[i].right - paRects[i].left,
     
    303303    tempDevMode.dmSize = sizeof(DEVMODE);
    304304    EnumDisplaySettings(NULL, 0xffffff, &tempDevMode);
     305    BOOL bUpdateMonitor = FALSE;
     306    LONG status = 0;
    305307
    306308    /* Assign the new rectangles to displays. */
     
    321323        }
    322324
    323         Log(("calling pfnChangeDisplaySettingsEx %x\n", gCtx.pfnChangeDisplaySettingsEx));     
    324 
    325         gCtx.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName,
    326                                         &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL);
    327 
    328         Log(("ChangeDisplaySettings position err %d\n", GetLastError ()));
     325        /* Test if the mode can be set. */
     326        Log(("ResizeDisplayDevice: Testing if the mode can be set ...\n"));
     327        SetLastError(0);
     328        status = gCtx.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName,
     329                                                 &paDeviceModes[i], NULL, CDS_TEST, NULL);
     330        if (status == DISP_CHANGE_SUCCESSFUL)
     331        {
     332            Log(("ResizeDisplayDevice: Mode can be set! Calling pfnChangeDisplaySettingsEx %x\n", gCtx.pfnChangeDisplaySettingsEx));         
     333            gCtx.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName,
     334                                            &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL);   
     335            Log(("ResizeDisplayDevice: ChangeDisplaySettingsEx position err %d\n", GetLastError ()));
     336            bUpdateMonitor = TRUE;
     337        }
     338        else
     339        {
     340            if (status == DISP_CHANGE_BADMODE)
     341            {
     342                Log(("ResizeDisplayDevice: Bad mode detected. No changes made.\n"));
     343            }
     344            else Log(("ResizeDisplayDevice: Mode can NOT be set! Error: %d\n", status));
     345        }
    329346    }
    330347   
    331348    /* A second call to ChangeDisplaySettings updates the monitor. */
    332     LONG status = ChangeDisplaySettings(NULL, 0);
    333     Log(("ChangeDisplaySettings update status %d\n", status));
    334     if (status == DISP_CHANGE_SUCCESSFUL || status == DISP_CHANGE_BADMODE)
    335     {
    336         /* Successfully set new video mode or our driver can not set the requested mode. Stop trying. */
    337         return FALSE;
    338     }
    339 
    340     /* Retry the request. */
    341     return TRUE;
     349    if (bUpdateMonitor)
     350    {
     351        status = ChangeDisplaySettings(NULL, 0);
     352        Log(("ResizeDisplayDevice: ChangeDisplaySettings update status %d\n", status));
     353        if (status == DISP_CHANGE_SUCCESSFUL || status == DISP_CHANGE_BADMODE)
     354        {
     355            /* Successfully set new video mode or our driver can not set the requested mode. Stop trying. */
     356            return FALSE;
     357        }
     358
     359        /* Retry the request. */
     360        return TRUE;
     361    }
     362
     363    return FALSE; /* Don't retry; maybe something went wrong. */
    342364}
    343365
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