VirtualBox

Changeset 97739 in vbox


Ignore:
Timestamp:
Dec 5, 2022 8:33:18 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154800
Message:

DnD/VBoxClient: Save the (fake) mouse move coordinates in DragInstance::mouseCursorMove() to not send the same coordinates again to a target window + flush the display afterwards.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp

    r97738 r97739  
    588588
    589589    /* X11 helpers. */
    590     int  mouseCursorFakeMove(void) const;
    591     int  mouseCursorMove(int iPosX, int iPosY) const;
     590    int  mouseCursorFakeMove(void);
     591    int  mouseCursorMove(int iPosX, int iPosY);
    592592    void mouseButtonSet(Window wndDest, int rx, int ry, int iButton, bool fPress);
    593593    int proxyWinShow(int *piRootX = NULL, int *piRootY = NULL) const;
     
    634634     *  Set to 0 if not available / not set yet. */
    635635    uint8_t                     m_uXdndVer;
     636    /** Last mouse X position (in pixels, absolute to root window).
     637     *  Set to -1 if not set yet. */
     638    int                         m_lastMouseX;
     639    /** Last mouse Y position (in pixels, absolute to root window).
     640     *  Set to -1 if not set yet. */
     641    int                         m_lastMouseY;
    636642    /** List of (Atom) formats the current source/target window supports. */
    637643    VBoxDnDAtomList             m_lstAtomFormats;
     
    807813        /** @todo Support INC (incremental transfers). */
    808814
    809         m_wndCur   = 0;
    810         m_uXdndVer = 0;
    811         m_enmState = Initialized;
    812         m_enmMode  = Unknown;
     815        m_wndCur                 = 0;
     816        m_uXdndVer               = 0;
     817        m_lastMouseX             = -1;
     818        m_lastMouseY             = -1;
     819        m_enmState               = Initialized;
     820        m_enmMode                = Unknown;
     821        m_cFailedPendingAttempts = 0;
     822
    813823        m_eventQueueList.clear();
    814         m_cFailedPendingAttempts = 0;
    815824
    816825        /* Reset the selection request buffer. */
     
    25792588 * @returns IPRT status code.
    25802589 */
    2581 int DragInstance::mouseCursorFakeMove(void) const
     2590int DragInstance::mouseCursorFakeMove(void)
    25822591{
    25832592    int iScreenID = XDefaultScreen(m_pDisplay);
     
    26272636 * @param   iPosY                   Absolute Y coordinate.
    26282637 */
    2629 int DragInstance::mouseCursorMove(int iPosX, int iPosY) const
    2630 {
    2631     int iScreenID = XDefaultScreen(m_pDisplay);
     2638int DragInstance::mouseCursorMove(int iPosX, int iPosY)
     2639{
     2640    int const iScreenID = XDefaultScreen(m_pDisplay);
    26322641    /** @todo What about multiple screens? Test this! */
    26332642
    2634     const int iScrX = XDisplayWidth(m_pDisplay, iScreenID);
    2635     const int iScrY = XDisplayHeight(m_pDisplay, iScreenID);
    2636 
    2637     iPosX = RT_CLAMP(iPosX, 0, iScrX);
    2638     iPosY = RT_CLAMP(iPosY, 0, iScrY);
    2639 
    2640     LogFlowThisFunc(("iPosX=%d, iPosY=%d\n", iPosX, iPosY));
     2643    int const iScreenWidth  = XDisplayWidth (m_pDisplay, iScreenID);
     2644    int const iScreenHeight = XDisplayHeight(m_pDisplay, iScreenID);
     2645
     2646    iPosX = RT_CLAMP(iPosX, 0, iScreenWidth);
     2647    iPosY = RT_CLAMP(iPosY, 0, iScreenHeight);
     2648
     2649    /* Same mouse position as before? No need to do anything. */
     2650    if (   m_lastMouseX == iPosX
     2651        && m_lastMouseY == iPosY)
     2652    {
     2653        return VINF_SUCCESS;
     2654    }
     2655
     2656    LogFlowThisFunc(("iPosX=%d, iPosY=%d, m_wndRoot=%#x\n", iPosX, iPosY, m_wndRoot));
    26412657
    26422658    /* Move the guest pointer to the DnD position, so we can find the window
    26432659     * below that position. */
    2644     XWarpPointer(m_pDisplay, None, m_wndRoot, 0, 0, 0, 0, iPosX, iPosY);
     2660    int xRc = XWarpPointer(m_pDisplay, None, m_wndRoot, 0, 0, 0, 0, iPosX, iPosY);
     2661    if (xRc == Success)
     2662    {
     2663        XFlush(m_pDisplay);
     2664
     2665        m_lastMouseX = iPosX;
     2666        m_lastMouseY = iPosY;
     2667    }
     2668    else
     2669        VBClLogError("Moving mouse cursor failed: %s", gX11->xErrorToString(xRc).c_str());
     2670
    26452671    return VINF_SUCCESS;
    26462672}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette