VirtualBox

Changeset 38590 in vbox


Ignore:
Timestamp:
Aug 31, 2011 7:36:39 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73785
Message:

Main/MouseImpl: try to send absolute position data that both Windows and (recent) X.Org guests interpret corrently

File:
1 edited

Legend:

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

    r38271 r38590  
    480480 * validity value to false if the pair is not on an active screen and to true
    481481 * otherwise.
     482 * @note      since guests with recent versions of X.Org use a different method
     483 *            to everyone else to map the valuator value to a screen pixel (they
     484 *            multiply by the screen dimension, do a floating point divide by
     485 *            the valuator maximum and round the result, while everyone else
     486 *            does truncating integer operations) we adjust the value we send
     487 *            so that it maps to the right pixel both when the result is rounded
     488 *            and when it is truncated.
    482489 *
    483490 * @returns   COM status value
     
    491498    Display *pDisplay = mParent->getDisplay();
    492499    ComAssertRet(pDisplay, E_FAIL);
     500    /** The amount to add to the result (multiplied by the screen width/height)
     501     * to compensate for differences in guest methods for mapping back to
     502     * pixels */
     503    enum { ADJUST_RANGE = - 3 * MOUSE_RANGE / 4 };
    493504
    494505    if (pfValid)
     
    503514            return rc;
    504515
    505         *pcX = displayWidth ? (x * MOUSE_RANGE - MOUSE_RANGE / 2) / (LONG) displayWidth: 0;
    506         *pcY = displayHeight ? (y * MOUSE_RANGE - MOUSE_RANGE / 2) / (LONG) displayHeight: 0;
     516        *pcX = displayWidth ? (x * MOUSE_RANGE + ADJUST_RANGE) / (LONG) displayWidth: 0;
     517        *pcY = displayHeight ? (y * MOUSE_RANGE + ADJUST_RANGE) / (LONG) displayHeight: 0;
    507518    }
    508519    else
     
    511522        /* Takes the display lock */
    512523        pDisplay->getFramebufferDimensions(&x1, &y1, &x2, &y2);
    513         *pcX = x1 < x2 ? ((x - x1) * MOUSE_RANGE - MOUSE_RANGE / 2) / (x2 - x1) : 0;
    514         *pcY = y1 < y2 ? ((y - y1) * MOUSE_RANGE - MOUSE_RANGE / 2) / (y2 - y1) : 0;
     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;
    515526        if (   *pcX < MOUSE_RANGE_LOWER || *pcX > MOUSE_RANGE_UPPER
    516527            || *pcY < MOUSE_RANGE_LOWER || *pcY > MOUSE_RANGE_UPPER)
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