VirtualBox

Changeset 55225 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Apr 13, 2015 7:56:31 PM (10 years ago)
Author:
vboxsync
Message:

Additions/x11/vboxvideo: new functions for getting mode hint information from HGSMI and from VBoxClient via X11 properties.

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

Legend:

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

    r55194 r55225  
    266266}
    267267
     268static bool useHardwareCursor(uint32_t fCursorCapabilities)
     269{
     270    if (   !(fCursorCapabilities & VMMDEV_MOUSE_HOST_CANNOT_HWPOINTER)
     271        && (fCursorCapabilities & VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE))
     272        return true;
     273    return false;
     274}
     275
     276static void compareAndMaybeSetUseHardwareCursor(VBOXPtr pVBox, uint32_t fCursorCapabilities, bool *pfChanged, bool fSet)
     277{
     278    if (pVBox->fUseHardwareCursor != useHardwareCursor(fCursorCapabilities))
     279        *pfChanged = true;
     280    if (fSet)
     281        pVBox->fUseHardwareCursor = useHardwareCursor(fCursorCapabilities);
     282}
     283
     284#define SIZE_HINTS_PROPERTY          "VBOX_SIZE_HINTS"
     285#define SIZE_HINTS_MISMATCH_PROPERTY "VBOX_SIZE_HINTS_MISMATCH"
     286#define MOUSE_CAPABILITIES_PROPERTY  "VBOX_MOUSE_CAPABILITIES"
     287
     288#define COMPARE_AND_MAYBE_SET(pDest, src, pfChanged, fSet) \
     289do { \
     290    if (*(pDest) != (src)) \
     291    { \
     292        if (fSet) \
     293            *(pDest) = (src); \
     294        *(pfChanged) = true; \
     295    } \
     296} while(0)
     297
     298/** Read in information about the most recent size hints and cursor
     299 * capabilities requested for the guest screens from a root window property set
     300 * by an X11 client.  Information obtained via HGSMI takes priority. */
     301void vbvxReadSizesAndCursorIntegrationFromProperties(ScrnInfoPtr pScrn, bool *pfNeedUpdate)
     302{
     303    VBOXPtr pVBox = VBOXGetRec(pScrn);
     304    size_t cPropertyElements, cDummy;
     305    int32_t *paModeHints,  *pfCursorCapabilities;
     306    int rc;
     307    unsigned i;
     308    bool fChanged;
     309    bool fNeedUpdate = false;
     310    int32_t fSizeMismatch = false;
     311
     312    if (vbvxGetIntegerPropery(pScrn, SIZE_HINTS_PROPERTY, &cPropertyElements, &paModeHints) != VINF_SUCCESS)
     313        paModeHints = NULL;
     314    if (paModeHints != NULL)
     315        for (i = 0; i < cPropertyElements / 2 && i < pVBox->cScreens; ++i)
     316        {
     317            VBVAMODEHINT *pVBVAModeHint = &pVBox->paVBVAModeHints[i];
     318            int32_t iSizeHint = paModeHints[i * 2];
     319            int32_t iLocation = paModeHints[i * 2 + 1];
     320            bool fNoHGSMI = !pVBox->fHaveHGSMIModeHints || pVBVAModeHint->magic != VBVAMODEHINT_MAGIC;
     321
     322            fChanged = false;
     323            if (iSizeHint != 0)
     324            {
     325                if (iSizeHint == -1)
     326                    COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afConnected, false, &fChanged, fNoHGSMI);
     327                else
     328                {
     329                    COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredSize.cx, (iSizeHint >> 16) & 0x8fff, &fChanged, fNoHGSMI);
     330                    COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredSize.cy, iSizeHint & 0x8fff, &fChanged, fNoHGSMI);
     331                    COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afConnected, true, &fChanged, fNoHGSMI);
     332                }
     333                if (iLocation == -1)
     334                    COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afHaveLocation, false, &fChanged, fNoHGSMI);
     335                else
     336                {
     337                    COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredLocation.x, (iLocation >> 16) & 0x8fff, &fChanged,
     338                                          fNoHGSMI);
     339                    COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredLocation.y, iLocation & 0x8fff, &fChanged, fNoHGSMI);
     340                    COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afHaveLocation, true, &fChanged, fNoHGSMI);
     341                }
     342                if (fChanged && fNoHGSMI)
     343                    fNeedUpdate = true;
     344                if (fChanged && !fNoHGSMI)
     345                    fSizeMismatch = true;
     346            }
     347        }
     348    fChanged = false;
     349    if (   vbvxGetIntegerPropery(pScrn, MOUSE_CAPABILITIES_PROPERTY, &cDummy, &pfCursorCapabilities) == VINF_SUCCESS
     350        && cDummy == 1)
     351        compareAndMaybeSetUseHardwareCursor(pVBox, *pfCursorCapabilities, &fChanged, !pVBox->fHaveHGSMIModeHints);
     352    if (fChanged && !pVBox->fHaveHGSMIModeHints)
     353        fNeedUpdate = true;
     354    if (fChanged && pVBox->fHaveHGSMIModeHints)
     355        fSizeMismatch = true;
     356    vbvxSetIntegerPropery(pScrn, SIZE_HINTS_MISMATCH_PROPERTY, 1, &fSizeMismatch, false);
     357    if (pfNeedUpdate != NULL && fNeedUpdate)
     358        *pfNeedUpdate = true;
     359}
     360
     361/** Read in information about the most recent size hints and cursor
     362 * capabilities requested for the guest screens from HGSMI. */
     363void vbvxReadSizesAndCursorIntegrationFromHGSMI(ScrnInfoPtr pScrn, bool *pfNeedUpdate)
     364{
     365    VBOXPtr pVBox = VBOXGetRec(pScrn);
     366    int rc;
     367    unsigned i;
     368    bool fChanged = false;
     369    uint32_t fCursorCapabilities;
     370
     371    if (!pVBox->fHaveHGSMIModeHints)
     372        return;
     373    rc = VBoxHGSMIGetModeHints(&pVBox->guestCtx, pVBox->cScreens, pVBox->paVBVAModeHints);
     374    VBVXASSERT(rc == VINF_SUCCESS, ("VBoxHGSMIGetModeHints failed, rc=%d.\n", rc));
     375    for (i = 0; i < pVBox->cScreens; ++i)
     376        if (pVBox->paVBVAModeHints[i].magic == VBVAMODEHINT_MAGIC)
     377        {
     378            COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredSize.cx, pVBox->paVBVAModeHints[i].cx & 0x8fff, &fChanged, true);
     379            COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredSize.cy, pVBox->paVBVAModeHints[i].cy & 0x8fff, &fChanged, true);
     380            COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afConnected, RT_BOOL(pVBox->paVBVAModeHints[i].fEnabled), &fChanged, true);
     381            COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredLocation.x, (int32_t)pVBox->paVBVAModeHints[i].dx & 0x8fff, &fChanged,
     382                                  true);
     383            COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].aPreferredLocation.y, (int32_t)pVBox->paVBVAModeHints[i].dy & 0x8fff, &fChanged,
     384                                  true);
     385            if (pVBox->paVBVAModeHints[i].dx != ~(uint32_t)0 && pVBox->paVBVAModeHints[i].dy != ~(uint32_t)0)
     386                COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afHaveLocation, true, &fChanged, true);
     387            else
     388                COMPARE_AND_MAYBE_SET(&pVBox->pScreens[i].afHaveLocation, false, &fChanged, true);
     389        }
     390    rc = VBoxQueryConfHGSMI(&pVBox->guestCtx, VBOX_VBVA_CONF32_CURSOR_CAPABILITIES, &fCursorCapabilities);
     391    VBVXASSERT(rc == VINF_SUCCESS, ("Getting VBOX_VBVA_CONF32_CURSOR_CAPABILITIES failed, rc=%d.\n", rc));
     392    compareAndMaybeSetUseHardwareCursor(pVBox, fCursorCapabilities, &fChanged, true);
     393    if (pfNeedUpdate != NULL && fChanged)
     394        *pfNeedUpdate = true;
     395}
     396
     397#undef COMPARE_AND_MAYBE_SET
     398
    268399#ifndef VBOXVIDEO_13
    269400
  • trunk/src/VBox/Additions/x11/vboxvideo/helpers.c

    r55203 r55225  
    7878}
    7979
     80void vbvxSetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t cData, int32_t *paData, Bool fSendEvent)
     81{
     82    Atom property_name;
     83    int i;
     84
     85    property_name = MakeAtom(pszName, strlen(pszName), TRUE);
     86    VBVXASSERT(property_name != BAD_RESOURCE, ("Failed to set atom \"%s\"\n", pszName));
     87    ChangeWindowProperty(ROOT_WINDOW(pScrn), property_name, XA_INTEGER, 32, PropModeReplace, cData, paData, fSendEvent);
     88}
     89
    8090void vbvxReprobeCursor(ScrnInfoPtr pScrn)
    8191{
  • trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h

    r55204 r55225  
    163163    /** The current preferred resolution for the screen */
    164164    RTRECTSIZE aPreferredSize;
     165    /** The current preferred location for the screen. */
     166    RTPOINT aPreferredLocation;
    165167    /** Has this screen been enabled by the host? */
    166168    Bool afConnected;
    167169    /** The last mode hint data read from the X11 property. */
    168170    int32_t lastModeHintFromProperty;
     171    /** Does this screen have a preferred location? */
     172    Bool afHaveLocation;
    169173};
    170174
     
    206210    /** The last requested framebuffer size. */
    207211    RTRECTSIZE FBSize;
    208 #ifdef VBOXVIDEO_13
     212    /** Can we get mode hint and cursor integration information from HGSMI? */
     213    bool fHaveHGSMIModeHints;
    209214    /** Array of structures for receiving mode hints. */
    210215    VBVAMODEHINT *paVBVAModeHints;
     216#ifdef VBOXVIDEO_13
    211217# ifdef RT_OS_LINUX
    212218    /** Input device file descriptor for getting ACPI hot-plug events. */
     
    244250#define VBOXGetRec vbvxGetRec  /* Temporary */
    245251extern int vbvxGetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t *pcData, int32_t **ppaData);
     252extern void vbvxSetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t cData, int32_t *paData, Bool fSendEvent);
    246253extern void vbvxReprobeCursor(ScrnInfoPtr pScrn);
    247254
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