VirtualBox

Ignore:
Timestamp:
Mar 31, 2023 9:19:29 AM (22 months ago)
Author:
vboxsync
Message:

Shared Clipboard/X11: Added more (optional) release logging, to let the user know about X11-based clipboard timeouts / empty selections. Should help diagnosing similar problems in the future. Added some docs. bugref:10402

File:
1 edited

Legend:

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

    r99203 r99250  
    16891689                 pCtx->vboxFormats, idxFmtX11, g_aFormats[idxFmtX11].pcszAtom, fmtX11));
    16901690
    1691 #ifdef LOG_ENABLED
    16921691    char *pszFmts = ShClFormatsToStrA(pCtx->vboxFormats);
    16931692    AssertPtrReturn(pszFmts, VERR_NO_MEMORY);
    16941693    LogRel2(("Shared Clipboard: Converting VBox formats '%s' to '%s' for X11\n",
    1695              pszFmts, g_aFormats[idxFmtX11].pcszAtom));
     1694             pszFmts, fmtX11 == SHCLX11FMT_INVALID ? "<invalid>" : g_aFormats[idxFmtX11].pcszAtom));
    16961695    RTStrFree(pszFmts);
    1697 #endif
    16981696
    16991697    void    *pv = NULL;
     
    20072005    AssertPtrReturnVoid(pReq);
    20082006
    2009     LogFlowFunc(("pReq->uFmtVBox=%#x, pReq->idxFmtX11=%u, pReq->pCtx=%p\n", pReq->uFmtVBox, pReq->idxFmtX11, pReq->pCtx));
     2007    LogFlowFunc(("uFmtVBox=%#x, idxFmtX11=%u, pvSrc=%p, cbSrc=%u\n", pReq->uFmtVBox, pReq->idxFmtX11, pvSrc, cbSrc));
    20102008
    20112009    LogRel2(("Shared Clipboard: Converting X11 format '%s' to VBox format %#x\n",
     
    22532251{
    22542252    RT_NOREF(widget);
     2253
     2254    int rc = VINF_SUCCESS;
     2255
     2256    CLIPREADX11CBREQ *pReq = (CLIPREADX11CBREQ *)pClient;
     2257    if (pReq) /* Give some more clues, if available. */
     2258    {
     2259        char *pszFmts = ShClFormatsToStrA(pReq->uFmtVBox);
     2260        AssertPtrReturnVoid(pszFmts);
     2261        AssertReturnVoid(pReq->idxFmtX11 <= SHCL_MAX_X11_FORMATS); /* Paranoia, should be checked already by the caller. */
     2262        LogRel2(("Shared Clipboard: Converting X11 format '%s' -> VBox format(s) '%s'\n", g_aFormats[pReq->idxFmtX11].pcszAtom, pszFmts));
     2263        RTStrFree(pszFmts);
     2264    }
     2265
    22552266    if (*atomType == XT_CONVERT_FAIL) /* Xt timeout */
    2256         clipConvertDataFromX11Worker(pClient, NULL, 0);
     2267    {
     2268        LogRel(("Shared Clipboard: Reading clipboard data from X11 timed out\n"));
     2269        rc = VERR_TIMEOUT;
     2270    }
    22572271    else
    22582272    {
    2259         CLIPREADX11CBREQ *pReq = (CLIPREADX11CBREQ *)pClient;
    2260         if (pReq->pCtx->Callbacks.pfnOnClipboardRead)
     2273        if (   pReq
     2274            && pReq->pCtx->Callbacks.pfnOnClipboardRead)
    22612275        {
    22622276            void  *pvData = NULL;
    22632277            size_t cbData = 0;
    2264             int rc = pReq->pCtx->Callbacks.pfnOnClipboardRead(pReq->pCtx->pFrontend, pReq->uFmtVBox, &pvData, &cbData, NULL);
     2278            rc = pReq->pCtx->Callbacks.pfnOnClipboardRead(pReq->pCtx->pFrontend, pReq->uFmtVBox, &pvData, &cbData, NULL);
    22652279            if (RT_SUCCESS(rc))
    22662280            {
     
    22692283                RTMemFree(pvData);
    22702284            }
    2271             else
    2272                 clipConvertDataFromX11Worker(pClient, NULL, 0);
    22732285        }
    22742286        else /* Call with current data provided by X (default). */
     
    22762288    }
    22772289
     2290    if (RT_FAILURE(rc))
     2291    {
     2292        LogRel(("Shared Clipboard: Reading clipboard data from X11 failed with %Rrc\n", rc));
     2293        /* Make sure to complete the request in any case. */
     2294        clipConvertDataFromX11Worker(pClient, NULL, 0);
     2295    }
     2296
    22782297    XtFree((char *)pvSrc);
    22792298}
    22802299
    2281 static int clipGetSelectionValue(PSHCLX11CTX pCtx, SHCLX11FMTIDX idxFmt,
    2282                                  CLIPREADX11CBREQ *pReq)
    2283 {
     2300/**
     2301 * Requests the current clipboard data from a specific selection.
     2302 *
     2303 * @returns VBox status code.
     2304 * @param   pCtx                The X11 clipboard context to use.
     2305 * @param   pszWhere            Clipboard selection to request the data from.
     2306 * @param   idxFmt              The X11 format to request the data in.
     2307 * @param   pReq                Where to store the requested data on success.
     2308 */
     2309static int clipGetSelectionValueEx(PSHCLX11CTX pCtx, const char *pszWhere, SHCLX11FMTIDX idxFmt,
     2310                                   CLIPREADX11CBREQ *pReq)
     2311{
     2312    AssertPtrReturn(pszWhere, VERR_INVALID_POINTER);
     2313    AssertReturn(idxFmt <= SHCL_MAX_X11_FORMATS, VERR_INVALID_PARAMETER);
     2314    AssertReturn(clipIsSupportedSelectionType(pCtx, clipGetAtom(pCtx, pszWhere)), VERR_INVALID_PARAMETER);
     2315    AssertPtrReturn(pReq, VERR_INVALID_POINTER);
     2316
     2317    LogRel2(("Shared Clipboard: Requesting X11 selection value in %s for format '%s'\n", pszWhere, g_aFormats[idxFmt].pcszAtom));
     2318
    22842319#ifndef TESTCASE
    2285     XtGetSelectionValue(pCtx->pWidget, clipGetAtom(pCtx, "CLIPBOARD"),
     2320    XtGetSelectionValue(pCtx->pWidget, clipGetAtom(pCtx, pszWhere),
    22862321                        clipAtomForX11Format(pCtx, idxFmt),
    22872322                        clipConvertDataFromX11,
     
    22932328
    22942329    return VINF_SUCCESS; /** @todo Return real rc. */
     2330}
     2331
     2332/**
     2333 * Requests the current clipboard data from the CLIPBOARD selection.
     2334 *
     2335 * @returns VBox status code.
     2336 * @param   pCtx                The X11 clipboard context to use.
     2337 * @param   idxFmt              The X11 format to request the data in.
     2338 * @param   pReq                Where to store the requested data on success.
     2339 *
     2340 * @sa clipGetSelectionValueEx() for requesting data for a specific selection.
     2341 */
     2342static int clipGetSelectionValue(PSHCLX11CTX pCtx, SHCLX11FMTIDX idxFmt, CLIPREADX11CBREQ *pReq)
     2343{
     2344    return clipGetSelectionValueEx(pCtx, "CLIPBOARD", idxFmt, pReq);
    22952345}
    22962346
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