VirtualBox

Changeset 47795 in vbox


Ignore:
Timestamp:
Aug 16, 2013 10:28:44 AM (11 years ago)
Author:
vboxsync
Message:

MouseImpl: map touch events to the primary monitor.

File:
1 edited

Legend:

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

    r47774 r47795  
    712712    ComAssertRet(pDisplay, E_FAIL);
    713713
    714     HRESULT rc = S_OK;
     714    /* Touch events are mapped to the primary monitor, because the emulated USB
     715     * touchscreen device is associated with one (normally the primary) screen in the guest.
     716     */
     717    ULONG uScreenId = 0;
     718
     719    ULONG cWidth  = 0;
     720    ULONG cHeight = 0;
     721    LONG  xOrigin = 0;
     722    LONG  yOrigin = 0;
     723    HRESULT rc = pDisplay->getScreenResolution(uScreenId, &cWidth, &cHeight, NULL, &xOrigin, &yOrigin);
     724    ComAssertComRCRetRC(rc);
    715725
    716726    uint64_t* pau64Contacts = NULL;
     
    724734        if (pau64Contacts)
    725735        {
    726             int32_t x1, y1, x2, y2;
    727             /* Takes the display lock */
    728             pDisplay->getFramebufferDimensions(&x1, &y1, &x2, &y2);
     736            int32_t x1 = xOrigin;
     737            int32_t y1 = yOrigin;
     738            int32_t x2 = x1 + cWidth;
     739            int32_t y2 = y1 + cHeight;
     740
     741            LogRel3(("%s: screen %d,%d %d,%d\n",
     742                     __FUNCTION__, x1, y1, x2, y2));
    729743
    730744            LONG i;
     
    742756                         __FUNCTION__, i, x, y, contactId, fInContact, fInRange));
    743757
    744                 /* Framebuffer dimensions are 0,0 width, height, that is x2,y2 are exclusive,
     758                /* Screen dimensions are 0,0 width, height, that is x2,y2 are exclusive,
    745759                 * while coords are inclusive.
    746760                 */
    747                 int32_t xAdj = x1 < x2 ?   ((x - 1 - x1) * VMMDEV_MOUSE_RANGE)
    748                                          / (x2 - x1) : 0;
    749                 int32_t yAdj = y1 < y2 ?   ((y - 1 - y1) * VMMDEV_MOUSE_RANGE)
    750                                          / (y2 - y1) : 0;
     761                if (x < x1 || x >= x2 || y < y1 || y >= y2)
     762                {
     763                    /* Out of range. Skip the contact. */
     764                    continue;
     765                }
     766
     767                int32_t xAdj = x1 < x2? ((x - 1 - x1) * VMMDEV_MOUSE_RANGE) / (x2 - x1) : 0;
     768                int32_t yAdj = y1 < y2? ((y - 1 - y1) * VMMDEV_MOUSE_RANGE) / (y2 - y1) : 0;
    751769
    752770                bool fValid = (   xAdj >= VMMDEV_MOUSE_RANGE_MIN
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