VirtualBox

Changeset 52189 in vbox


Ignore:
Timestamp:
Jul 25, 2014 2:09:02 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95246
Message:

Additions/x11/VBoxClient: make remembering screen size between sessions work for multiple monitors, second series.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuestLib.h

    r52178 r52189  
    485485                                                    bool *pfEnabled, bool fAck);
    486486VBGLR3DECL(bool)    VbglR3HostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits);
     487VBGLR3DECL(int)     VbglR3VideoModeGetHighestSavedScreen(unsigned *pcScreen);
    487488VBGLR3DECL(int)     VbglR3SaveVideoMode(unsigned cScreen, unsigned cx,
    488489                                        unsigned cy, unsigned cBits, unsigned x,
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp

    r49950 r52189  
    778778VBGLR3DECL(void) VbglR3GuestPropEnumFree(PVBGLR3GUESTPROPENUM pHandle)
    779779{
     780    if (!pHandle)
     781        return;
    780782    RTMemFree(pHandle->pchBuf);
    781783    RTMemFree(pHandle);
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibVideo.cpp

    r52177 r52189  
    278278
    279279/**
     280 * Get the highest screen number for which there is a saved video mode or "0"
     281 * if there are no saved modes.
     282 *
     283 * @returns iprt status value
     284 * @param   pcScreen   where to store the virtual screen number
     285 */
     286VBGLR3DECL(int) VbglR3VideoModeGetHighestSavedScreen(unsigned *pcScreen)
     287{
     288#if defined(VBOX_WITH_GUEST_PROPS)
     289    using namespace guestProp;
     290
     291    int rc, rc2 = VERR_UNRESOLVED_ERROR;
     292    uint32_t u32ClientId = 0;
     293    const char *pszPattern = VIDEO_PROP_PREFIX"*";
     294    PVBGLR3GUESTPROPENUM pHandle = NULL;
     295    const char *pszName;
     296    unsigned cHighestScreen = 0;
     297
     298    AssertPtrReturn(pcScreen, VERR_INVALID_POINTER);
     299    rc = VbglR3GuestPropConnect(&u32ClientId);
     300    if (RT_SUCCESS(rc))
     301        rc = VbglR3GuestPropEnum(u32ClientId, &pszPattern, 1, &pHandle,
     302                                 &pszName, NULL, NULL, NULL);
     303    if (u32ClientId != 0)
     304        rc2 = VbglR3GuestPropDisconnect(u32ClientId);
     305    if (RT_SUCCESS(rc))
     306        rc = rc2;
     307    while (pszName != NULL && RT_SUCCESS(rc))
     308    {
     309        uint32_t cScreen;
     310
     311        rc = RTStrToUInt32Full(pszName + sizeof(VIDEO_PROP_PREFIX) - 1, 10,
     312                               &cScreen);
     313        if (RT_SUCCESS(rc))  /* There may be similar properties with text. */
     314            cHighestScreen = RT_MAX(cHighestScreen, cScreen);
     315        rc = VbglR3GuestPropEnumNext(pHandle, &pszName, NULL, NULL, NULL);
     316    }
     317    VbglR3GuestPropEnumFree(pHandle);
     318    if (RT_SUCCESS(rc))
     319        *pcScreen = cHighestScreen;
     320    return rc;
     321#else /* !VBOX_WITH_GUEST_PROPS */
     322    return VERR_NOT_IMPLEMENTED;
     323#endif /* !VBOX_WITH_GUEST_PROPS */
     324}
     325
     326/**
    280327 * Save video mode parameters to the guest property store.
    281328 *
     
    299346    char szModeParms[MAX_VALUE_LEN];
    300347    uint32_t u32ClientId = 0;
    301     unsigned cx2, cy2, cBits2, x2, y2;
     348    unsigned cx2, cy2, cBits2, x2, y2, cHighestScreen, cHighestScreen2;
    302349    bool fEnabled2;
    303 
     350    int rc, rc2 = VERR_UNRESOLVED_ERROR;
     351
     352    rc = VbglR3VideoModeGetHighestSavedScreen(&cHighestScreen);
    304353    RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%u", cScreen);
    305354    RTStrPrintf(szModeParms, sizeof(szModeParms), "%ux%ux%u,%ux%u,%u", cx, cy,
    306355                cBits, x, y, (unsigned) fEnabled);
    307     int rc = VbglR3GuestPropConnect(&u32ClientId);
     356    if (RT_SUCCESS(rc))
     357        rc = VbglR3GuestPropConnect(&u32ClientId);
    308358    if (RT_SUCCESS(rc))
    309359        rc = VbglR3GuestPropWriteValue(u32ClientId, szModeName, szModeParms);
    310360    if (u32ClientId != 0)
    311         VbglR3GuestPropDisconnect(u32ClientId);  /* Return value ignored, because what can we do anyway? */
     361        rc2 = VbglR3GuestPropDisconnect(u32ClientId);
     362    if (RT_SUCCESS(rc))
     363        rc = rc2;
     364    /* Sanity check 1.  We do not try to make allowance for someone else
     365     * changing saved settings at the same time as us. */
    312366    if (RT_SUCCESS(rc))
    313367    {
     
    319373            rc = VERR_WRITE_ERROR;
    320374    }
     375    /* Sanity check 2.  Same comment. */
     376    if (RT_SUCCESS(rc))
     377        rc = VbglR3VideoModeGetHighestSavedScreen(&cHighestScreen2);
     378    if (RT_SUCCESS(rc))
     379        if (cHighestScreen2 != RT_MAX(cHighestScreen, cScreen))
     380            rc = VERR_INTERNAL_ERROR;
    321381    return rc;
    322382#else /* !VBOX_WITH_GUEST_PROPS */
     
    358418    int cMatches;
    359419    unsigned cx, cy, cBits, x, y, fEnabled;
     420    int rc, rc2 = VERR_UNRESOLVED_ERROR;
    360421
    361422    /** @todo add a VbglR3GuestPropReadValueF/FV that does the RTStrPrintf for you. */
    362423    RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%u", cScreen);
    363     int rc = VbglR3GuestPropConnect(&u32ClientId);
     424    rc = VbglR3GuestPropConnect(&u32ClientId);
    364425    if (RT_SUCCESS(rc))
    365426        rc = VbglR3GuestPropReadValue(u32ClientId, szModeName, szModeParms,
    366427                                      sizeof(szModeParms), NULL);
    367428    if (u32ClientId != 0)
    368         VbglR3GuestPropDisconnect(u32ClientId);  /* Return value ignored, because what can we do anyway? */
     429        rc2 = VbglR3GuestPropDisconnect(u32ClientId);
     430    if (RT_SUCCESS(rc))
     431        rc = rc2;
    369432
    370433/*
  • trunk/src/VBox/Additions/x11/VBoxClient/display.cpp

    r52177 r52189  
    219219static void runDisplay(struct x11State *pState)
    220220{
    221     int status, rc, i;
     221    int status, rc;
     222    unsigned i, cScreens;
    222223    char szCommand[256];
    223224    Cursor hClockCursor = XCreateFontCursor(pState->pDisplay, XC_watch);
     
    225226
    226227    LogRelFlowFunc(("\n"));
    227     /** @todo fix this not to use a hard-coded value. */
    228     for (i = 0; i < 64; ++i)
     228    rc = VbglR3VideoModeGetHighestSavedScreen(&cScreens);
     229    if (RT_FAILURE(rc))
     230        FatalError(("Failed to get the number of saved screen modes, rc=%Rrc\n",
     231                    rc));
     232    for (i = 0; i < RT_MAX(cScreens + 1, 8); ++i)
    229233    {
    230234        unsigned cx = 0, cy = 0, cBPP = 0, x = 0, y = 0;
     
    233237        rc = VbglR3RetrieveVideoMode(i, &cx, &cy, &cBPP, &x, &y,
    234238                                     &fEnabled);
     239        if (RT_SUCCESS(rc) && i > cScreens) /* Sanity */
     240            FatalError(("Internal error retrieving the number of saved screen modes.\n"));
    235241        if (RT_SUCCESS(rc))
    236242            setModeX11(pState, cx, cy, cBPP, i, x, y, fEnabled,
     
    298304            rc = VbglR3SeamlessGetLastEvent(&Mode);
    299305            if (RT_FAILURE(rc))
    300                 FatalError(("Failed to save size hint, rc=%Rrc\n", rc));
     306                FatalError(("Failed to check seamless mode, rc=%Rrc\n", rc));
    301307            if (Mode == VMMDev_Seamless_Disabled)
    302308            {
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