VirtualBox

Changeset 4711 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Sep 11, 2007 1:49:44 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
24381
Message:

Fixed a shared clipboard problem on Windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxService/VBoxClipboard.cpp

    r4071 r4711  
    2020#include <VBox/HostServices/VBoxClipboardSvc.h>
    2121#include "helpers.h"
     22#include <iprt/asm.h>
    2223
    2324typedef struct _VBOXCLIPBOARDCONTEXT
     
    3839//    uint64_t u64LastSentCRC64;
    3940   
    40     bool     fAnnouncing;
     41    volatile uint32_t u32Announcing;
    4142
    4243} VBOXCLIPBOARDCONTEXT;
     
    335336            dprintf (("vboxClipboardProcessMsg: WM_DRAWCLIPBOARD, hwnd %p\n", pCtx->hwnd));
    336337
    337             if (!pCtx->fAnnouncing)
    338             {
     338            if (ASMAtomicCmpXchgU32 (&pCtx->u32Announcing, 0, 1) == false)
     339            {
     340                /* Could not do 1->0 transition. That means u32Announcing is 0. */
    339341                vboxClipboardChanged (pCtx);
    340342            }
     
    356358            UINT format = (UINT)wParam;
    357359
     360            dprintf (("vboxClipboardProcessMsg: WM_RENDERFORMAT, format %x\n", format));
     361           
    358362            switch (format)
    359363            {
     
    518522            uint32_t u32Formats = (uint32_t)lParam;
    519523           
    520             /* Prevent the WM_DRAWCLIPBOARD processing. */
    521             pCtx->fAnnouncing = true;
    522 
    523524            if (OpenClipboard (hwnd))
    524525            {
     
    530531                {
    531532                    dprintf(("window proc WM_USER: VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT\n"));
    532                     hClip = SetClipboardData (CF_UNICODETEXT, NULL);
     533                   
     534                    /* Prevent the WM_DRAWCLIPBOARD processing. Will be reset in WM_DRAWCLIPBOARD. */
     535                    if (ASMAtomicCmpXchgU32 (&pCtx->u32Announcing, 1, 0) == true)
     536                    {
     537                        hClip = SetClipboardData (CF_UNICODETEXT, NULL);
     538                    }
    533539                }
    534540
     
    536542                {
    537543                    dprintf(("window proc WM_USER: VBOX_SHARED_CLIPBOARD_FMT_BITMAP\n"));
    538                     hClip = SetClipboardData (CF_DIB, NULL);
     544                   
     545                    /* Prevent the WM_DRAWCLIPBOARD processing. Will be reset in WM_DRAWCLIPBOARD. */
     546                    if (ASMAtomicCmpXchgU32 (&pCtx->u32Announcing, 1, 0) == true)
     547                    {
     548                        hClip = SetClipboardData (CF_DIB, NULL);
     549                    }
    539550                }
    540551
     
    545556                    if (format != 0)
    546557                    {
    547                         hClip = SetClipboardData (format, NULL);
     558                        /* Prevent the WM_DRAWCLIPBOARD processing. Will be reset in WM_DRAWCLIPBOARD. */
     559                        if (ASMAtomicCmpXchgU32 (&pCtx->u32Announcing, 1, 0) == true)
     560                        {
     561                            hClip = SetClipboardData (format, NULL);
     562                        }
    548563                    }
    549564                }
     
    551566                CloseClipboard();
    552567
    553                 dprintf(("window proc WM_USER: hClip %p\n", hClip));
     568                dprintf(("window proc WM_USER: hClip %p, err %d\n", hClip, GetLastError ()));
    554569            }
    555570            else
     
    557572                dprintf(("window proc WM_USER: failed to open clipboard\n"));
    558573            }
    559            
    560             pCtx->fAnnouncing = false;
    561574        } break;
    562575
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