VirtualBox

Ignore:
Timestamp:
Mar 31, 2015 3:59:35 PM (10 years ago)
Author:
vboxsync
Message:

Additions/x11: temporary check-in of new X11 Additions resizing code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/display.cpp

    r54192 r55043  
    8686/** Tell the VBoxGuest driver we no longer want any events and tell the host
    8787 * we no longer support any capabilities. */
    88 static int disableEventsAndCaps()
     88static int disableEventsAndCaps(bool fDisableEvents)
    8989{
    9090    int rc = VbglR3SetGuestCaps(0, VMMDEV_GUEST_SUPPORTS_GRAPHICS);
     
    9494    if (RT_FAILURE(rc))
    9595        VBClFatalError(("Failed to unset mouse status, rc=%Rrc.\n", rc));
    96     rc = VbglR3CtlFilterMask(0,  VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED
    97                                 | VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
     96    if (fDisableEvents)
     97        rc = VbglR3CtlFilterMask(0, VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED | VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
    9898    if (RT_FAILURE(rc))
    9999        VBClFatalError(("Failed to unset filter mask, rc=%Rrc.\n", rc));
     
    174174static void updateSizeHintsProperty(struct DISPLAYSTATE *pState)
    175175{
    176     long *paSizeHints = (long *)RTMemTmpAllocZ(pState->cScreensTracked * sizeof(long));
     176    long *paSizeHints = (long *)RTMemTmpAllocZ(pState->cScreensTracked * sizeof(long) * 2);
    177177    unsigned i;
    178178
     
    181181    for (i = 0; i < pState->cScreensTracked; ++i)
    182182    {
     183        if (pState->paScreenInformation[i].fEnabled)
     184            paSizeHints[2 * i] =   (pState->paScreenInformation[i].cx & 0x8fff) << 16
     185                                 | (pState->paScreenInformation[i].cy & 0x8fff);
     186        else if (pState->paScreenInformation[i].cx != 0 && pState->paScreenInformation[i].cy != 0)
     187            paSizeHints[2 * i] = -1;
    183188        if (   pState->paScreenInformation[i].fEnabled
    184             && pState->paScreenInformation[i].cx != 0 && pState->paScreenInformation[i].cy != 0)
    185             paSizeHints[i] = (pState->paScreenInformation[i].cx & 0x8fff) << 16 | (pState->paScreenInformation[i].cy & 0x8fff);
    186         else if (pState->paScreenInformation[i].cx != 0 && pState->paScreenInformation[i].cy != 0)
    187             paSizeHints[i] = -1;
     189            && pState->paScreenInformation[i].fUpdatePosition)
     190            paSizeHints[2 * i + 1] =   (pState->paScreenInformation[i].x & 0x8fff) << 16
     191                                     | (pState->paScreenInformation[i].y & 0x8fff);
     192        else
     193            paSizeHints[2 * i + 1] = -1;
    188194    }
    189195    XChangeProperty(pState->pDisplay, DefaultRootWindow(pState->pDisplay), XInternAtom(pState->pDisplay, "VBOX_SIZE_HINTS", 0),
    190                     XA_INTEGER, 32, PropModeReplace, (unsigned char *)paSizeHints, pState->cScreensTracked);
     196                    XA_INTEGER, 32, PropModeReplace, (unsigned char *)paSizeHints, pState->cScreensTracked * 2);
    191197    XFlush(pState->pDisplay);
    192198    RTMemTmpFree(paSizeHints);
    193199}
    194200
    195 static void notifyXServer(struct DISPLAYSTATE *pState)
     201static void notifyXServerRandR11(struct DISPLAYSTATE *pState)
    196202{
    197203    char szCommand[256];
    198     unsigned i;
    199     bool fUpdateInformation = false;
    200204
    201205    /** @note The xrandr command can fail if something else accesses RandR at
    202206     *  the same time.  We just ignore failure for now and let the user try
    203207     *  again as we do not know what someone else is doing. */
    204     for (i = 0; i < pState->cScreensTracked; ++i)
    205         if (pState->paScreenInformation[i].fUpdateSize)
    206             fUpdateInformation = true;
    207     if (   !pState->fHaveRandR12 && pState->paScreenInformation[0].fUpdateSize
     208    if (   pState->paScreenInformation[0].fUpdateSize
    208209        && pState->paScreenInformation[0].cx > 0 && pState->paScreenInformation[0].cy > 0)
    209210    {
     
    212213        system(szCommand);
    213214        pState->paScreenInformation[0].fUpdateSize = false;
    214     }
    215     else if (pState->fHaveRandR12 && fUpdateInformation)
    216         for (i = 0; i < pState->cScreensTracked; ++i)
    217         {
    218             if (pState->paScreenInformation[i].fUpdateSize)
    219             {
    220                 RTStrPrintf(szCommand, sizeof(szCommand), "%s --output VGA-%u --preferred", pState->pcszXrandr, i);
    221                 system(szCommand);
    222             }
    223             if (pState->paScreenInformation[i].fUpdatePosition)
    224             {
    225                 RTStrPrintf(szCommand, sizeof(szCommand), "%s --output VGA-%u --auto --pos %ux%u",
    226                             pState->pcszXrandr, i, pState->paScreenInformation[i].x, pState->paScreenInformation[i].y);
    227                 system(szCommand);
    228             }
    229             pState->paScreenInformation[i].fUpdateSize = pState->paScreenInformation[i].fUpdatePosition = false;
    230         }
    231     else
    232     {
    233         RTStrPrintf(szCommand, sizeof(szCommand), "%s", pState->pcszXrandr);
    234         system(szCommand);
    235215    }
    236216}
     
    250230                    (unsigned char *)&fFeatures, 1);
    251231    XFlush(pState->pDisplay);
    252     if (pState->fHaveRandR12)
    253         for (i = 0; i < pState->cScreensTracked; ++i)
    254             pState->paScreenInformation[i].fUpdateSize = true;
    255     else
    256         pState->paScreenInformation[0].fUpdateSize = true;
    257232}
    258233
     
    294269        updateMouseCapabilities(pState);
    295270        updateSizeHintsProperty(pState);
    296         notifyXServer(pState);
     271        if (!pState->fHaveRandR12)
     272            notifyXServerRandR11(pState);
    297273        do
    298274            rc = VbglR3WaitEvent(  VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST
     
    385361    if (!pSelf->mfInit)
    386362        return VERR_WRONG_ORDER;
    387     return disableEventsAndCaps();
     363    return disableEventsAndCaps(false);
    388364}
    389365
     
    400376{
    401377    NOREF(ppInterface);
    402     disableEventsAndCaps();
     378    disableEventsAndCaps(true);
    403379    VbglR3Term();
    404380}
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