VirtualBox

Changeset 46301 in vbox for trunk/src/VBox/GuestHost


Ignore:
Timestamp:
May 28, 2013 7:02:18 PM (12 years ago)
Author:
vboxsync
Message:

GuestHost/SharedClipboard: the Xt toolkit can only handle one concurrent clipboard operation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/x11-clipboard.cpp

    r46288 r46301  
    193193    /** The first XFixes event number */
    194194    int fixesEventBase;
     195    /** The Xt Intrinsics can only handle one outstanding clipboard operation
     196     * at a time, so we keep track of whether one is in process. */
     197    bool fBusy;
     198    /** We can't handle a clipboard update event while we are busy, so remember
     199     * it for later. */
     200    bool fUpdateNeeded;
    195201};
    196202
     
    475481}
    476482
     483static void clipQueryX11CBFormats(CLIPBACKEND *pCtx);
     484
    477485/**
    478486 * Notify the VBox clipboard about available data formats, based on the
     
    489497    LogRel2(("clipConvertX11Targets: pValue=%p, *pcLen=%u, *atomType=%d, XT_CONVERT_FAIL=%d\n",
    490498             pValue, *pcLen, *atomType, XT_CONVERT_FAIL));
    491     if (   (*atomType == XT_CONVERT_FAIL)  /* timeout */
    492         || (pValue == NULL))               /* No data available */
    493     {
    494         clipReportEmptyX11CB(pCtx);
    495         return;
    496     }
    497     clipUpdateX11Targets(pCtx, (Atom *)pValue, *pcLen);
     499    pCtx->fBusy = false;
     500    if (pCtx->fUpdateNeeded)
     501    {
     502        /* We may already be out of date. */
     503        pCtx->fUpdateNeeded = false;
     504        clipQueryX11CBFormats(pCtx);
     505    }
     506    else
     507    {
     508        if (   (*atomType == XT_CONVERT_FAIL)  /* timeout */
     509               || (pValue == NULL))               /* No data available */
     510        {
     511            clipReportEmptyX11CB(pCtx);
     512            return;
     513        }
     514        clipUpdateX11Targets(pCtx, (Atom *)pValue, *pcLen);
     515    }
    498516    XtFree(reinterpret_cast<char *>(pValue));
    499517}
     
    502520 * Callback to notify us when the contents of the X11 clipboard change.
    503521 */
    504 void clipQueryX11CBFormats(CLIPBACKEND *pCtx)
     522static void clipQueryX11CBFormats(CLIPBACKEND *pCtx)
    505523{
    506524    LogRel2 (("%s: requesting the targets that the X11 clipboard offers\n",
    507525           __PRETTY_FUNCTION__));
     526    if (pCtx->fBusy)
     527    {
     528        pCtx->fUpdateNeeded = true;
     529        return;
     530    }
     531    pCtx->fBusy = true;
    508532    XtGetSelectionValue(pCtx->widget,
    509533                        clipGetAtom(pCtx->widget, "CLIPBOARD"),
     
    15931617    uint32_t cbDest = 0;
    15941618
     1619    pCtx->fBusy = false;
     1620    if (pCtx->fUpdateNeeded)
     1621        clipQueryX11CBFormats(pCtx);
    15951622    if (pvSrc == NULL)
    15961623        /* The clipboard selection may have changed before we could get it. */
     
    16731700
    16741701    int rc = VINF_SUCCESS;
    1675     /*
    1676      * VBox wants to read data in the given format.
    1677      */
    1678     if (pReq->mFormat == VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
    1679     {
     1702    bool fBusy = pCtx->fBusy;
     1703    pCtx->fBusy = true;
     1704    if (fBusy)
     1705        /* If the clipboard is busy just fend off the request. */
     1706        rc = VERR_TRY_AGAIN;
     1707    else if (pReq->mFormat == VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
     1708    {
     1709        /*
     1710         * VBox wants to read data in the given format.
     1711         */
    16801712        pReq->mTextFormat = pCtx->X11TextFormat;
    16811713        if (pReq->mTextFormat == INVALID)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette