VirtualBox

Ignore:
Timestamp:
Sep 24, 2018 12:30:47 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
125282
Message:

DnD: Added typedefs for DNDACTION and DNDACTIONLIST to emphasize usage, did some renaming to clean things up.

File:
1 edited

Legend:

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

    r74411 r74439  
    440440    void destroy();
    441441
    442     int sendFinished(Window hWndSource, uint32_t uAction);
     442    int sendFinished(Window hWndSource, VBOXDNDACTION dndAction);
    443443
    444444public:
     
    504504
    505505    /* Host -> Guest handling. */
    506     int hgEnter(const RTCList<RTCString> &formats, uint32_t actions);
     506    int hgEnter(const RTCList<RTCString> &formats, VBOXDNDACTIONLIST dndListActionsAllowed);
    507507    int hgLeave(void);
    508     int hgMove(uint32_t uPosX, uint32_t uPosY, uint32_t uDefaultAction);
    509     int hgDrop(uint32_t uPosX, uint32_t uPosY, uint32_t uDefaultAction);
     508    int hgMove(uint32_t uPosX, uint32_t uPosY, VBOXDNDACTION dndActionDefault);
     509    int hgDrop(uint32_t uPosX, uint32_t uPosY, VBOXDNDACTION dndActionDefault);
    510510    int hgDataReceive(PVBGLR3GUESTDNDMETADATA pMetaData);
    511511
     
    537537    int             toAtomList(const RTCList<RTCString> &lstFormats, VBoxDnDAtomList &lstAtoms) const;
    538538    int             toAtomList(const void *pvData, uint32_t cbData, VBoxDnDAtomList &lstAtoms) const;
    539     static Atom     toAtomAction(uint32_t uAction);
    540     static int      toAtomActions(uint32_t uActions, VBoxDnDAtomList &lstAtoms);
     539    static Atom     toAtomAction(VBOXDNDACTION dndAction);
     540    static int      toAtomActions(VBOXDNDACTIONLIST dndActionList, VBoxDnDAtomList &lstAtoms);
    541541    static uint32_t toHGCMAction(Atom atom);
    542542    static uint32_t toHGCMActions(const VBoxDnDAtomList &actionsList);
     
    950950                LogFlowThisFunc(("\tReported dead area: x=%RU16, y=%RU16, cx=%RU16, cy=%RU16\n", x, y, cx, cy));
    951951#endif
    952 
    953                 uint32_t uAction = VBOX_DND_ACTION_IGNORE; /* Default is ignoring. */
     952                VBOXDNDACTION dndAction = VBOX_DND_ACTION_IGNORE; /* Default is ignoring. */
    954953                /** @todo Compare this with the allowed actions. */
    955954                if (fAcceptDrop)
    956                     uAction = toHGCMAction(static_cast<Atom>(e.xclient.data.l[XdndStatusAction]));
    957 
    958                 rc = VbglR3DnDHGSendAckOp(&m_dndCtx, uAction);
     955                    dndAction = toHGCMAction(static_cast<Atom>(e.xclient.data.l[XdndStatusAction]));
     956
     957                rc = VbglR3DnDHGSendAckOp(&m_dndCtx, dndAction);
    959958            }
    960959            else if (e.xclient.message_type == xAtom(XA_XdndFinished))
     
    15941593 * @returns IPRT status code.
    15951594 * @param   lstFormats              List of supported formats from the host.
    1596  * @param   uActions                (ORed) List of supported actions from the host.
    1597  */
    1598 int DragInstance::hgEnter(const RTCList<RTCString> &lstFormats, uint32_t uActions)
     1595 * @param   dndListActionsAllowed   (ORed) List of supported actions from the host.
     1596 */
     1597int DragInstance::hgEnter(const RTCList<RTCString> &lstFormats, uint32_t dndListActionsAllowed)
    15991598{
    16001599    LogFlowThisFunc(("mode=%RU32, state=%RU32\n", m_enmMode, m_enmState));
     
    16061605
    16071606#ifdef DEBUG
    1608     LogFlowThisFunc(("uActions=0x%x, lstFormats=%zu: ", uActions, lstFormats.size()));
     1607    LogFlowThisFunc(("dndListActionsAllowed=0x%x, lstFormats=%zu: ", dndListActionsAllowed, lstFormats.size()));
    16091608    for (size_t i = 0; i < lstFormats.size(); ++i)
    16101609        LogFlow(("'%s' ", lstFormats.at(i).c_str()));
     
    16301629        /* Announce the possible actions. */
    16311630        VBoxDnDAtomList lstActions;
    1632         rc = toAtomActions(uActions, lstActions);
     1631        rc = toAtomActions(dndListActionsAllowed, lstActions);
    16331632        if (RT_FAILURE(rc))
    16341633            break;
     
    16671666 * @param   uPosX                   Relative X position within the guest's display area.
    16681667 * @param   uPosY                   Relative Y position within the guest's display area.
    1669  * @param   uDefaultAction          Default action the host wants to perform on the guest
     1668 * @param   dndActionDefault        Default action the host wants to perform on the guest
    16701669 *                                  as soon as the operation successfully finishes.
    16711670 */
    1672 int DragInstance::hgMove(uint32_t uPosX, uint32_t uPosY, uint32_t uDefaultAction)
     1671int DragInstance::hgMove(uint32_t uPosX, uint32_t uPosY, VBOXDNDACTION dndActionDefault)
    16731672{
    16741673    LogFlowThisFunc(("mode=%RU32, state=%RU32\n", m_enmMode, m_enmState));
    1675     LogFlowThisFunc(("uPosX=%RU32, uPosY=%RU32, uAction=%RU32\n", uPosX, uPosY, uDefaultAction));
     1674    LogFlowThisFunc(("uPosX=%RU32, uPosY=%RU32, dndActionDefault=%RU32\n", uPosX, uPosY, dndActionDefault));
    16761675
    16771676    if (   m_enmMode  != HG
     
    18201819         * Send a XdndPosition event with the proposed action to the guest.
    18211820         */
    1822         Atom pa = toAtomAction(uDefaultAction);
     1821        Atom pa = toAtomAction(dndActionDefault);
    18231822        LogFlowThisFunc(("strAction=%s\n", xAtomToString(pa).c_str()));
    18241823
     
    18631862 * @param   uPosX                   Relative X position within the guest's display area.
    18641863 * @param   uPosY                   Relative Y position within the guest's display area.
    1865  * @param   uDefaultAction          Default action the host wants to perform on the guest
     1864 * @param   dndActionDefault        Default action the host wants to perform on the guest
    18661865 *                                  as soon as the operation successfully finishes.
    18671866 */
    1868 int DragInstance::hgDrop(uint32_t uPosX, uint32_t uPosY, uint32_t uDefaultAction)
    1869 {
    1870     RT_NOREF3(uPosX, uPosY, uDefaultAction);
     1867int DragInstance::hgDrop(uint32_t uPosX, uint32_t uPosY, VBOXDNDACTION dndActionDefault)
     1868{
     1869    RT_NOREF3(uPosX, uPosY, dndActionDefault);
    18711870    LogFlowThisFunc(("wndCur=%RU32, wndProxy=%RU32, mode=%RU32, state=%RU32\n", m_wndCur, m_wndProxy.hWnd, m_enmMode, m_enmState));
    1872     LogFlowThisFunc(("uPosX=%RU32, uPosY=%RU32, uAction=%RU32\n", uPosX, uPosY, uDefaultAction));
     1871    LogFlowThisFunc(("uPosX=%RU32, uPosY=%RU32, dndActionDefault=%RU32\n", uPosX, uPosY, dndActionDefault));
    18731872
    18741873    if (   m_enmMode  != HG
     
    19951994
    19961995    RTCString strFormats = "\r\n"; /** @todo If empty, IOCTL fails with VERR_ACCESS_DENIED. */
    1997     uint32_t uDefAction = VBOX_DND_ACTION_IGNORE;
    1998     uint32_t uAllActions = VBOX_DND_ACTION_IGNORE;
     1996    VBOXDNDACTION     dndActionDefault = VBOX_DND_ACTION_IGNORE;
     1997    VBOXDNDACTIONLIST dndActionList    = VBOX_DND_ACTION_IGNORE;
    19991998
    20001999    /* Currently in wrong mode? Bail out. */
     
    20972096        {
    20982097            strFormats   = strFormatsCur;
    2099             uDefAction  = VBOX_DND_ACTION_COPY; /** @todo Handle default action! */
    2100             uAllActions  = VBOX_DND_ACTION_COPY; /** @todo Ditto. */
    2101             uAllActions |= toHGCMActions(m_lstActions);
     2098            dndActionDefault = VBOX_DND_ACTION_COPY; /** @todo Handle default action! */
     2099            dndActionList    = VBOX_DND_ACTION_COPY; /** @todo Ditto. */
     2100            dndActionList  |= toHGCMActions(m_lstActions);
    21022101        }
    21032102
     
    21052104    }
    21062105
    2107     rc2 = VbglR3DnDGHSendAckPending(&m_dndCtx, uDefAction, uAllActions,
     2106    rc2 = VbglR3DnDGHSendAckPending(&m_dndCtx, dndActionDefault, dndActionList,
    21082107                                    strFormats.c_str(), strFormats.length() + 1 /* Include termination */);
    2109     LogFlowThisFunc(("uClientID=%RU32, uDefAction=0x%x, allActions=0x%x, strFormats=%s, rc=%Rrc\n",
    2110                      m_dndCtx.uClientID, uDefAction, uAllActions, strFormats.c_str(), rc2));
     2108    LogFlowThisFunc(("uClientID=%RU32, uDefAction=0x%x, uLstActions=0x%x, strFormats=%s, rc=%Rrc\n",
     2109                     m_dndCtx.uClientID, dndActionDefault, dndActionList, strFormats.c_str(), rc2));
    21112110    if (RT_FAILURE(rc2))
    21122111    {
     
    28222821 *
    28232822 * @returns Converted Atom-based drag'n drop action.
    2824  * @param   uAction                 HGCM drag'n drop actions to convert.
     2823 * @param   dndAction               HGCM drag'n drop actions to convert.
    28252824 */
    28262825/* static */
    2827 Atom DragInstance::toAtomAction(uint32_t uAction)
     2826Atom DragInstance::toAtomAction(VBOXDNDACTION dndAction)
    28282827{
    28292828    /* Ignore is None. */
    2830     return (isDnDCopyAction(uAction) ? xAtom(XA_XdndActionCopy) :
    2831             isDnDMoveAction(uAction) ? xAtom(XA_XdndActionMove) :
    2832             isDnDLinkAction(uAction) ? xAtom(XA_XdndActionLink) :
     2829    return (isDnDCopyAction(dndAction) ? xAtom(XA_XdndActionCopy) :
     2830            isDnDMoveAction(dndAction) ? xAtom(XA_XdndActionMove) :
     2831            isDnDLinkAction(dndAction) ? xAtom(XA_XdndActionLink) :
    28332832            None);
    28342833}
     
    28382837 *
    28392838 * @returns IPRT status code.
    2840  * @param   uActions                HGCM drag'n drop actions to convert.
     2839 * @param   dndActionList           HGCM drag'n drop actions to convert.
    28412840 * @param   lstAtoms                Reference to VBoxDnDAtomList to store actions in.
    28422841 */
    28432842/* static */
    2844 int DragInstance::toAtomActions(uint32_t uActions, VBoxDnDAtomList &lstAtoms)
    2845 {
    2846     if (hasDnDCopyAction(uActions))
     2843int DragInstance::toAtomActions(VBOXDNDACTIONLIST dndActionList, VBoxDnDAtomList &lstAtoms)
     2844{
     2845    if (hasDnDCopyAction(dndActionList))
    28472846        lstAtoms.append(xAtom(XA_XdndActionCopy));
    2848     if (hasDnDMoveAction(uActions))
     2847    if (hasDnDMoveAction(dndActionList))
    28492848        lstAtoms.append(xAtom(XA_XdndActionMove));
    2850     if (hasDnDLinkAction(uActions))
     2849    if (hasDnDLinkAction(dndActionList))
    28512850        lstAtoms.append(xAtom(XA_XdndActionLink));
    28522851
     
    29292928}
    29302929
    2931 int VBoxDnDProxyWnd::sendFinished(Window hWndSource, uint32_t uAction)
     2930int VBoxDnDProxyWnd::sendFinished(Window hWndSource, VBOXDNDACTION dndAction)
    29322931{
    29332932    /* Was the drop accepted by the host? That is, anything than ignoring. */
    2934     bool fDropAccepted = uAction > VBOX_DND_ACTION_IGNORE;
    2935 
    2936     LogFlowFunc(("uAction=%RU32\n", uAction));
     2933    bool fDropAccepted = dndAction > VBOX_DND_ACTION_IGNORE;
     2934
     2935    LogFlowFunc(("dndAction=%RU32\n", dndAction));
    29372936
    29382937    /* Confirm the result of the transfer to the target window. */
     
    29442943    m.message_type = xAtom(XA_XdndFinished);
    29452944    m.format       = 32;
    2946     m.data.l[XdndFinishedWindow] = hWnd;                                                       /* Target window. */
    2947     m.data.l[XdndFinishedFlags]  = fDropAccepted ? RT_BIT(0) : 0;                              /* Was the drop accepted? */
    2948     m.data.l[XdndFinishedAction] = fDropAccepted ? DragInstance::toAtomAction(uAction) : None; /* Action used on accept. */
     2945    m.data.l[XdndFinishedWindow] = hWnd;                                                         /* Target window. */
     2946    m.data.l[XdndFinishedFlags]  = fDropAccepted ? RT_BIT(0) : 0;                                /* Was the drop accepted? */
     2947    m.data.l[XdndFinishedAction] = fDropAccepted ? DragInstance::toAtomAction(dndAction) : None; /* Action used on accept. */
    29492948
    29502949    int xRc = XSendEvent(pDisp, hWndSource, True, NoEventMask, reinterpret_cast<XEvent*>(&m));
     
    31113110                            RTCList<RTCString> lstFormats =
    31123111                                RTCString(pVbglR3Event->u.HG_Enter.pszFormats, pVbglR3Event->u.HG_Enter.cbFormats - 1).split("\r\n");
    3113                             rc = m_pCurDnD->hgEnter(lstFormats, pVbglR3Event->u.HG_Enter.uAllActions);
     3112                            rc = m_pCurDnD->hgEnter(lstFormats, pVbglR3Event->u.HG_Enter.dndLstActionsAllowed);
    31143113                            if (RT_FAILURE(rc))
    31153114                                break;
     
    31313130                    {
    31323131                        rc = m_pCurDnD->hgMove(pVbglR3Event->u.HG_Move.uXpos, pVbglR3Event->u.HG_Move.uYpos,
    3133                                                pVbglR3Event->u.HG_Move.uDefAction);
     3132                                               pVbglR3Event->u.HG_Move.dndActionDefault);
    31343133                        break;
    31353134                    }
     
    31443143                    {
    31453144                        rc = m_pCurDnD->hgDrop(pVbglR3Event->u.HG_Drop.uXpos, pVbglR3Event->u.HG_Drop.uYpos,
    3146                                                pVbglR3Event->u.HG_Drop.uDefAction);
     3145                                               pVbglR3Event->u.HG_Drop.dndActionDefault);
    31473146                        break;
    31483147                    }
     
    31843183                    case VBGLR3DNDEVENTTYPE_GH_DROP:
    31853184                    {
    3186                         rc = m_pCurDnD->ghDropped(pVbglR3Event->u.GH_Drop.pszFormat, pVbglR3Event->u.GH_Drop.uAction);
     3185                        rc = m_pCurDnD->ghDropped(pVbglR3Event->u.GH_Drop.pszFormat, pVbglR3Event->u.GH_Drop.dndActionRequested);
    31873186                        break;
    31883187                    }
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