VirtualBox

Changeset 85921 in vbox


Ignore:
Timestamp:
Aug 28, 2020 9:57:19 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
140110
Message:

DnD/X11: Cleaned up internal Atom actions / formats list handling.

File:
1 edited

Legend:

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

    r85920 r85921  
    578578
    579579    /* Atom / HGCM formatting helpers. */
    580     int             appendToAtomList(const RTCList<RTCString> &lstFormats, VBoxDnDAtomList &lstAtoms) const;
    581     int             appendToAtomList(const void *pvData, uint32_t cbData, VBoxDnDAtomList &lstAtoms) const;
     580    int             appendFormatsToList(const RTCList<RTCString> &lstFormats, VBoxDnDAtomList &lstAtoms) const;
     581    int             appendDataToList(const void *pvData, uint32_t cbData, VBoxDnDAtomList &lstAtoms) const;
    582582    static Atom     toAtomAction(VBOXDNDACTION dndAction);
    583583    static int      toAtomActions(VBOXDNDACTIONLIST dndActionList, VBoxDnDAtomList &lstAtoms);
     
    607607    long                        m_curVer;
    608608    /** List of (Atom) formats the source window supports. */
    609     VBoxDnDAtomList             m_lstFormats;
     609    VBoxDnDAtomList             m_lstAtomFormats;
    610610    /** List of (Atom) actions the source window supports. */
    611     VBoxDnDAtomList             m_lstActions;
     611    VBoxDnDAtomList             m_lstAtomActions;
    612612    /** Buffer for answering the target window's selection request. */
    613613    void                       *m_pvSelReqData;
     
    747747        wndXDnDClearActionList(m_wndProxy.hWnd);
    748748
    749         /* Reset the internal state. */
    750         m_lstActions.clear();
    751         m_lstFormats.clear();
     749        m_lstAtomActions.clear();
     750
     751        /* First, clear the formats list. */
     752        m_lstAtomFormats.clear();
     753        /* Append default targets we support.
     754         * Note: The order is sorted by preference; be careful when changing this. */
     755        m_lstAtomFormats.append(xAtom(XA_TARGETS));
     756        m_lstAtomFormats.append(xAtom(XA_MULTIPLE));
     757        /** @todo Support INC (incremental transfers). */
     758
    752759        m_wndCur    = 0;
    753760        m_curVer    = -1;
     
    10451052                        {
    10461053                            LogFlowThisFunc(("\t%s\n", gX11->xAtomToString(e.xclient.data.l[i]).c_str()));
    1047                             m_lstFormats.append(e.xclient.data.l[i]);
     1054                            m_lstAtomFormats.append(e.xclient.data.l[i]);
    10481055                        }
    10491056                    }
     
    10511058                    {
    10521059                        /* More than 3 format types supported. */
    1053                         rc = wndXDnDGetFormatList(wndSelection, m_lstFormats);
     1060                        rc = wndXDnDGetFormatList(wndSelection, m_lstAtomFormats);
    10541061                    }
    10551062
     
    10611068                        if (m_curVer >= 2) /* More than one action allowed since protocol version 2. */
    10621069                        {
    1063                             rc = wndXDnDGetActionList(wndSelection, m_lstActions);
     1070                            rc = wndXDnDGetActionList(wndSelection, m_lstAtomActions);
    10641071                        }
    10651072                        else /* Only "copy" action allowed on legacy applications. */
    1066                             m_lstActions.append(XA_XdndActionCopy);
     1073                            m_lstAtomActions.append(XA_XdndActionCopy);
    10671074                    }
    10681075
     
    12961303#ifdef DEBUG
    12971304            LogFlowFunc(("Supported formats:\n"));
    1298             for (size_t i = 0; i < m_lstFormats.size(); i++)
    1299                 LogFlowFunc(("\t%s\n", xAtomToString(m_lstFormats.at(i)).c_str()));
     1305            for (size_t i = 0; i < m_lstAtomFormats.size(); i++)
     1306                LogFlowFunc(("\t%s\n", xAtomToString(m_lstAtomFormats.at(i)).c_str()));
    13001307#endif
    13011308            /* Is the requestor asking for the possible MIME types? */
     
    13061313                /* If so, set the window property with the formats on the requestor
    13071314                 * window. */
    1308                 rc = wndXDnDSetFormatList(pEvReq->requestor, pEvReq->property, m_lstFormats);
     1315                rc = wndXDnDSetFormatList(pEvReq->requestor, pEvReq->property, m_lstAtomFormats);
    13091316                if (RT_SUCCESS(rc))
    13101317                    pEvResp->property = pEvReq->property;
    13111318            }
    13121319            /* Is the requestor asking for a specific MIME type (we support)? */
    1313             else if (m_lstFormats.contains(pEvReq->target))
     1320            else if (m_lstAtomFormats.contains(pEvReq->target))
    13141321            {
    13151322                VBClLogInfo("Target window %#x ('%s') is asking for data as '%s'\n",
     
    16281635        /* Check if the VM session has changed and reconnect to the HGCM service if necessary. */
    16291636        rc = checkForSessionChange();
    1630         if (RT_FAILURE(rc))
    1631             break;
    1632 
    1633         rc = appendToAtomList(lstFormats, m_lstFormats);
    1634         if (RT_FAILURE(rc))
    1635             break;
    1636 
    1637         /* If we have more than 3 formats we have to use the type list extension. */
    1638         if (m_lstFormats.size() > 3)
    1639         {
    1640             rc = wndXDnDSetFormatList(m_wndProxy.hWnd, xAtom(XA_XdndTypeList), m_lstFormats);
    1641             if (RT_FAILURE(rc))
    1642                 break;
    1643         }
     1637        AssertRCBreak(rc);
     1638
     1639        /* Append all actual (MIME) formats we support to the list.
     1640         * These must come last, after the default Atoms above. */
     1641        rc = appendFormatsToList(lstFormats, m_lstAtomFormats);
     1642        AssertRCBreak(rc);
     1643
     1644        rc = wndXDnDSetFormatList(m_wndProxy.hWnd, xAtom(XA_XdndTypeList), m_lstAtomFormats);
     1645        AssertRCBreak(rc);
    16441646
    16451647        /* Announce the possible actions. */
     
    18121814        m.data.l[XdndEnterFlags]  = RT_MAKE_U32_FROM_U8(
    18131815                                    /* Bit 0 is set if the source supports more than three data types. */
    1814                                     m_lstFormats.size() > 3 ? RT_BIT(0) : 0,
     1816                                    m_lstAtomFormats.size() > 3 ? RT_BIT(0) : 0,
    18151817                                    /* Reserved for future use. */
    18161818                                    0, 0,
    18171819                                    /* Protocol version to use. */
    18181820                                    RT_MIN(VBOX_XDND_VERSION, newVer));
    1819         m.data.l[XdndEnterType1]  = m_lstFormats.value(0, None); /* First data type to use. */
    1820         m.data.l[XdndEnterType2]  = m_lstFormats.value(1, None); /* Second data type to use. */
    1821         m.data.l[XdndEnterType3]  = m_lstFormats.value(2, None); /* Third data type to use. */
     1821        m.data.l[XdndEnterType1]  = m_lstAtomFormats.value(0, None); /* First data type to use. */
     1822        m.data.l[XdndEnterType2]  = m_lstAtomFormats.value(1, None); /* Second data type to use. */
     1823        m.data.l[XdndEnterType3]  = m_lstAtomFormats.value(2, None); /* Third data type to use. */
    18221824
    18231825        xRc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
     
    21652167    if (RT_SUCCESS(rc2))
    21662168    {
    2167         RTCString strFormatsCur = gX11->xAtomListToString(m_lstFormats);
     2169        RTCString strFormatsCur = gX11->xAtomListToString(m_lstAtomFormats);
    21682170        if (!strFormatsCur.isEmpty())
    21692171        {
     
    21712173            dndActionDefault = VBOX_DND_ACTION_COPY; /** @todo Handle default action! */
    21722174            dndActionList    = VBOX_DND_ACTION_COPY; /** @todo Ditto. */
    2173             dndActionList   |= toHGCMActions(m_lstActions);
     2175            dndActionList   |= toHGCMActions(m_lstAtomActions);
    21742176        }
    21752177
     
    28162818        return VERR_INVALID_PARAMETER;
    28172819
    2818     /* We support TARGETS and the data types. */
    2819     VBoxDnDAtomList lstFormatsExt(lstFormats.size() + 1);
    2820     lstFormatsExt.append(xAtom(XA_TARGETS));
    2821     lstFormatsExt.append(lstFormats);
    2822 
    28232820    /* Add the property with the property data to the window. */
    28242821    XChangeProperty(m_pDisplay, wndThis, atmProp,
     
    28372834 * @param   lstAtoms                Reference to VBoxDnDAtomList list to store results in.
    28382835 */
    2839 int DragInstance::appendToAtomList(const RTCList<RTCString> &lstFormats, VBoxDnDAtomList &lstAtoms) const
     2836int DragInstance::appendFormatsToList(const RTCList<RTCString> &lstFormats, VBoxDnDAtomList &lstAtoms) const
    28402837{
    28412838    for (size_t i = 0; i < lstFormats.size(); ++i)
     
    28532850 * @param   lstAtoms                Reference to VBoxDnDAtomList list to store results in.
    28542851 */
    2855 int DragInstance::appendToAtomList(const void *pvData, uint32_t cbData, VBoxDnDAtomList &lstAtoms) const
     2852int DragInstance::appendDataToList(const void *pvData, uint32_t cbData, VBoxDnDAtomList &lstAtoms) const
    28562853{
    28572854    RT_NOREF1(lstAtoms);
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