VirtualBox

Changeset 40310 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Mar 1, 2012 11:56:06 AM (13 years ago)
Author:
vboxsync
Message:

Devices/VMMDev and Additions: use a single definition for the value range of the Additions pointer position reporting.

File:
1 edited

Legend:

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

    r40282 r40310  
    4141/** @} */
    4242
    43 /** @name Absolute mouse reporting range
    44  * @{ */
    45 enum
    46 {
    47     /** Lower end */
    48     MOUSE_RANGE_LOWER = 0,
    49     /** Higher end */
    50     MOUSE_RANGE_UPPER = 0xFFFF,
    51     /** Full range */
    52     MOUSE_RANGE = MOUSE_RANGE_UPPER - MOUSE_RANGE_LOWER
    53 };
    54 /** @} */
    5543
    5644/**
     
    327315                                        int32_t dz, int32_t dw, uint32_t fButtons)
    328316{
    329     if (mouseXAbs < MOUSE_RANGE_LOWER || mouseXAbs > MOUSE_RANGE_UPPER)
     317    if (   mouseXAbs < VMMDEV_MOUSE_RANGE_MIN
     318        || mouseXAbs > VMMDEV_MOUSE_RANGE_MAX)
    330319        return S_OK;
    331     if (mouseYAbs < MOUSE_RANGE_LOWER || mouseYAbs > MOUSE_RANGE_UPPER)
     320    if (   mouseYAbs < VMMDEV_MOUSE_RANGE_MIN
     321        || mouseYAbs > VMMDEV_MOUSE_RANGE_MAX)
    332322        return S_OK;
    333323    if (   mouseXAbs != mcLastAbsX || mouseYAbs != mcLastAbsY
     
    477467/**
    478468 * Convert an (X, Y) value pair in screen co-ordinates (starting from 1) to a
    479  * value from MOUSE_RANGE_LOWER to MOUSE_RANGE_UPPER.  Sets the optional
    480  * validity value to false if the pair is not on an active screen and to true
    481  * otherwise.
     469 * value from VMMDEV_MOUSE_RANGE_MIN to VMMDEV_MOUSE_RANGE_MAX.  Sets the
     470 * optional validity value to false if the pair is not on an active screen and
     471 * to true otherwise.
    482472 * @note      since guests with recent versions of X.Org use a different method
    483473 *            to everyone else to map the valuator value to a screen pixel (they
     
    501491     * to compensate for differences in guest methods for mapping back to
    502492     * pixels */
    503     enum { ADJUST_RANGE = - 3 * MOUSE_RANGE / 4 };
     493    enum { ADJUST_RANGE = - 3 * VMMDEV_MOUSE_RANGE / 4 };
    504494
    505495    if (pfValid)
     
    509499        ULONG displayWidth, displayHeight;
    510500        /* Takes the display lock */
    511         HRESULT rc = pDisplay->GetScreenResolution(0, &displayWidth, &displayHeight,
    512                                                    NULL);
     501        HRESULT rc = pDisplay->GetScreenResolution(0, &displayWidth,
     502                                                   &displayHeight, NULL);
    513503        if (FAILED(rc))
    514504            return rc;
    515505
    516         *pcX = displayWidth ? (x * MOUSE_RANGE + ADJUST_RANGE) / (LONG) displayWidth: 0;
    517         *pcY = displayHeight ? (y * MOUSE_RANGE + ADJUST_RANGE) / (LONG) displayHeight: 0;
     506        *pcX = displayWidth ?    (x * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
     507                               / (LONG) displayWidth: 0;
     508        *pcY = displayHeight ?   (y * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
     509                               / (LONG) displayHeight: 0;
    518510    }
    519511    else
     
    522514        /* Takes the display lock */
    523515        pDisplay->getFramebufferDimensions(&x1, &y1, &x2, &y2);
    524         *pcX = x1 < x2 ? ((x - x1) * MOUSE_RANGE + ADJUST_RANGE) / (x2 - x1) : 0;
    525         *pcY = y1 < y2 ? ((y - y1) * MOUSE_RANGE + ADJUST_RANGE) / (y2 - y1) : 0;
    526         if (   *pcX < MOUSE_RANGE_LOWER || *pcX > MOUSE_RANGE_UPPER
    527             || *pcY < MOUSE_RANGE_LOWER || *pcY > MOUSE_RANGE_UPPER)
     516        *pcX = x1 < x2 ?   ((x - x1) * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
     517                         / (x2 - x1) : 0;
     518        *pcY = y1 < y2 ?   ((y - y1) * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
     519                         / (y2 - y1) : 0;
     520        if (   *pcX < VMMDEV_MOUSE_RANGE_MIN || *pcX > VMMDEV_MOUSE_RANGE_MAX
     521            || *pcY < VMMDEV_MOUSE_RANGE_MIN || *pcY > VMMDEV_MOUSE_RANGE_MAX)
    528522            if (pfValid)
    529523                *pfValid = false;
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