VirtualBox

Changeset 35212 in vbox


Ignore:
Timestamp:
Dec 16, 2010 11:15:43 PM (14 years ago)
Author:
vboxsync
Message:

Main/Mouse: ignore mouse events on disabled screens properly

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MouseImpl.cpp

    r34835 r35212  
    442442/**
    443443 * Convert an (X, Y) value pair in screen co-ordinates (starting from 1) to a
    444  * value from 0 to 0xffff.
     444 * value from 0 to 0xffff.  Sets the optional validity value to false if the
     445 * pair is not on an active screen and to true otherwise.
    445446 *
    446447 * @returns   COM status value
    447448 */
    448 HRESULT Mouse::convertDisplayRes(LONG x, LONG y, uint32_t *pcX, uint32_t *pcY)
     449HRESULT Mouse::convertDisplayRes(LONG x, LONG y, int32_t *pcX, int32_t *pcY,
     450                                 bool *pfValid)
    449451{
    450452    AssertPtrReturn(pcX, E_POINTER);
    451453    AssertPtrReturn(pcY, E_POINTER);
     454    AssertPtrNullReturn(pfValid, E_POINTER);
    452455    Display *pDisplay = mParent->getDisplay();
    453456    ComAssertRet(pDisplay, E_FAIL);
    454457
     458    if (pfValid)
     459        *pfValid = true;
    455460    if (!(mfVMMDevGuestCaps & VMMDEV_MOUSE_NEW_PROTOCOL))
    456461    {
     
    472477        *pcX = x1 != x2 ? (x - 1 - x1) * 0xFFFF / (x2 - x1) : 0;
    473478        *pcY = y1 != y2 ? (y - 1 - y1) * 0xFFFF / (y2 - y1) : 0;
     479        if (*pcX < 0 || *pcX > 0xFFFF || *pcY < 0 || *pcY > 0xFFFF)
     480            if (pfValid)
     481                *pfValid = false;
    474482    }
    475483    return S_OK;
     
    501509             __PRETTY_FUNCTION__, x, y, dz, dw, buttonState));
    502510
    503     uint32_t mouseXAbs, mouseYAbs, fButtons;
     511    int32_t mouseXAbs, mouseYAbs;
     512    uint32_t fButtons;
     513    bool fValid;
    504514
    505515    /** @todo the front end should do this conversion to avoid races */
    506516    /** @note Or maybe not... races are pretty inherent in everything done in
    507517     *        this object and not really bad as far as I can see. */
    508     HRESULT rc = convertDisplayRes(x, y, &mouseXAbs, &mouseYAbs);
     518    HRESULT rc = convertDisplayRes(x, y, &mouseXAbs, &mouseYAbs, &fValid);
    509519    if (FAILED(rc)) return rc;
    510520
     
    521531     * ignore relative movement on the PS/2 device. */
    522532    updateVMMDevMouseCaps(VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE, 0);
    523     rc = reportAbsEvent(mouseXAbs, mouseYAbs, dz, dw, fButtons,
    524                         RT_BOOL(  mfVMMDevGuestCaps
    525                                 & VMMDEV_MOUSE_NEW_PROTOCOL));
     533    if (fValid)
     534    {
     535        rc = reportAbsEvent(mouseXAbs, mouseYAbs, dz, dw, fButtons,
     536                            RT_BOOL(  mfVMMDevGuestCaps
     537                                    & VMMDEV_MOUSE_NEW_PROTOCOL));
    526538
    527539#ifndef VBOXBFE_WITHOUT_COM
    528     mMouseEvent.reinit(VBoxEventType_OnGuestMouse, true, x, y, dz, dw, fButtons);
    529     mMouseEvent.fire(0);
     540        mMouseEvent.reinit(VBoxEventType_OnGuestMouse, true, x, y, dz, dw,
     541                           fButtons);
     542        mMouseEvent.fire(0);
    530543#endif
     544    }
    531545
    532546    return rc;
  • trunk/src/VBox/Main/include/MouseImpl.h

    r33758 r35212  
    105105                           int32_t dz, int32_t dw, uint32_t fButtons,
    106106                           bool fUsesVMMDevEvent);
    107     HRESULT convertDisplayRes(LONG x, LONG y, uint32_t *pcX, uint32_t *pcY);
     107    HRESULT convertDisplayRes(LONG x, LONG y, int32_t *pcX, int32_t *pcY,
     108                              bool *pfValid);
    108109
    109110    void getDeviceCaps(bool *pfAbs, bool *pfRel);
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