Index: /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp	(revision 83627)
+++ /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp	(revision 83628)
@@ -25,4 +25,7 @@
 #include <iprt/assert.h>
 #include <iprt/asm.h>
+#include <iprt/process.h>
+#include <iprt/rand.h>
+#include <iprt/string.h>
 #include <iprt/thread.h>
 
@@ -45,4 +48,8 @@
     /** Shared clipboard client. */
     PSHCLCLIENT             pClient;
+    /** Random 64-bit number embedded into szGuestOwnershipFlavor. */
+    uint64_t                idGuestOwnership;
+    /** The guest ownership flavor (type) string. */
+    char                    szGuestOwnershipFlavor[64];
 } SHCLCONTEXT;
 
@@ -201,4 +208,29 @@
 #endif
 
+    SHCLCONTEXT *pCtx = pClient->State.pCtx;
+    ShClSvcLock();
+
+    /*
+     * Generate a unique flavor string for this format announcement.
+     */
+    uint64_t idFlavor = RTRandU64();
+    pCtx->idGuestOwnership = idFlavor;
+    RTStrPrintf(pCtx->szGuestOwnershipFlavor, sizeof(pCtx->szGuestOwnershipFlavor),
+                "org.virtualbox.sharedclipboard.%RTproc.%RX64", RTProcSelf(), idFlavor);
+
+    /*
+     * Empty the pasteboard and put our ownership indicator flavor there
+     * with the stringified formats as value.
+     */
+    char szValue[32];
+    RTStrPrintf(szValue, sizeof(szValue), "%#x", fFormats);
+
+    takePasteboardOwnership(pCtx->hPasteboard, pCtx->idGuestOwnership, pCtx->szGuestOwnershipFlavor, szValue);
+
+    ShClSvcUnlock();
+
+    /*
+     * Now, request the data from the guest.
+     */
     return ShClSvcDataReadRequest(pClient, fFormats, NULL /* pidEvent */);
 }
@@ -227,5 +259,5 @@
     ShClSvcLock();
 
-    writeToPasteboard(pClient->State.pCtx->hPasteboard, pvData, cbData, fFormat);
+    writeToPasteboard(pClient->State.pCtx->hPasteboard, pClient->State.pCtx->idGuestOwnership, pvData, cbData, fFormat);
 
     ShClSvcUnlock();
Index: /trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp	(revision 83627)
+++ /trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp	(revision 83628)
@@ -284,8 +284,66 @@
 
 /**
+ * Takes the ownership of the pasteboard.
+ *
+ * This is called when the other end reports available formats.
+ *
+ * @returns VBox status code.
+ * @param   hPasteboard         The pastboard handle (reference).
+ * @param   idOwnership         The ownership ID to use now.
+ * @param   pszOwnershipFlavor  The ownership indicator flavor
+ * @param   pszOwnershipValue   The ownership value (stringified format mask).
+ *
+ * @todo    Add fFormats so we can make promises about available formats at once
+ *          without needing to request any data first.  That might help on
+ *          flavor priority.
+ */
+int takePasteboardOwnership(PasteboardRef hPasteboard, uint64_t idOwnership,
+                            const char *pszOwnershipFlavor, const char *pszOwnershipValue)
+{
+    /*
+     * Clear the pasteboard and take ownership over it.
+     */
+    OSStatus orc = PasteboardClear(hPasteboard);
+    if (orc == 0)
+    {
+        /* For good measure. */
+        PasteboardSynchronize(hPasteboard);
+
+        /*
+         * Put the ownership flavor and value onto the clipboard.
+         */
+        CFDataRef hData = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)pszOwnershipValue, strlen(pszOwnershipValue));
+        if (hData)
+        {
+            CFStringRef hFlavor = CFStringCreateWithCString(kCFAllocatorDefault, pszOwnershipFlavor, kCFStringEncodingUTF8);
+            if (hFlavor)
+            {
+                orc = PasteboardPutItemFlavor(hPasteboard, (PasteboardItemID)idOwnership,
+                                              hFlavor, hData, kPasteboardFlavorNoFlags);
+                if (orc == 0)
+                    Log(("takePasteboardOwnership: idOwnership=%RX64 flavor=%s value=%s\n",
+                         idOwnership, pszOwnershipFlavor, pszOwnershipValue));
+                else
+                    Log(("takePasteboardOwnership: PasteboardPutItemFlavor -> %d (%#x)!\n", orc, orc));
+                CFRelease(hFlavor);
+            }
+            else
+                Log(("takePasteboardOwnership: CFStringCreateWithCString failed!\n"));
+            CFRelease(hData);
+        }
+        else
+            Log(("takePasteboardOwnership: CFDataCreate failed!\n"));
+    }
+    else
+        Log(("takePasteboardOwnership: PasteboardClear failed -> %d (%#x)\n", orc, orc));
+    return orc == 0 ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
+}
+
+/**
  * Write clipboard content to the host clipboard from the internal clipboard
  * structure.
  *
  * @param   pPasteboard    Reference to the global pasteboard.
+ * @param   idOwnership    The ownership ID.
  * @param   pv             The source buffer.
  * @param   cb             The size of the source buffer.
@@ -294,11 +352,7 @@
  * @returns IPRT status code.
  */
