Index: /trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp	(revision 85920)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp	(revision 85921)
@@ -578,6 +578,6 @@
 
     /* Atom / HGCM formatting helpers. */
-    int             appendToAtomList(const RTCList<RTCString> &lstFormats, VBoxDnDAtomList &lstAtoms) const;
-    int             appendToAtomList(const void *pvData, uint32_t cbData, VBoxDnDAtomList &lstAtoms) const;
+    int             appendFormatsToList(const RTCList<RTCString> &lstFormats, VBoxDnDAtomList &lstAtoms) const;
+    int             appendDataToList(const void *pvData, uint32_t cbData, VBoxDnDAtomList &lstAtoms) const;
     static Atom     toAtomAction(VBOXDNDACTION dndAction);
     static int      toAtomActions(VBOXDNDACTIONLIST dndActionList, VBoxDnDAtomList &lstAtoms);
@@ -607,7 +607,7 @@
     long                        m_curVer;
     /** List of (Atom) formats the source window supports. */
-    VBoxDnDAtomList             m_lstFormats;
+    VBoxDnDAtomList             m_lstAtomFormats;
     /** List of (Atom) actions the source window supports. */
-    VBoxDnDAtomList             m_lstActions;
+    VBoxDnDAtomList             m_lstAtomActions;
     /** Buffer for answering the target window's selection request. */
     void                       *m_pvSelReqData;
@@ -747,7 +747,14 @@
         wndXDnDClearActionList(m_wndProxy.hWnd);
 
-        /* Reset the internal state. */
-        m_lstActions.clear();
-        m_lstFormats.clear();
+        m_lstAtomActions.clear();
+
+        /* First, clear the formats list. */
+        m_lstAtomFormats.clear();
+        /* Append default targets we support.
+         * Note: The order is sorted by preference; be careful when changing this. */
+        m_lstAtomFormats.append(xAtom(XA_TARGETS));
+        m_lstAtomFormats.append(xAtom(XA_MULTIPLE));
+        /** @todo Support INC (incremental transfers). */
+
         m_wndCur    = 0;
         m_curVer    = -1;
@@ -1045,5 +1052,5 @@
                         {
                             LogFlowThisFunc(("\t%s\n", gX11->xAtomToString(e.xclient.data.l[i]).c_str()));
-                            m_lstFormats.append(e.xclient.data.l[i]);
+                            m_lstAtomFormats.append(e.xclient.data.l[i]);
                         }
                     }
@@ -1051,5 +1058,5 @@
                     {
                         /* More than 3 format types supported. */
-                        rc = wndXDnDGetFormatList(wndSelection, m_lstFormats);
+                        rc = wndXDnDGetFormatList(wndSelection, m_lstAtomFormats);
                     }
 
@@ -1061,8 +1068,8 @@
                         if (m_curVer >= 2) /* More than one action allowed since protocol version 2. */
                         {
-                            rc = wndXDnDGetActionList(wndSelection, m_lstActions);
+                            rc = wndXDnDGetActionList(wndSelection, m_lstAtomActions);
                         }
                         else /* Only "copy" action allowed on legacy applications. */
-                            m_lstActions.append(XA_XdndActionCopy);
+                            m_lstAtomActions.append(XA_XdndActionCopy);
                     }
 
@@ -1296,6 +1303,6 @@
 #ifdef DEBUG
             LogFlowFunc(("Supported formats:\n"));
-            for (size_t i = 0; i < m_lstFormats.size(); i++)
-                LogFlowFunc(("\t%s\n", xAtomToString(m_lstFormats.at(i)).c_str()));
+            for (size_t i = 0; i < m_lstAtomFormats.size(); i++)
+                LogFlowFunc(("\t%s\n", xAtomToString(m_lstAtomFormats.at(i)).c_str()));
 #endif
             /* Is the requestor asking for the possible MIME types? */
@@ -1306,10 +1313,10 @@
                 /* If so, set the window property with the formats on the requestor
                  * window. */
-                rc = wndXDnDSetFormatList(pEvReq->requestor, pEvReq->property, m_lstFormats);
+                rc = wndXDnDSetFormatList(pEvReq->requestor, pEvReq->property, m_lstAtomFormats);
                 if (RT_SUCCESS(rc))
                     pEvResp->property = pEvReq->property;
             }
             /* Is the requestor asking for a specific MIME type (we support)? */
-            else if (m_lstFormats.contains(pEvReq->target))
+            else if (m_lstAtomFormats.contains(pEvReq->target))
             {
                 VBClLogInfo("Target window %#x ('%s') is asking for data as '%s'\n",
@@ -1628,18 +1635,13 @@
         /* Check if the VM session has changed and reconnect to the HGCM service if necessary. */
         rc = checkForSessionChange();
-        if (RT_FAILURE(rc))
-            break;
-
-        rc = appendToAtomList(lstFormats, m_lstFormats);
-        if (RT_FAILURE(rc))
-            break;
-
-        /* If we have more than 3 formats we have to use the type list extension. */
-        if (m_lstFormats.size() > 3)
-        {
-            rc = wndXDnDSetFormatList(m_wndProxy.hWnd, xAtom(XA_XdndTypeList), m_lstFormats);
-            if (RT_FAILURE(rc))
-                break;
-        }
+        AssertRCBreak(rc);
+
+        /* Append all actual (MIME) formats we support to the list.
+         * These must come last, after the default Atoms above. */
+        rc = appendFormatsToList(lstFormats, m_lstAtomFormats);
+        AssertRCBreak(rc);
+
+        rc = wndXDnDSetFormatList(m_wndProxy.hWnd, xAtom(XA_XdndTypeList), m_lstAtomFormats);
+        AssertRCBreak(rc);
 
         /* Announce the possible actions. */
@@ -1812,12 +1814,12 @@
         m.data.l[XdndEnterFlags]  = RT_MAKE_U32_FROM_U8(
                                     /* Bit 0 is set if the source supports more than three data types. */
-                                    m_lstFormats.size() > 3 ? RT_BIT(0) : 0,
+                                    m_lstAtomFormats.size() > 3 ? RT_BIT(0) : 0,
                                     /* Reserved for future use. */
                                     0, 0,
                                     /* Protocol version to use. */
                                     RT_MIN(VBOX_XDND_VERSION, newVer));
-        m.data.l[XdndEnterType1]  = m_lstFormats.value(0, None); /* First data type to use. */
-        m.data.l[XdndEnterType2]  = m_lstFormats.value(1, None); /* Second data type to use. */
-        m.data.l[XdndEnterType3]  = m_lstFormats.value(2, None); /* Third data type to use. */
+        m.data.l[XdndEnterType1]  = m_lstAtomFormats.value(0, None); /* First data type to use. */
+        m.data.l[XdndEnterType2]  = m_lstAtomFormats.value(1, None); /* Second data type to use. */
+        m.data.l[XdndEnterType3]  = m_lstAtomFormats.value(2, None); /* Third data type to use. */
 
         xRc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
@@ -2165,5 +2167,5 @@
     if (RT_SUCCESS(rc2))
     {
-        RTCString strFormatsCur = gX11->xAtomListToString(m_lstFormats);
+        RTCString strFormatsCur = gX11->xAtomListToString(m_lstAtomFormats);
         if (!strFormatsCur.isEmpty())
         {
@@ -2171,5 +2173,5 @@
             dndActionDefault = VBOX_DND_ACTION_COPY; /** @todo Handle default action! */
             dndActionList    = VBOX_DND_ACTION_COPY; /** @todo Ditto. */
-            dndActionList   |= toHGCMActions(m_lstActions);
+            dndActionList   |= toHGCMActions(m_lstAtomActions);
         }
 
@@ -2816,9 +2818,4 @@
         return VERR_INVALID_PARAMETER;
 
-    /* We support TARGETS and the data types. */
-    VBoxDnDAtomList lstFormatsExt(lstFormats.size() + 1);
-    lstFormatsExt.append(xAtom(XA_TARGETS));
-    lstFormatsExt.append(lstFormats);
-
     /* Add the property with the property data to the window. */
     XChangeProperty(m_pDisplay, wndThis, atmProp,
@@ -2837,5 +2834,5 @@
  * @param   lstAtoms                Reference to VBoxDnDAtomList list to store results in.
  */
-int DragInstance::appendToAtomList(const RTCList<RTCString> &lstFormats, VBoxDnDAtomList &lstAtoms) const
+int DragInstance::appendFormatsToList(const RTCList<RTCString> &lstFormats, VBoxDnDAtomList &lstAtoms) const
 {
     for (size_t i = 0; i < lstFormats.size(); ++i)
@@ -2853,5 +2850,5 @@
  * @param   lstAtoms                Reference to VBoxDnDAtomList list to store results in.
  */
-int DragInstance::appendToAtomList(const void *pvData, uint32_t cbData, VBoxDnDAtomList &lstAtoms) const
+int DragInstance::appendDataToList(const void *pvData, uint32_t cbData, VBoxDnDAtomList &lstAtoms) const
 {
     RT_NOREF1(lstAtoms);
