VirtualBox

Changeset 33758 in vbox


Ignore:
Timestamp:
Nov 4, 2010 10:30:19 AM (14 years ago)
Author:
vboxsync
Message:

Main, Devices/VMMDev, VBoxBFE: some rewrites of the mouse handling code

Location:
trunk
Files:
6 edited

Legend:

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

    r33540 r33758  
    19541954     *
    19551955     * @returns VBox status code
    1956      * @param   capabilities  Capability mask
    1957      */
    1958     DECLR3CALLBACKMEMBER(int, pfnSetMouseCapabilities,(PPDMIVMMDEVPORT pInterface, uint32_t capabilities));
     1956     * @param   fCapsAdded    Mask of capabilities to add to the flag
     1957     * @param   fCapsRemoved  Mask of capabilities to remove from the flag
     1958     */
     1959    DECLR3CALLBACKMEMBER(int, pfnUpdateMouseCapabilities,(PPDMIVMMDEVPORT pInterface, uint32_t fCapsAdded, uint32_t fCapsremoved));
    19591960
    19601961    /**
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r33540 r33758  
    22352235 * @param   capabilities  Capability mask
    22362236 */
    2237 static DECLCALLBACK(int) vmmdevSetMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t fCaps)
     2237static DECLCALLBACK(int) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t fCapsAdded, uint32_t fCapsRemoved)
    22382238{
    22392239    VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
    22402240    PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
    22412241
    2242     bool fNotify = (   (fCaps & VMMDEV_MOUSE_NOTIFY_GUEST_MASK)
    2243                     != (pThis->mouseCapabilities & VMMDEV_MOUSE_NOTIFY_GUEST_MASK));
    2244 
    2245     LogRelFlowFunc(("fCaps=0x%x, fNotify %s\n", fCaps,
    2246                     fNotify ? "TRUE" : "FALSE"));
    2247 
    2248     pThis->mouseCapabilities &=   ~VMMDEV_MOUSE_HOST_MASK
     2242    uint32_t fOldCaps = pThis->mouseCapabilities;
     2243    pThis->mouseCapabilities &= ~(fCapsRemoved & VMMDEV_MOUSE_HOST_MASK);
     2244    pThis->mouseCapabilities |=   (fCapsAdded & VMMDEV_MOUSE_HOST_MASK)
    22492245                                | VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR;
    2250     pThis->mouseCapabilities |= (fCaps & VMMDEV_MOUSE_HOST_MASK);
     2246    bool fNotify = fOldCaps != pThis->mouseCapabilities;
     2247
     2248    LogRelFlowFunc(("fCapsAdded=0x%x, fCapsRemoved=0x%x, fNotify %s\n",
     2249                    fCapsAdded, fCapsRemoved, fNotify ? "TRUE" : "FALSE"));
     2250
    22512251    if (fNotify)
    22522252        VMMDevNotifyGuest (pThis, VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED);
     
    28952895     */
    28962896    /* IBase */
    2897     pThis->IBase.pfnQueryInterface         = vmmdevPortQueryInterface;
     2897    pThis->IBase.pfnQueryInterface          = vmmdevPortQueryInterface;
    28982898
    28992899    /* VMMDev port */
    2900     pThis->IPort.pfnQueryAbsoluteMouse     = vmmdevQueryAbsoluteMouse;
    2901     pThis->IPort.pfnSetAbsoluteMouse       = vmmdevSetAbsoluteMouse;
    2902     pThis->IPort.pfnQueryMouseCapabilities = vmmdevQueryMouseCapabilities;
    2903     pThis->IPort.pfnSetMouseCapabilities   = vmmdevSetMouseCapabilities;
    2904     pThis->IPort.pfnRequestDisplayChange   = vmmdevRequestDisplayChange;
    2905     pThis->IPort.pfnSetCredentials         = vmmdevSetCredentials;
    2906     pThis->IPort.pfnVBVAChange             = vmmdevVBVAChange;
    2907     pThis->IPort.pfnRequestSeamlessChange  = vmmdevRequestSeamlessChange;
    2908     pThis->IPort.pfnSetMemoryBalloon       = vmmdevSetMemoryBalloon;
    2909     pThis->IPort.pfnSetStatisticsInterval  = vmmdevSetStatisticsInterval;
    2910     pThis->IPort.pfnVRDPChange             = vmmdevVRDPChange;
    2911     pThis->IPort.pfnCpuHotUnplug           = vmmdevCpuHotUnplug;
    2912     pThis->IPort.pfnCpuHotPlug             = vmmdevCpuHotPlug;
     2900    pThis->IPort.pfnQueryAbsoluteMouse      = vmmdevQueryAbsoluteMouse;
     2901    pThis->IPort.pfnSetAbsoluteMouse        = vmmdevSetAbsoluteMouse;
     2902    pThis->IPort.pfnQueryMouseCapabilities  = vmmdevQueryMouseCapabilities;
     2903    pThis->IPort.pfnUpdateMouseCapabilities = vmmdevUpdateMouseCapabilities;
     2904    pThis->IPort.pfnRequestDisplayChange    = vmmdevRequestDisplayChange;
     2905    pThis->IPort.pfnSetCredentials          = vmmdevSetCredentials;
     2906    pThis->IPort.pfnVBVAChange              = vmmdevVBVAChange;
     2907    pThis->IPort.pfnRequestSeamlessChange   = vmmdevRequestSeamlessChange;
     2908    pThis->IPort.pfnSetMemoryBalloon        = vmmdevSetMemoryBalloon;
     2909    pThis->IPort.pfnSetStatisticsInterval   = vmmdevSetStatisticsInterval;
     2910    pThis->IPort.pfnVRDPChange              = vmmdevVRDPChange;
     2911    pThis->IPort.pfnCpuHotUnplug            = vmmdevCpuHotUnplug;
     2912    pThis->IPort.pfnCpuHotPlug              = vmmdevCpuHotPlug;
    29132913
    29142914    /* Shared folder LED */
    2915     pThis->SharedFolders.Led.u32Magic      = PDMLED_MAGIC;
     2915    pThis->SharedFolders.Led.u32Magic       = PDMLED_MAGIC;
    29162916    pThis->SharedFolders.ILeds.pfnQueryStatusLed = vmmdevQueryStatusLed;
    29172917
    29182918#ifdef VBOX_WITH_HGCM
    29192919    /* HGCM port */
    2920     pThis->IHGCMPort.pfnCompleted          = hgcmCompleted;
     2920    pThis->IHGCMPort.pfnCompleted           = hgcmCompleted;
    29212921#endif
    29222922
  • trunk/src/VBox/Frontends/VBoxBFE/VMMDevInterface.cpp

    r32851 r33758  
    156156 * @thread  The emulation thread.
    157157 */
    158 DECLCALLBACK(void) VMMDev::UpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
     158DECLCALLBACK(void) VMMDev::UpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
    159159{
    160160    /*
     
    163163
    164164    if (gMouse)
    165     {
    166         gMouse->onVMMDevCanAbsChange(!!(newCapabilities & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE));
    167         gMouse->onVMMDevNeedsHostChange(!!(newCapabilities & VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR));
    168     }
     165        gMouse->onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK);
    169166    if (gConsole)
    170     {
    171167        gConsole->resetCursor();
    172     }
    173168}
    174169
  • trunk/src/VBox/Main/MouseImpl.cpp

    r33708 r33758  
    2626
    2727#include <VBox/pdmdrv.h>
     28#include <VBox/VMMDev.h>
    2829
    2930#include <iprt/asm.h>
    30 
    31 #include <VBox/VMMDev.h>
    3231
    3332/** @name Mouse device capabilities bitfield
     
    7675{
    7776    RT_ZERO(mpDrv);
    78     mfVMMDevCanAbs = false;
    79     mfVMMDevNeedsHostCursor = false;
    80     mLastAbsX = 0x8000;
    81     mLastAbsY = 0x8000;
    82     mLastButtons = 0;
     77    mcLastAbsX = 0x8000;
     78    mcLastAbsY = 0x8000;
     79    mfLastButtons = 0;
    8380    return S_OK;
    8481}
     
    118115#endif
    119116
    120     mfHostCaps = 0;
    121 
    122117    /* Confirm a successful initialization */
    123118    autoInitSpan.setSucceeded();
     
    159154/////////////////////////////////////////////////////////////////////////////
    160155
    161 /** Query the VMM device for the Guest Additions's (and the host front-end's)
    162  * mouse handling capabilities.
    163  * @note all calls out of this object are made with no locks held! */
    164 HRESULT Mouse::getVMMDevMouseCaps(uint32_t *pfCaps)
    165 {
    166     AssertPtrReturn(pfCaps, E_POINTER);
    167     /** @todo does getting the VMMDev and the VMMDevPort like this guarantee
    168      * they won't go away while we are using them? */
    169     VMMDev *pVMMDev = mParent->getVMMDev();
    170     ComAssertRet(pVMMDev, E_FAIL);
    171     PPDMIVMMDEVPORT pVMMDevPort = pVMMDev->getVMMDevPort();
    172     ComAssertRet(pVMMDevPort, E_FAIL);
    173 
    174     int rc = pVMMDevPort->pfnQueryMouseCapabilities(pVMMDevPort, pfCaps);
    175     return RT_SUCCESS(rc) ? S_OK : E_FAIL;
    176 }
    177 
    178156/** Report the front-end's mouse handling capabilities to the VMM device and
    179157 * thus to the guest.
    180158 * @note all calls out of this object are made with no locks held! */
    181 HRESULT Mouse::setVMMDevMouseCaps(uint32_t fCaps)
     159HRESULT Mouse::updateVMMDevMouseCaps(uint32_t fCapsAdded,
     160                                     uint32_t fCapsRemoved)
    182161{
    183162    VMMDev *pVMMDev = mParent->getVMMDev();
    184     ComAssertRet(pVMMDev, E_FAIL);
     163    if (!pVMMDev)
     164        return E_FAIL;  /* No assertion, as the front-ends can send events
     165                         * at all sorts of inconvenient times. */
    185166    PPDMIVMMDEVPORT pVMMDevPort = pVMMDev->getVMMDevPort();
    186167    ComAssertRet(pVMMDevPort, E_FAIL);
    187168
    188     int rc = pVMMDevPort->pfnSetMouseCapabilities(pVMMDevPort, fCaps);
     169    int rc = pVMMDevPort->pfnUpdateMouseCapabilities(pVMMDevPort, fCapsAdded,
     170                                                     fCapsRemoved);
    189171    return RT_SUCCESS(rc) ? S_OK : E_FAIL;
    190172}
     
    206188    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    207189
    208     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    209     bool fAbs = false;
    210 
    211     if (mfVMMDevCanAbs)
    212         fAbs = TRUE;
    213 
    214     for (unsigned i = 0; i < MOUSE_MAX_DEVICES; ++i)
    215         if (mpDrv[i] && (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_ABSOLUTE))
    216             fAbs = TRUE;
    217 
    218     *absoluteSupported = fAbs;
     190    *absoluteSupported = supportsAbs();
    219191    return S_OK;
    220192}
     
    235207    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    236208
    237     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    238     bool fRel = false;
    239 
    240     for (unsigned i = 0; i < MOUSE_MAX_DEVICES; ++i)
    241         if (mpDrv[i] && (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_RELATIVE))
    242             fRel = TRUE;
    243 
    244     *relativeSupported = fRel;
     209    *relativeSupported = supportsRel();
    245210    return S_OK;
    246211}
     
    261226    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    262227
    263     *pfNeedsHostCursor = mfVMMDevNeedsHostCursor;
     228    *pfNeedsHostCursor = guestNeedsHostCursor();
    264229    return S_OK;
    265230}
     
    311276                                        int32_t dw, uint32_t fButtons)
    312277{
    313     if (dx || dy || dz || dw || fButtons != mLastButtons)
     278    if (dx || dy || dz || dw || fButtons != mfLastButtons)
    314279    {
    315280        PPDMIMOUSEPORT pUpPort = NULL;
     
    332297                            tr("Could not send the mouse event to the virtual mouse (%Rrc)"),
    333298                            vrc);
    334         mLastButtons = fButtons;
     299        mfLastButtons = fButtons;
    335300    }
    336301    return S_OK;
     
    347312                                        int32_t dz, int32_t dw, uint32_t fButtons)
    348313{
    349     if (   mouseXAbs != mLastAbsX || mouseYAbs != mLastAbsY
    350         || dz || dw || fButtons != mLastButtons)
     314    if (   mouseXAbs != mcLastAbsX || mouseYAbs != mcLastAbsY
     315        || dz || dw || fButtons != mfLastButtons)
    351316    {
    352317        PPDMIMOUSEPORT pUpPort = NULL;
     
    369334                            tr("Could not send the mouse event to the virtual mouse (%Rrc)"),
    370335                            vrc);
    371         mLastButtons = fButtons;
     336        mfLastButtons = fButtons;
    372337
    373338    }
     
    389354    ComAssertRet(pVMMDevPort, E_FAIL);
    390355
    391     if (mouseXAbs != mLastAbsX || mouseYAbs != mLastAbsY)
     356    if (mouseXAbs != mcLastAbsX || mouseYAbs != mcLastAbsY)
    392357    {
    393358        int vrc = pVMMDevPort->pfnSetAbsoluteMouse(pVMMDevPort,
     
    418383    LONG cJiggle = 0;
    419384
    420     if (mfVMMDevCanAbs)
     385    if (vmmdevCanAbs())
    421386    {
    422387        /*
    423388         * Send the absolute mouse position to the VMM device.
    424389         */
    425         if (mouseXAbs != mLastAbsX || mouseYAbs != mLastAbsY)
     390        if (mouseXAbs != mcLastAbsX || mouseYAbs != mcLastAbsY)
    426391        {
    427392            rc = reportAbsEventToVMMDev(mouseXAbs, mouseYAbs);
     
    433398        rc = reportAbsEventToMouseDev(mouseXAbs, mouseYAbs, dz, dw, fButtons);
    434399
    435     mLastAbsX = mouseXAbs;
    436     mLastAbsY = mouseYAbs;
     400    mcLastAbsX = mouseXAbs;
     401    mcLastAbsY = mouseYAbs;
    437402    return rc;
    438403}
     
    453418{
    454419    HRESULT rc;
    455     /** Do we need to send updated capabilities to the VMM device? */
    456     bool fUpdateCaps = FALSE;
    457420    uint32_t fButtons;
    458421
    459422    AutoCaller autoCaller(this);
    460423    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    461 
    462     {
    463         AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    464 
    465         LogRel3(("%s: dx=%d, dy=%d, dz=%d, dw=%d\n", __PRETTY_FUNCTION__,
     424    LogRel3(("%s: dx=%d, dy=%d, dz=%d, dw=%d\n", __PRETTY_FUNCTION__,
    466425                 dx, dy, dz, dw));
    467         /* Make sure that the guest knows that we are sending real movement
    468          * events to the PS/2 device and not just dummy wake-up ones. */
    469         if (mfHostCaps & VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE)
    470         {
    471             mfHostCaps &= ~VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE;
    472             fUpdateCaps = TRUE;
    473         }
    474 
    475         fButtons = mouseButtonsToPDM(buttonState);
    476     }
    477     /** @note we drop the lock before calling out of the object! */
    478     if (fUpdateCaps)
    479         setVMMDevMouseCaps(mfHostCaps);
     426
     427    fButtons = mouseButtonsToPDM(buttonState);
     428    /* Make sure that the guest knows that we are sending real movement
     429     * events to the PS/2 device and not just dummy wake-up ones. */
     430    updateVMMDevMouseCaps(0, VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE);
    480431    rc = reportRelEventToMouseDev(dx, dy, dz, dw, fButtons);
    481432
     
    538489             __PRETTY_FUNCTION__, x, y, dz, dw, buttonState));
    539490
    540     uint32_t mouseXAbs, mouseYAbs;
    541     /** Do we need to send updated capabilities to the VMM device? */
    542     bool fUpdateCaps = FALSE;
     491    uint32_t mouseXAbs, mouseYAbs, fButtons;
    543492
    544493    /** @todo the front end should do this conversion to avoid races */
     
    551500     * Understand the issues involved and fix for the rest. */
    552501    /* if (mouseXAbs > 0xffff)
    553         mouseXAbs = mLastAbsX;
     502        mouseXAbs = mcLastAbsX;
    554503    if (mouseYAbs > 0xffff)
    555         mouseYAbs = mLastAbsY; */
    556 
    557     uint32_t mouseCaps;
    558     rc = getVMMDevMouseCaps(&mouseCaps);
    559     if (FAILED(rc)) return rc;
    560     uint32_t fButtons = mouseButtonsToPDM(buttonState);
    561 
     504        mouseYAbs = mcLastAbsY; */
     505
     506    fButtons = mouseButtonsToPDM(buttonState);
    562507    /* If we are doing old-style (IRQ-less) absolute reporting to the VMM
    563508     * device then make sure the guest is aware of it, so that it knows to
    564509     * ignore relative movement on the PS/2 device. */
    565     {
    566         AutoWriteLock aLock(this COMMA_LOCKVAL_SRC_POS);
    567 
    568         if (!(mfHostCaps & VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE))
    569         {
    570             mfHostCaps |= VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE;
    571             fUpdateCaps = TRUE;
    572         }
    573     }
    574     /** @note we drop the lock again before calling out! */
    575     if (fUpdateCaps)
    576         setVMMDevMouseCaps(mfHostCaps);
    577 
     510    updateVMMDevMouseCaps(VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE, 0);
    578511    rc = reportAbsEvent(mouseXAbs, mouseYAbs, dz, dw, fButtons,
    579                         !!(mouseCaps & VMMDEV_MOUSE_GUEST_USES_EVENT));
     512                        RT_BOOL(  mfVMMDevGuestCaps
     513                                & VMMDEV_MOUSE_GUEST_USES_EVENT));
    580514
    581515#ifndef VBOXBFE_WITHOUT_COM
     
    591525
    592526
    593 /** Work out what mouse capabilities the guest and the front-end have to offer,
    594  * based on the state of the available emulated devices and the capabilities
    595  * the guest has signalled to the VMM device, and notify the guest and the
    596  * Console respectively about what the other can do. */
    597 void Mouse::sendMouseCapsNotifications(void)
     527/** Does the guest currently rely on the host to draw the mouse cursor or
     528 * can it switch to doing it itself in software? */
     529bool Mouse::guestNeedsHostCursor(void)
     530{
     531    return RT_BOOL(mfVMMDevGuestCaps & VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR);
     532}
     533
     534
     535/** Check what sort of reporting can be done using the devices currently
     536 * enabled.  Does not consider the VMM device. */
     537void Mouse::getDeviceCaps(bool *pfAbs, bool *pfRel)
    598538{
    599539    bool fAbsDev = false;
    600540    bool fRelDev = false;
    601     uint32_t u32MouseCaps;
    602 
    603     {
    604         AutoWriteLock aLock(this COMMA_LOCKVAL_SRC_POS);
    605 
    606         for (unsigned i = 0; i < MOUSE_MAX_DEVICES; ++i)
    607             if (mpDrv[i])
    608             {
    609                if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_ABSOLUTE)
    610                    fAbsDev = true;
    611                if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_RELATIVE)
    612                    fRelDev = true;
    613             }
    614         if (fAbsDev && !(mfHostCaps & VMMDEV_MOUSE_HOST_HAS_ABS_DEV))
    615             mfHostCaps |= VMMDEV_MOUSE_HOST_HAS_ABS_DEV;
    616         if (!fAbsDev && (mfHostCaps & VMMDEV_MOUSE_HOST_HAS_ABS_DEV))
    617             mfHostCaps &= ~VMMDEV_MOUSE_HOST_HAS_ABS_DEV;
    618     }
    619     /** @note we drop the lock again before calling out! */
    620     if (SUCCEEDED(getVMMDevMouseCaps(&u32MouseCaps)))
    621         mfVMMDevCanAbs =    (u32MouseCaps & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE)
    622                         && fRelDev;
     541
     542    AutoReadLock aLock(this COMMA_LOCKVAL_SRC_POS);
     543
     544    for (unsigned i = 0; i < MOUSE_MAX_DEVICES; ++i)
     545        if (mpDrv[i])
     546        {
     547           if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_ABSOLUTE)
     548               fAbsDev = true;
     549           if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_RELATIVE)
     550               fRelDev = true;
     551        }
     552    if (pfAbs)
     553        *pfAbs = fAbsDev;
     554    if (pfRel)
     555        *pfRel = fRelDev;
     556}
     557
     558
     559/** Does the VMM device currently support absolute reporting? */
     560bool Mouse::vmmdevCanAbs(void)
     561{
     562    bool fRelDev;
     563
     564    getDeviceCaps(NULL, &fRelDev);
     565    return    (mfVMMDevGuestCaps & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE)
     566           && fRelDev;
     567}
     568
     569
     570/** Does the VMM device currently support absolute reporting? */
     571bool Mouse::deviceCanAbs(void)
     572{
     573    bool fAbsDev;
     574
     575    getDeviceCaps(&fAbsDev, NULL);
     576    return fAbsDev;
     577}
     578
     579
     580/** Can we currently send relative events to the guest? */
     581bool Mouse::supportsRel(void)
     582{
     583    bool fRelDev;
     584
     585    getDeviceCaps(NULL, &fRelDev);
     586    return fRelDev;
     587}
     588
     589
     590/** Can we currently send absolute events to the guest? */
     591bool Mouse::supportsAbs(void)
     592{
     593    bool fAbsDev;
     594
     595    getDeviceCaps(&fAbsDev, NULL);
     596    return fAbsDev || vmmdevCanAbs();
     597}
     598
     599
     600/** Check what sort of reporting can be done using the devices currently
     601 * enabled (including the VMM device) and notify the guest and the front-end.
     602 */
     603void Mouse::sendMouseCapsNotifications(void)
     604{
     605    bool fAbsDev, fRelDev, fCanAbs, fNeedsHostCursor;
     606
     607    {
     608        AutoReadLock aLock(this COMMA_LOCKVAL_SRC_POS);
     609
     610        getDeviceCaps(&fAbsDev, &fRelDev);
     611        fCanAbs = supportsAbs();
     612        fNeedsHostCursor = guestNeedsHostCursor();
     613    }
     614    if (fAbsDev)
     615        updateVMMDevMouseCaps(VMMDEV_MOUSE_HOST_HAS_ABS_DEV, 0);
    623616    else
    624         mfVMMDevCanAbs = false;
     617        updateVMMDevMouseCaps(0, VMMDEV_MOUSE_HOST_HAS_ABS_DEV);
    625618    /** @todo this call takes the Console lock in order to update the cached
    626619     * callback data atomically.  However I can't see any sign that the cached
    627620     * data is ever used again. */
    628     mParent->onMouseCapabilityChange(fAbsDev || mfVMMDevCanAbs, fRelDev,
    629                                      mfVMMDevNeedsHostCursor);
    630     /** @todo if this gets called during device initialisation we get an
    631      * error due to VMMDev not being initialised yet. */
    632     setVMMDevMouseCaps(mfHostCaps);
     621    mParent->onMouseCapabilityChange(fCanAbs, fRelDev, fNeedsHostCursor);
    633622}
    634623
  • trunk/src/VBox/Main/VMMDevInterface.cpp

    r33540 r33758  
    323323 * @thread  The emulation thread.
    324324 */
    325 DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
     325DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
    326326{
    327327    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     
    334334    Mouse *pMouse = pConsole->getMouse();
    335335    if (pMouse)  /** @todo and if not?  Can that actually happen? */
    336     {
    337         pMouse->onVMMDevCanAbsChange(!!(newCapabilities & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE));
    338         pMouse->onVMMDevNeedsHostChange(!!(newCapabilities & VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR));
    339     }
     336        pMouse->onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK);
    340337}
    341338
  • trunk/src/VBox/Main/include/MouseImpl.h

    r33061 r33758  
    8282    }
    8383
    84     /** notify the front-end that the guest now supports absolute reporting */
    85     void onVMMDevCanAbsChange(bool)
     84    /** notify the front-end of guest capability changes */
     85    void onVMMDevGuestCapsChange(uint32_t fCaps)
    8686    {
    87         sendMouseCapsNotifications();
    88     }
    89 
    90     /** notify the front-end as to whether the guest can start drawing its own
    91      * cursor on demand */
    92     void onVMMDevNeedsHostChange(bool needsHost)
    93     {
    94         mfVMMDevNeedsHostCursor = needsHost;
     87        mfVMMDevGuestCaps = fCaps;
    9588        sendMouseCapsNotifications();
    9689    }
     
    10396    static DECLCALLBACK(void)   drvDestruct(PPDMDRVINS pDrvIns);
    10497
    105     HRESULT getVMMDevMouseCaps(uint32_t *pfCaps);
    106     HRESULT setVMMDevMouseCaps(uint32_t fCaps);
     98    HRESULT updateVMMDevMouseCaps(uint32_t fCapsAdded, uint32_t fCapsRemoved);
    10799    HRESULT reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
    108100                                 int32_t dw, uint32_t fButtons);
     
    115107    HRESULT convertDisplayRes(LONG x, LONG y, uint32_t *pcX, uint32_t *pcY);
    116108
     109    void getDeviceCaps(bool *pfAbs, bool *pfRel);
    117110    void sendMouseCapsNotifications(void);
     111    bool guestNeedsHostCursor(void);
     112    bool vmmdevCanAbs(void);
     113    bool deviceCanAbs(void);
     114    bool supportsAbs(void);
     115    bool supportsRel(void);
    118116
    119117#ifdef VBOXBFE_WITHOUT_COM
     
    125123    struct DRVMAINMOUSE    *mpDrv[MOUSE_MAX_DEVICES];
    126124
    127     LONG mfHostCaps;
    128     bool mfVMMDevCanAbs;
    129     bool mfVMMDevNeedsHostCursor;
    130     uint32_t mLastAbsX;
    131     uint32_t mLastAbsY;
    132     uint32_t mLastButtons;
     125    uint32_t mfVMMDevGuestCaps;  /** We cache this to avoid access races */
     126    uint32_t mcLastAbsX;
     127    uint32_t mcLastAbsY;
     128    uint32_t mfLastButtons;
    133129
    134130#ifndef VBOXBFE_WITHOUT_COM
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