-int writeToPasteboard(PasteboardRef pPasteboard, void *pv, uint32_t cb, uint32_t fFormat)
+int writeToPasteboard(PasteboardRef pPasteboard, uint64_t idOwnership, void *pv, uint32_t cb, uint32_t fFormat)
 {
     Log(("writeToPasteboard: fFormat = %02X\n", fFormat));
-
-    /* Clear the pasteboard */
-    if (PasteboardClear(pPasteboard))
-        return VERR_NOT_SUPPORTED;
 
     /* Make sure all is in sync */
@@ -342,6 +396,4 @@
 
         CFDataRef textData = NULL;
-        /* Item id is 1. Nothing special here. */
-        PasteboardItemID itemId = (PasteboardItemID)1;
         /* Create a CData object which we could pass to the pasteboard */
         if ((textData = CFDataCreate(kCFAllocatorDefault,
@@ -349,7 +401,5 @@
         {
             /* Put the Utf-16 version to the pasteboard */
-            PasteboardPutItemFlavor(pPasteboard, itemId,
-                                    kUTTypeUTF16PlainText,
-                                    textData, 0);
+            PasteboardPutItemFlavor(pPasteboard, (PasteboardItemID)idOwnership, kUTTypeUTF16PlainText, textData, 0);
         }
         /* Create a Utf-8 version */
@@ -363,7 +413,5 @@
             {
                 /* Put the Utf-8 version to the pasteboard */
-                PasteboardPutItemFlavor(pPasteboard, itemId,
-                                        kUTTypeUTF8PlainText,
-                                        textData, 0);
+                PasteboardPutItemFlavor(pPasteboard, (PasteboardItemID)idOwnership, kUTTypeUTF8PlainText, textData, 0);
             }
             RTStrFree(pszDestText);
@@ -380,6 +428,4 @@
         size_t cbBmpSize;
         CFDataRef bmpData = NULL;
-        /* Item id is 1. Nothing special here. */
-        PasteboardItemID itemId = (PasteboardItemID)1;
 
         rc = ShClDibToBmp(pv, cb, &pBmp, &cbBmpSize);
@@ -391,7 +437,5 @@
             {
                 /* Put the Utf-8 version to the pasteboard */
-                PasteboardPutItemFlavor(pPasteboard, itemId,
-                                        kUTTypeBMP,
-                                        bmpData, 0);
+                PasteboardPutItemFlavor(pPasteboard, (PasteboardItemID)idOwnership, kUTTypeBMP, bmpData, 0);
             }
             RTMemFree(pBmp);
Index: /trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.h
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.h	(revision 83627)
+++ /trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.h	(revision 83628)
@@ -29,5 +29,7 @@
 int queryNewPasteboardFormats(PasteboardRef pPasteboard, uint32_t *pfFormats, bool *pfChanged);
 int readFromPasteboard(PasteboardRef pPasteboard, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcbActual);
-int writeToPasteboard(PasteboardRef pPasteboard, void *pv, uint32_t cb, uint32_t fFormat);
+int takePasteboardOwnership(PasteboardRef pPasteboard, uint64_t idOwnership,
+                            const char *pszOwnershipFlavor, const char *pszOwnershipValue);
+int writeToPasteboard(PasteboardRef pPasteboard, uint64_t idOwnership, void *pv, uint32_t cb, uint32_t fFormat);
 
 #endif /* !VBOX_INCLUDED_SRC_SharedClipboard_darwin_pasteboard_h */
