VirtualBox

Ignore:
Timestamp:
Mar 17, 2016 6:40:28 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106078
Message:

bugref:8288: Additions/x11: rework VBoxClient video mode hint handling: reworked the display parts of VBoxClient. Now they only use standard X11 mechanisms for any recent server version, which means that the same code works with the kernel and the user-space driver, and also wait for about two seconds before changing the mode, cancelling if some one else is faster, to avoid interfering with mechanisms provided by the desktop environment. With old servers we get mode hints from a property updated by the driver. The user space driver code has been updated to match, and has also dropped pre-HGSMI mechanisms for getting mode hints.

Location:
trunk/src/VBox/Additions/x11/vboxvideo
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/vboxvideo/getmode.c

    r56228 r60083  
    181181}
    182182
    183 #define SIZE_HINTS_PROPERTY          "VBOX_SIZE_HINTS"
    184 #define SIZE_HINTS_MISMATCH_PROPERTY "VBOX_SIZE_HINTS_MISMATCH"
    185 #define MOUSE_CAPABILITIES_PROPERTY  "VBOX_MOUSE_CAPABILITIES"
    186 
    187183#define COMPARE_AND_MAYBE_SET(pDest, src, pfChanged, fSet) \
    188184do { \
     
    194190    } \
    195191} while(0)
    196 
    197 /** Read in information about the most recent size hints and cursor
    198  * capabilities requested for the guest screens from a root window property set
    199  * by an X11 client.  Information obtained via HGSMI takes priority. */
    200 void vbvxReadSizesAndCursorIntegrationFromProperties(ScrnInfoPtr pScrn, bool *pfNeedUpdate)
    201 {
    202     VBOXPtr pVBox = VBOXGetRec(pScrn);
    203     size_t cPropertyElements, cDummy;
    204     int32_t *paModeHints,  *pfCursorCapabilities;
    205     unsigned i;
    206     bool fChanged;
    207     bool fNeedUpdate = false;
    208     int32_t fSizeMismatch = false;
    209 
    210     if (vbvxGetIntegerPropery(pScrn, SIZE_HINTS_PROPERTY, &cPropertyElements, &paModeHints) != VINF_SUCCESS)
    211         paModeHints = NULL;
    212     if (paModeHints != NULL)
    213         for (i = 0; i < cPropertyElements / 2 && i < pVBox->cScreens; ++i)
    214         {
    215             VBVAMODEHINT *pVBVAModeHint = &pVBox->paVBVAModeHints[i];
    216             int32_t iSizeHint = paModeHints[i * 2];
    217             int32_t iLocation = paModeHints[i * 2 + 1];
    218             bool fNoHGSMI = !pVBox->fHaveHGSMIModeHints || pVBVAModeHint->magic != VBVAMODEHINT_MAGIC;
    219 
    220             fChanged = false;
    221             if (iSizeHint != 0)
    222             {
    223                 if (iSizeHint == -1)
    224                     COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afConnected, false, &fChanged, fNoHGSMI);
    225                 else
    226                 {
    227                     COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredSize.cx, (iSizeHint >> 16) & 0x8fff, &fChanged, fNoHGSMI);
    228                     COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredSize.cy, iSizeHint & 0x8fff, &fChanged, fNoHGSMI);
    229                     COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afConnected, true, &fChanged, fNoHGSMI);
    230                 }
    231                 if (iLocation == -1)
    232                     COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afHaveLocation, false, &fChanged, fNoHGSMI);
    233                 else
    234                 {
    235                     COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredLocation.x, (iLocation >> 16) & 0x8fff, &fChanged,
    236                                           fNoHGSMI);
    237                     COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredLocation.y, iLocation & 0x8fff, &fChanged, fNoHGSMI);
    238                     COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afHaveLocation, true, &fChanged, fNoHGSMI);
    239                 }
    240                 if (fChanged && fNoHGSMI)
    241                     fNeedUpdate = true;
    242                 if (fChanged && !fNoHGSMI)
    243                     fSizeMismatch = true;
    244             }
    245         }
    246     fChanged = false;
    247     if (   vbvxGetIntegerPropery(pScrn, MOUSE_CAPABILITIES_PROPERTY, &cDummy, &pfCursorCapabilities) == VINF_SUCCESS
    248         && cDummy == 1)
    249         compareAndMaybeSetUseHardwareCursor(pVBox, *pfCursorCapabilities, &fChanged, !pVBox->fHaveHGSMIModeHints);
    250     if (fChanged && !pVBox->fHaveHGSMIModeHints)
    251         fNeedUpdate = true;
    252     if (fChanged && pVBox->fHaveHGSMIModeHints)
    253         fSizeMismatch = true;
    254     vbvxSetIntegerPropery(pScrn, SIZE_HINTS_MISMATCH_PROPERTY, 1, &fSizeMismatch, false);
    255     if (pfNeedUpdate != NULL && fNeedUpdate)
    256         *pfNeedUpdate = true;
    257 }
    258192
    259193/** Read in information about the most recent size hints and cursor
  • trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c

    r59943 r60083  
    989989}
    990990
     991#ifndef VBOXVIDEO_13
    991992/** Set the graphics and guest cursor support capabilities to the host if
    992993 *  the user-space helper is running. */
     
    998999    int rc;
    9991000
    1000     if (pVBox->fHaveHGSMIModeHints)
     1001    if (!pVBox->fHaveHGSMIModeHints)
    10011002        return;
    1002     rc = vbvxGetIntegerPropery(pScrn, "VBOX_HAS_GRAPHICS", &cData, &paData);
     1003    rc = vbvxGetIntegerPropery(pScrn, "VBOXCLIENT_STARTED", &cData, &paData);
    10031004    if (rc != VINF_SUCCESS || cData != 1)
    10041005        return;
    1005     if (RT_BOOL(*paData) != hasVT)
    1006     {
    1007         uint32_t fFeatures;
    1008         VbglR3SetGuestCaps(hasVT ? VMMDEV_GUEST_SUPPORTS_GRAPHICS : 0, hasVT ? 0 : VMMDEV_GUEST_SUPPORTS_GRAPHICS);
    1009         rc = VbglR3GetMouseStatus(&fFeatures, NULL, NULL);
    1010         fFeatures &= VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE | VMMDEV_MOUSE_NEW_PROTOCOL;
    1011         if (RT_SUCCESS(rc))
    1012             VbglR3SetMouseStatus(hasVT ? fFeatures : fFeatures | VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR);
    1013     }
    1014     *paData = hasVT;
    1015 }
     1006    pVBox->fHaveVBoxClient = TRUE;
     1007    VBoxHGSMISendCapsInfo(&pVBox->guestCtx,   hasVT
     1008                                            ? VBVACAPS_VIDEO_MODE_HINTS | VBVACAPS_DISABLE_CURSOR_INTEGRATION
     1009                                            : VBVACAPS_DISABLE_CURSOR_INTEGRATION);
     1010}
     1011#endif
    10161012
    10171013#ifdef VBOXVIDEO_13
     
    11111107#else
    11121108
     1109#define PREFERRED_MODE_ATOM_NAME "VBOXVIDEO_PREFERRED_MODE"
     1110
    11131111static void setSizesRandR11(ScrnInfoPtr pScrn)
    11141112{
    11151113    VBOXPtr pVBox = VBOXGetRec(pScrn);
    11161114    DisplayModePtr pNewMode;
     1115    int32_t propertyValue;
    11171116
    11181117    pNewMode = pScrn->modes != pScrn->currentMode ? pScrn->modes : pScrn->modes->next;
    11191118    pNewMode->HDisplay = RT_CLAMP(pVBox->pScreens[0].aPreferredSize.cx, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MAX_VIRTUAL);
    11201119    pNewMode->VDisplay = RT_CLAMP(pVBox->pScreens[0].aPreferredSize.cy, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MAX_VIRTUAL);
     1120    propertyValue = (pNewMode->HDisplay << 16) + pNewMode->VDisplay;
     1121    ChangeWindowProperty(ROOT_WINDOW(pScrn), MakeAtom(PREFERRED_MODE_ATOM_NAME,
     1122                         sizeof(PREFERRED_MODE_ATOM_NAME) - 1, TRUE), XA_INTEGER, 32,
     1123                         PropModeReplace, 1, &propertyValue, TRUE);
    11211124}
    11221125
     
    11501153    (void)pTimeout;
    11511154    (void)pReadmask;
    1152     updateGraphicsCapability(pScrn, pScrn->vtSema);
     1155#ifndef VBOXVIDEO_13
     1156    if (!pVBox->fHaveVBoxClient)
     1157        updateGraphicsCapability(pScrn, pScrn->vtSema);
     1158#endif
    11531159    if (pScrn->vtSema)
    11541160        vbvxReadSizesAndCursorIntegrationFromHGSMI(pScrn, &fNeedUpdate);
    1155     /* This has to be done even when we are switched out so that VBoxClient can
    1156      * set a mode using RandR without having to know the virtual terminal state.
    1157      */
    1158     if (ROOT_WINDOW(pScrn) != NULL)
    1159         vbvxReadSizesAndCursorIntegrationFromProperties(pScrn, &fNeedUpdate);
    11601161    if (fNeedUpdate)
    11611162        setSizesAndCursorIntegration(pScrn, false);
     
    12461247        return FALSE;
    12471248    VBoxInitialiseSizeHints(pScrn);
    1248     /* Get any screen size hints from HGSMI.  Do not yet try to access X11
    1249      * properties, as they are not yet set up, and nor are the clients that
    1250      * might have set them. */
     1249    /* Get any screen size hints from HGSMI. */
    12511250    vbvxReadSizesAndCursorIntegrationFromHGSMI(pScrn, NULL);
    12521251
     
    13661365
    13671366    TRACE_ENTRY();
    1368     updateGraphicsCapability(pScrn, TRUE);
    13691367    vbvxSetUpHGSMIHeapInGuest(pVBox, pScrn->videoRam * 1024);
    13701368    vboxEnableVbva(pScrn);
     
    13741372    setSizesAndCursorIntegration(pScrn, false);
    13751373#else
     1374    updateGraphicsCapability(pScrn, TRUE);
    13761375    setModeRandR11(pScrn, pScrn->currentMode, false, true, cXOverRide, cYOverRide);
    13771376    DeleteProperty(ROOT_WINDOW(pScrn), MakeAtom(NO_VT_ATOM_NAME, sizeof(NO_VT_ATOM_NAME) - 1, TRUE));
     
    13901389
    13911390    TRACE_ENTRY();
    1392     updateGraphicsCapability(pScrn, FALSE);
    13931391#ifdef VBOXVIDEO_13
    13941392    for (i = 0; i < pVBox->cScreens; ++i)
    13951393        vbox_crtc_dpms(pVBox->pScreens[i].paCrtcs, DPMSModeOff);
    13961394#else
     1395    updateGraphicsCapability(pScrn, FALSE);
    13971396    ChangeWindowProperty(ROOT_WINDOW(pScrn), MakeAtom(NO_VT_ATOM_NAME, sizeof(NO_VT_ATOM_NAME) - 1, FALSE), XA_INTEGER, 32,
    13981397                         PropModeReplace, 1, &propertyValue, TRUE);
  • trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h

    r59194 r60083  
    201201    void *hACPIEventHandler;
    202202# endif
     203#else
     204    /** Has VBoxClient registered with us for setting video modes? */
     205    bool fHaveVBoxClient;
    203206#endif
    204207    /** HGSMI guest heap context */
  • trunk/src/VBox/Additions/x11/vboxvideo/vbva.c

    r57426 r60083  
    222222#ifdef VBOXVIDEO_13
    223223    VBoxHGSMISendCapsInfo(&pVBox->guestCtx, VBVACAPS_VIDEO_MODE_HINTS | VBVACAPS_DISABLE_CURSOR_INTEGRATION);
     224#else
     225    VBoxHGSMISendCapsInfo(&pVBox->guestCtx, VBVACAPS_DISABLE_CURSOR_INTEGRATION);
     226#endif
    224227    pVBox->fHaveHGSMIModeHints = haveHGSMIModeHintAndCursorReportingInterface(pVBox);
    225228    pVBox->fHostHasScreenBlankingFlag = hostHasScreenBlankingFlag(pVBox);
    226 #endif
    227229    return rc;
    228230}
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