VirtualBox

Changeset 85831 in vbox


Ignore:
Timestamp:
Aug 19, 2020 1:50:45 PM (4 years ago)
Author:
vboxsync
Message:

Shared Clipboard/X11: Renaming, a bit of additional (release) logging.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/SharedClipboard-x11.h

    r82968 r85831  
    9292
    9393    /** The best text format X11 has to offer, as an index into the formats table. */
    94     SHCLX11FMTIDX X11TextFormat;
     94    SHCLX11FMTIDX idxFmtText;
    9595    /** The best bitmap format X11 has to offer, as an index into the formats table. */
    96     SHCLX11FMTIDX X11BitmapFormat;
     96    SHCLX11FMTIDX idxFmtBmp;
    9797    /** The best HTML format X11 has to offer, as an index into the formats table. */
    98     SHCLX11FMTIDX X11HTMLFormat;
     98    SHCLX11FMTIDX idxFmtHTML;
    9999#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    100100    /** The best HTML format X11 has to offer, as an index into the formats table. */
    101     SHCLX11FMTIDX X11URIListFormat;
     101    SHCLX11FMTIDX idxFmtURI;
    102102#endif
    103103    /** What kind of formats does VBox have to offer? */
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp

    r85828 r85831  
    172172{
    173173    /** The format VBox would like the data in. */
    174     SHCLFORMAT       mFormat;
     174    SHCLFORMAT       uFmtVBox;
    175175    /** The format we requested from X11. */
    176     SHCLX11FMTIDX    mX11Format;
     176    SHCLX11FMTIDX    idxFmtX11;
    177177    /** The clipboard context this request is associated with. */
    178     SHCLX11CTX      *mpCtx;
     178    SHCLX11CTX      *pCtx;
    179179    /** The request structure passed in from the backend. */
    180     CLIPREADCBREQ   *mpReq;
     180    CLIPREADCBREQ   *pReq;
    181181} CLIPREADX11CBREQ;
    182182
     
    423423static void clipReportFormatsToVBox(PSHCLX11CTX pCtx)
    424424{
    425     uint32_t fFormats  = clipVBoxFormatForX11Format(pCtx->X11TextFormat);
    426              fFormats |= clipVBoxFormatForX11Format(pCtx->X11BitmapFormat);
    427              fFormats |= clipVBoxFormatForX11Format(pCtx->X11HTMLFormat);
     425    SHCLFORMATS vboxFmt  = clipVBoxFormatForX11Format(pCtx->idxFmtText);
     426                vboxFmt |= clipVBoxFormatForX11Format(pCtx->idxFmtBmp);
     427                vboxFmt |= clipVBoxFormatForX11Format(pCtx->idxFmtHTML);
    428428#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    429              fFormats |= clipVBoxFormatForX11Format(pCtx->X11URIListFormat);
    430 #endif
    431 
    432     LogFlowFunc(("fFormats=0x%x\n", fFormats));
    433     LogFlowFunc(("txt: %u, bmp: %u, html: %u\n",
    434                  pCtx->X11TextFormat, pCtx->X11BitmapFormat, pCtx->X11HTMLFormat));
     429                vboxFmt |= clipVBoxFormatForX11Format(pCtx->idxFmtURI);
     430#endif
     431
     432    LogFlowFunc(("idxFmtText=%u ('%s'), idxFmtBmp=%u ('%s'), idxFmtHTML=%u ('%s')",
     433                 pCtx->idxFmtText, g_aFormats[pCtx->idxFmtText].pcszAtom,
     434                 pCtx->idxFmtBmp,  g_aFormats[pCtx->idxFmtBmp].pcszAtom,
     435                 pCtx->idxFmtHTML, g_aFormats[pCtx->idxFmtHTML].pcszAtom));
    435436#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    436     LogFlowFunc(("uri list: %u\n", pCtx->X11URIListFormat));
    437 #endif
    438 
    439     LogRel2(("Shared Clipboard: X11 reported available formats 0x%x\n", fFormats));
    440 
    441     ShClX11ReportFormatsCallback(pCtx->pFrontend, fFormats);
     437    LogFlowFunc((", idxFmtURI=%u ('%s')", pCtx->idxFmtURI, g_aFormats[pCtx->idxFmtURI].pcszAtom));
     438#endif
     439    LogFlow((" -> vboxFmt=%#x\n", vboxFmt));
     440
     441    LogRel2(("Shared Clipboard: X11 reported available VBox formats: %#x\n", vboxFmt));
     442
     443    ShClX11ReportFormatsCallback(pCtx->pFrontend, vboxFmt);
    442444}
    443445
     
    452454    LogFlowFuncEnter();
    453455
    454     pCtx->X11TextFormat    = SHCLX11FMT_INVALID;
    455     pCtx->X11BitmapFormat  = SHCLX11FMT_INVALID;
    456     pCtx->X11HTMLFormat    = SHCLX11FMT_INVALID;
     456    pCtx->idxFmtText = 0;
     457    pCtx->idxFmtBmp  = 0;
     458    pCtx->idxFmtHTML = 0;
    457459#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    458     pCtx->X11URIListFormat = SHCLX11FMT_INVALID;
     460    pCtx->idxFmtURI  = 0;
    459461#endif
    460462}
     
    478480 * @return Index to supported X clipboard format.
    479481 * @param  pCtx                 The X11 clipboard context to use.
    480  * @param  pTargets             The list of targets.
     482 * @param  paIdxFmtTargets      The list of targets.
    481483 * @param  cTargets             The size of the list in @a pTargets.
    482484 */
    483485SHCL_X11_DECL(SHCLX11FMTIDX) clipGetTextFormatFromTargets(PSHCLX11CTX pCtx,
    484                                                           SHCLX11FMTIDX *pTargets,
     486                                                          SHCLX11FMTIDX *paIdxFmtTargets,
    485487                                                          size_t cTargets)
    486488{
    487489    AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT);
    488     AssertReturn(VALID_PTR(pTargets) || cTargets == 0, NIL_CLIPX11FORMAT);
    489 
    490     SHCLX11FMTIDX bestTextFormat = NIL_CLIPX11FORMAT;
    491     SHCLX11FMT enmBestTextTarget = SHCLX11FMT_INVALID;
     490    AssertReturn(VALID_PTR(paIdxFmtTargets) || cTargets == 0, NIL_CLIPX11FORMAT);
     491
     492    SHCLX11FMTIDX idxFmtText = NIL_CLIPX11FORMAT;
     493    SHCLX11FMT    fmtTextX11 = SHCLX11FMT_INVALID;
    492494    for (unsigned i = 0; i < cTargets; ++i)
    493495    {
    494         SHCLX11FMTIDX format = pTargets[i];
    495         if (format != NIL_CLIPX11FORMAT)
    496         {
    497             if (   (clipVBoxFormatForX11Format(format) == VBOX_SHCL_FMT_UNICODETEXT)
    498                 && enmBestTextTarget < clipRealFormatForX11Format(format))
     496        SHCLX11FMTIDX idxFmt = paIdxFmtTargets[i];
     497        if (idxFmt != NIL_CLIPX11FORMAT)
     498        {
     499            if (   (clipVBoxFormatForX11Format(idxFmt) == VBOX_SHCL_FMT_UNICODETEXT)
     500                && fmtTextX11 < clipRealFormatForX11Format(idxFmt))
    499501            {
    500                 enmBestTextTarget = clipRealFormatForX11Format(format);
    501                 bestTextFormat = format;
     502                fmtTextX11 = clipRealFormatForX11Format(idxFmt);
     503                idxFmtText = idxFmt;
    502504            }
    503505        }
    504506    }
    505     return bestTextFormat;
     507    return idxFmtText;
    506508}
    507509
     
    513515 * @return Supported X clipboard format.
    514516 * @param  pCtx                 The X11 clipboard context to use.
    515  * @param  pTargets             The list of targets.
     517 * @param  paIdxFmtTargets      The list of targets.
    516518 * @param  cTargets             The size of the list in @a pTargets.
    517519 */
    518520static SHCLX11FMTIDX clipGetBitmapFormatFromTargets(PSHCLX11CTX pCtx,
    519                                                     SHCLX11FMTIDX *pTargets,
     521                                                    SHCLX11FMTIDX *paIdxFmtTargets,
    520522                                                    size_t cTargets)
    521523{
    522524    AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT);
    523     AssertReturn(VALID_PTR(pTargets) || cTargets == 0, NIL_CLIPX11FORMAT);
    524 
    525     SHCLX11FMTIDX bestBitmapFormat = NIL_CLIPX11FORMAT;
    526     SHCLX11FMT enmBestBitmapTarget = SHCLX11FMT_INVALID;
     525    AssertReturn(VALID_PTR(paIdxFmtTargets) || cTargets == 0, NIL_CLIPX11FORMAT);
     526
     527    SHCLX11FMTIDX idxFmtBmp = NIL_CLIPX11FORMAT;
     528    SHCLX11FMT    fmtBmpX11 = SHCLX11FMT_INVALID;
    527529    for (unsigned i = 0; i < cTargets; ++i)
    528530    {
    529         SHCLX11FMTIDX format = pTargets[i];
    530         if (format != NIL_CLIPX11FORMAT)
    531         {
    532             if (   (clipVBoxFormatForX11Format(format) == VBOX_SHCL_FMT_BITMAP)
    533                 && enmBestBitmapTarget < clipRealFormatForX11Format(format))
     531        SHCLX11FMTIDX idxFmt = paIdxFmtTargets[i];
     532        if (idxFmt != NIL_CLIPX11FORMAT)
     533        {
     534            if (   (clipVBoxFormatForX11Format(idxFmt) == VBOX_SHCL_FMT_BITMAP)
     535                && fmtBmpX11 < clipRealFormatForX11Format(idxFmt))
    534536            {
    535                 enmBestBitmapTarget = clipRealFormatForX11Format(format);
    536                 bestBitmapFormat = format;
     537                fmtBmpX11 = clipRealFormatForX11Format(idxFmt);
     538                idxFmtBmp = idxFmt;
    537539            }
    538540        }
    539541    }
    540     return bestBitmapFormat;
     542    return idxFmtBmp;
    541543}
    542544
     
    546548 *
    547549 * @return Supported X clipboard format.
    548  * @param   pCtx                The X11 clipboard context to use.
    549  * @param  pTargets             The list of targets.
     550 * @param  pCtx                 The X11 clipboard context to use.
     551 * @param  paIdxFmtTargets      The list of targets.
    550552 * @param  cTargets             The size of the list in @a pTargets.
    551553 */
    552554static SHCLX11FMTIDX clipGetHtmlFormatFromTargets(PSHCLX11CTX pCtx,
    553                                                   SHCLX11FMTIDX *pTargets,
     555                                                  SHCLX11FMTIDX *paIdxFmtTargets,
    554556                                                  size_t cTargets)
    555557{
    556558    AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT);
    557     AssertReturn(VALID_PTR(pTargets) || cTargets == 0, NIL_CLIPX11FORMAT);
    558 
    559     SHCLX11FMTIDX bestHTMLFormat = NIL_CLIPX11FORMAT;
    560     SHCLX11FMT enmBestHtmlTarget = SHCLX11FMT_INVALID;
     559    AssertReturn(VALID_PTR(paIdxFmtTargets) || cTargets == 0, NIL_CLIPX11FORMAT);
     560
     561    SHCLX11FMTIDX idxFmtHTML = NIL_CLIPX11FORMAT;
     562    SHCLX11FMT    fmxHTMLX11 = SHCLX11FMT_INVALID;
    561563    for (unsigned i = 0; i < cTargets; ++i)
    562564    {
    563         SHCLX11FMTIDX format = pTargets[i];
    564         if (format != NIL_CLIPX11FORMAT)
    565         {
    566             if (   (clipVBoxFormatForX11Format(format) == VBOX_SHCL_FMT_HTML)
    567                 && enmBestHtmlTarget < clipRealFormatForX11Format(format))
     565        SHCLX11FMTIDX idxFmt = paIdxFmtTargets[i];
     566        if (idxFmt != NIL_CLIPX11FORMAT)
     567        {
     568            if (   (clipVBoxFormatForX11Format(idxFmt) == VBOX_SHCL_FMT_HTML)
     569                && fmxHTMLX11 < clipRealFormatForX11Format(idxFmt))
    568570            {
    569                 enmBestHtmlTarget = clipRealFormatForX11Format(format);
    570                 bestHTMLFormat = format;
     571                fmxHTMLX11 = clipRealFormatForX11Format(idxFmt);
     572                idxFmtHTML = idxFmt;
    571573            }
    572574        }
    573575    }
    574     return bestHTMLFormat;
     576    return idxFmtHTML;
    575577}
    576578
     
    582584 * @return Supported X clipboard format.
    583585 * @param  pCtx                 The X11 clipboard context to use.
    584  * @param  pTargets             The list of targets.
     586 * @param  paIdxFmtTargets      The list of targets.
    585587 * @param  cTargets             The size of the list in @a pTargets.
    586588 */
    587589static SHCLX11FMTIDX clipGetURIListFormatFromTargets(PSHCLX11CTX pCtx,
    588                                                      SHCLX11FMTIDX *pTargets,
     590                                                     SHCLX11FMTIDX *paIdxFmtTargets,
    589591                                                     size_t cTargets)
    590592{
    591593    AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT);
    592     AssertReturn(VALID_PTR(pTargets) || cTargets == 0, NIL_CLIPX11FORMAT);
    593 
    594     SHCLX11FMTIDX bestURIListFormat = NIL_CLIPX11FORMAT;
    595     SHCLX11FMT enmBestURIListTarget = SHCLX11FMT_INVALID;
     594    AssertReturn(VALID_PTR(paIdxFmtTargets) || cTargets == 0, NIL_CLIPX11FORMAT);
     595
     596    SHCLX11FMTIDX idxFmtURI = NIL_CLIPX11FORMAT;
     597    SHCLX11FMT    fmtURIX11 = SHCLX11FMT_INVALID;
    596598    for (unsigned i = 0; i < cTargets; ++i)
    597599    {
    598         SHCLX11FMTIDX format = pTargets[i];
    599         if (format != NIL_CLIPX11FORMAT)
    600         {
    601             if (   (clipVBoxFormatForX11Format(format) == VBOX_SHCL_FMT_URI_LIST)
    602                 && enmBestURIListTarget < clipRealFormatForX11Format(format))
     600        SHCLX11FMTIDX idxFmt = paIdxFmtTargets[i];
     601        if (idxFmt != NIL_CLIPX11FORMAT)
     602        {
     603            if (   (clipVBoxFormatForX11Format(idxFmt) == VBOX_SHCL_FMT_URI_LIST)
     604                && fmtURIX11 < clipRealFormatForX11Format(idxFmt))
    603605            {
    604                 enmBestURIListTarget = clipRealFormatForX11Format(format);
    605                 bestURIListFormat = format;
     606                fmtURIX11 = clipRealFormatForX11Format(idxFmt);
     607                idxFmtURI = idxFmt;
    606608            }
    607609        }
    608610    }
    609     return bestURIListFormat;
     611    return idxFmtURI;
    610612}
    611613# endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */
     
    617619 *
    618620 * @param  pCtx                 The X11 clipboard context to use.
    619  * @param  pTargets             The list of targets.
     621 * @param  paIdxFmtTargets      The list of targets.
    620622 * @param  cTargets             The size of the list in @a pTargets.
    621623 */
    622624static void clipGetFormatsFromTargets(PSHCLX11CTX pCtx,
    623                                       SHCLX11FMTIDX *pTargets, size_t cTargets)
     625                                      SHCLX11FMTIDX *paIdxFmtTargets, size_t cTargets)
    624626{
    625627    AssertPtrReturnVoid(pCtx);
    626     AssertPtrReturnVoid(pTargets);
    627 
    628     SHCLX11FMTIDX bestTextFormat = clipGetTextFormatFromTargets(pCtx, pTargets, cTargets);
    629     if (pCtx->X11TextFormat != bestTextFormat)
    630         pCtx->X11TextFormat = bestTextFormat;
    631 
    632     pCtx->X11BitmapFormat = SHCLX11FMT_INVALID; /* not yet supported */ /** @todo r=andy Check this. */
    633     SHCLX11FMTIDX bestBitmapFormat = clipGetBitmapFormatFromTargets(pCtx, pTargets, cTargets);
    634     if (pCtx->X11BitmapFormat != bestBitmapFormat)
    635         pCtx->X11BitmapFormat = bestBitmapFormat;
    636 
    637     SHCLX11FMTIDX bestHtmlFormat = clipGetHtmlFormatFromTargets(pCtx, pTargets, cTargets);
    638     if (pCtx->X11HTMLFormat != bestHtmlFormat)
    639         pCtx->X11HTMLFormat = bestHtmlFormat;
     628    AssertPtrReturnVoid(paIdxFmtTargets);
     629
     630    SHCLX11FMTIDX idxFmtText = clipGetTextFormatFromTargets(pCtx, paIdxFmtTargets, cTargets);
     631    if (pCtx->idxFmtText != idxFmtText)
     632        pCtx->idxFmtText = idxFmtText;
     633
     634    pCtx->idxFmtBmp = SHCLX11FMT_INVALID; /* not yet supported */ /** @todo r=andy Check this. */
     635    SHCLX11FMTIDX idxFmtBmp = clipGetBitmapFormatFromTargets(pCtx, paIdxFmtTargets, cTargets);
     636    if (pCtx->idxFmtBmp != idxFmtBmp)
     637        pCtx->idxFmtBmp = idxFmtBmp;
     638
     639    SHCLX11FMTIDX idxFmtHTML = clipGetHtmlFormatFromTargets(pCtx, paIdxFmtTargets, cTargets);
     640    if (pCtx->idxFmtHTML != idxFmtHTML)
     641        pCtx->idxFmtHTML = idxFmtHTML;
    640642
    641643#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    642     SHCLX11FMTIDX bestURIListFormat = clipGetURIListFormatFromTargets(pCtx, pTargets, cTargets);
    643     if (pCtx->X11URIListFormat != bestURIListFormat)
    644         pCtx->X11URIListFormat = bestURIListFormat;
     644    SHCLX11FMTIDX idxFmtURI = clipGetURIListFormatFromTargets(pCtx, paIdxFmtTargets, cTargets);
     645    if (pCtx->idxFmtURI != idxFmtURI)
     646        pCtx->idxFmtURI = idxFmtURI;
    645647#endif
    646648}
     
    654656 * @param  cTargets             The size of the array @a pTargets.
    655657 */
    656 SHCL_X11_DECL(void) clipUpdateX11Targets(PSHCLX11CTX pCtx, SHCLX11FMTIDX *pTargets, size_t cTargets)
     658SHCL_X11_DECL(void) clipUpdateX11Targets(PSHCLX11CTX pCtx, SHCLX11FMTIDX *paIdxFmtTargets, size_t cTargets)
    657659{
    658660    LogFlowFuncEnter();
    659661
    660     if (pTargets == NULL)
     662    if (paIdxFmtTargets == NULL)
    661663    {
    662664        /* No data available */
     
    665667    }
    666668
    667     clipGetFormatsFromTargets(pCtx, pTargets, cTargets);
     669    clipGetFormatsFromTargets(pCtx, paIdxFmtTargets, cTargets);
    668670    clipReportFormatsToVBox(pCtx);
    669671}
     
    715717    LogRel2(("Shared Clipboard: %u formats were found\n", cFormats));
    716718
    717     SHCLX11FMTIDX *pFormats = NULL;
     719    SHCLX11FMTIDX *paIdxFmt = NULL;
    718720    if (   cFormats
    719721        && pValue
     
    721723    {
    722724        /* Allocated array to hold the format indices. */
    723         pFormats = (SHCLX11FMTIDX *)RTMemAllocZ(cFormats * sizeof(SHCLX11FMTIDX));
     725        paIdxFmt = (SHCLX11FMTIDX *)RTMemAllocZ(cFormats * sizeof(SHCLX11FMTIDX));
    724726    }
    725727
     
    741743#endif
    742744
    743     if (pFormats)
     745    if (paIdxFmt)
    744746    {
    745747        for (unsigned i = 0; i < cFormats; ++i)
     
    750752                                          g_aFormats[j].pcszAtom, False);
    751753                if (*(pAtoms + i) == target)
    752                     pFormats[i] = j;
     754                    paIdxFmt[i] = j;
    753755            }
    754756#if !defined(TESTCASE)
    755             if (pFormats[i] != SHCLX11FMT_INVALID)
    756                 LogRel2(("Shared Clipboard: Reporting format '%s'\n", g_aFormats[pFormats[i]].pcszAtom));
     757            if (paIdxFmt[i] != SHCLX11FMT_INVALID)
     758                LogRel2(("Shared Clipboard: Reporting format '%s'\n", g_aFormats[paIdxFmt[i]].pcszAtom));
    757759#endif
    758760        }
     
    761763        LogFunc(("Reporting empty targets (none reported or allocation failure)\n"));
    762764
    763     clipUpdateX11Targets(pCtx, pFormats, cFormats);
    764     RTMemFree(pFormats);
     765    clipUpdateX11Targets(pCtx, paIdxFmt, cFormats);
     766    RTMemFree(paIdxFmt);
    765767
    766768    XtFree(reinterpret_cast<char *>(pValue));
     
    12481250    Atom *atomTargets = (Atom *)XtMalloc((SHCL_MAX_X11_FORMATS + cFixedTargets) * sizeof(Atom));
    12491251    unsigned cTargets = 0;
    1250     SHCLX11FMTIDX format = NIL_CLIPX11FORMAT;
     1252    SHCLX11FMTIDX idxFmt = NIL_CLIPX11FORMAT;
    12511253    do
    12521254    {
    1253         format = clipEnumX11Formats(pCtx->vboxFormats, format);
    1254         if (format != NIL_CLIPX11FORMAT)
    1255         {
    1256             atomTargets[cTargets] = clipAtomForX11Format(pCtx, format);
     1255        idxFmt = clipEnumX11Formats(pCtx->vboxFormats, idxFmt);
     1256        if (idxFmt != NIL_CLIPX11FORMAT)
     1257        {
     1258            atomTargets[cTargets] = clipAtomForX11Format(pCtx, idxFmt);
    12571259            ++cTargets;
    12581260        }
    1259     } while (format != NIL_CLIPX11FORMAT);
     1261    } while (idxFmt != NIL_CLIPX11FORMAT);
    12601262
    12611263    /* We always offer these fixed targets. */
     
    14531455    int rc = VINF_SUCCESS;
    14541456
    1455     SHCLX11FMTIDX x11Format = clipFindX11FormatByAtom(pCtx, *atomTarget);
    1456     SHCLX11FMT clipFormat = clipRealFormatForX11Format(x11Format);
    1457 
    1458     LogFlowFunc(("fFormats=0x%x, x11Format=%u, clipFormat=%u\n", pCtx->vboxFormats, x11Format, clipFormat));
    1459 
    1460     if (   ((clipFormat == SHCLX11FMT_UTF8) || (clipFormat == SHCLX11FMT_TEXT))
     1457    SHCLX11FMTIDX idxFmtX11 = clipFindX11FormatByAtom(pCtx, *atomTarget);
     1458    SHCLX11FMT    fmtX11    = clipRealFormatForX11Format(idxFmtX11);
     1459
     1460    LogFlowFunc(("vboxFormats=0x%x, idxFmtX11=%u ('%s'), fmtX11=%u\n",
     1461                 pCtx->vboxFormats, idxFmtX11, g_aFormats[idxFmtX11].pcszAtom, fmtX11));
     1462
     1463    LogRel2(("Shared Clipboard: Converting VBox formats %#x to '%s' for X11\n",
     1464             pCtx->vboxFormats, g_aFormats[idxFmtX11].pcszAtom));
     1465
     1466    if (   ((fmtX11 == SHCLX11FMT_UTF8) || (fmtX11 == SHCLX11FMT_TEXT))
    14611467        && (pCtx->vboxFormats & VBOX_SHCL_FMT_UNICODETEXT))
    14621468    {
     
    14661472        if (RT_SUCCESS(rc) && (cb == 0))
    14671473            rc = VERR_NO_DATA;
    1468         if (RT_SUCCESS(rc) && ((clipFormat == SHCLX11FMT_UTF8) || (clipFormat == SHCLX11FMT_TEXT)))
     1474        if (RT_SUCCESS(rc) && ((fmtX11 == SHCLX11FMT_UTF8) || (fmtX11 == SHCLX11FMT_TEXT)))
    14691475            rc = clipUtf16CRLFToUtf8LF(XtDisplay(pCtx->pWidget),
    14701476                                       (PRTUTF16)pv, cb, atomTarget,
     
    14721478                                       pcLenReturn, piFormatReturn);
    14731479        if (RT_SUCCESS(rc))
    1474             clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, clipFormat);
     1480            clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, fmtX11);
    14751481
    14761482        RTMemFree(pv);
    14771483    }
    1478     else if (   (clipFormat == SHCLX11FMT_BMP)
     1484    else if (   (fmtX11 == SHCLX11FMT_BMP)
    14791485             && (pCtx->vboxFormats & VBOX_SHCL_FMT_BITMAP))
    14801486    {
     
    14841490        if (RT_SUCCESS(rc) && (cb == 0))
    14851491            rc = VERR_NO_DATA;
    1486         if (RT_SUCCESS(rc) && (clipFormat == SHCLX11FMT_BMP))
     1492        if (RT_SUCCESS(rc) && (fmtX11 == SHCLX11FMT_BMP))
    14871493        {
    14881494            /* Create a full BMP from it */
     
    15011507        RTMemFree(pv);
    15021508    }
    1503     else if (  (clipFormat == SHCLX11FMT_HTML)
     1509    else if (  (fmtX11 == SHCLX11FMT_HTML)
    15041510            && (pCtx->vboxFormats & VBOX_SHCL_FMT_HTML))
    15051511    {
     
    15241530                                           pcLenReturn, piFormatReturn);
    15251531            if (RT_SUCCESS(rc))
    1526                 clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, clipFormat);
     1532                clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, fmtX11);
    15271533
    15281534            RTMemFree(pv);
     
    15321538    else if (pCtx->vboxFormats & VBOX_SHCL_FMT_URI_LIST)
    15331539    {
    1534         switch (clipFormat)
     1540        switch (fmtX11)
    15351541        {
    15361542            case SHCLX11FMT_TEXT:
     
    15601566
    15611567    if (RT_FAILURE(rc))
    1562         LogRel2(("Shared Clipboard: Converting format 0x%x for X11 (x11Format=%u, clipFormat=%u) failed, rc=%Rrc\n",
    1563                  pCtx->vboxFormats, x11Format, clipFormat, rc));
     1568        LogRel(("Shared Clipboard: Converting VBox formats %#x to '%s' for X11 (idxFmtX11=%u, fmtX11=%u) failed, rc=%Rrc\n",
     1569                pCtx->vboxFormats, g_aFormats[idxFmtX11].pcszAtom, idxFmtX11, fmtX11, rc));
    15641570
    15651571    LogFlowFuncLeaveRC(rc);
     
    15971603                                     pValReturn, pcLenReturn, piFormatReturn);
    15981604
    1599     LogFlowFunc(("returning %RTbool, internal status code %Rrc\n", RT_SUCCESS(rc), rc));
     1605    LogFlowFunc(("returning %RTbool, rc=%Rrc\n", RT_SUCCESS(rc), rc));
    16001606    return RT_SUCCESS(rc) ? True : False;
    16011607}
     
    17211727{
    17221728    CLIPREADX11CBREQ *pReq = (CLIPREADX11CBREQ *)pClient;
    1723 
    1724     LogFlowFunc(("pReq->mFormat=%02X, pReq->mX11Format=%u, pReq->mCtx=%p\n", pReq->mFormat, pReq->mX11Format, pReq->mpCtx));
    1725 
    1726     AssertPtr(pReq->mpCtx);
    1727     Assert(pReq->mFormat != VBOX_SHCL_FMT_NONE); /* Sanity. */
     1729    AssertPtrReturnVoid(pReq);
     1730
     1731    LogFlowFunc(("pReq->uFmtVBox=%#x, pReq->idxFmtX11=%u, pReq->pCtx=%p\n", pReq->uFmtVBox, pReq->idxFmtX11, pReq->pCtx));
     1732
     1733    LogRel2(("Shared Clipboard: Converting X11 format '%s' to VBox format %#x\n",
     1734             g_aFormats[pReq->idxFmtX11].pcszAtom, pReq->uFmtVBox));
     1735
     1736    AssertPtr(pReq->pCtx);
     1737    Assert(pReq->uFmtVBox != VBOX_SHCL_FMT_NONE); /* Sanity. */
    17281738
    17291739    int rc = VINF_SUCCESS;
     
    17371747        rc = VERR_NO_DATA;
    17381748    }
    1739     else if (pReq->mFormat == VBOX_SHCL_FMT_UNICODETEXT)
     1749    else if (pReq->uFmtVBox == VBOX_SHCL_FMT_UNICODETEXT)
    17401750    {
    17411751        /* In which format is the clipboard data? */
    1742         switch (clipRealFormatForX11Format(pReq->mX11Format))
     1752        switch (clipRealFormatForX11Format(pReq->idxFmtX11))
    17431753        {
    17441754            case SHCLX11FMT_UTF8:
     
    17701780        }
    17711781    }
    1772     else if (pReq->mFormat == VBOX_SHCL_FMT_BITMAP)
     1782    else if (pReq->uFmtVBox == VBOX_SHCL_FMT_BITMAP)
    17731783    {
    17741784        /* In which format is the clipboard data? */
    1775         switch (clipRealFormatForX11Format(pReq->mX11Format))
     1785        switch (clipRealFormatForX11Format(pReq->idxFmtX11))
    17761786        {
    17771787            case SHCLX11FMT_BMP:
     
    18021812        }
    18031813    }
    1804     else if (pReq->mFormat == VBOX_SHCL_FMT_HTML)
     1814    else if (pReq->uFmtVBox == VBOX_SHCL_FMT_HTML)
    18051815    {
    18061816        /* In which format is the clipboard data? */
    1807         switch (clipRealFormatForX11Format(pReq->mX11Format))
     1817        switch (clipRealFormatForX11Format(pReq->idxFmtX11))
    18081818        {
    18091819            case SHCLX11FMT_HTML:
     
    18651875    }
    18661876# ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    1867     else if (pReq->mFormat == VBOX_SHCL_FMT_URI_LIST)
     1877    else if (pReq->uFmtVBox == VBOX_SHCL_FMT_URI_LIST)
    18681878    {
    18691879        /* In which format is the clipboard data? */
    1870         switch (clipRealFormatForX11Format(pReq->mX11Format))
     1880        switch (clipRealFormatForX11Format(pReq->idxFmtX11))
    18711881        {
    18721882            case SHCLX11FMT_URI_LIST:
     
    19161926        rc = VERR_NOT_SUPPORTED;
    19171927
    1918     ShClX11RequestFromX11CompleteCallback(pReq->mpCtx->pFrontend, rc, pReq->mpReq,
     1928    if (RT_FAILURE(rc))
     1929        LogRel(("Shared Clipboard: Converting X11 format '%s' (idxFmtX11=%u) to VBox format %#x failed, rc=%Rrc\n",
     1930                g_aFormats[pReq->idxFmtX11].pcszAtom, pReq->idxFmtX11, pReq->uFmtVBox, rc));
     1931
     1932    ShClX11RequestFromX11CompleteCallback(pReq->pCtx->pFrontend, rc, pReq->pReq,
    19191933                                          pvDst, cbDst);
    19201934    RTMemFree(pvDst);
     
    19481962}
    19491963
    1950 static int clipGetSelectionValue(PSHCLX11CTX pCtx, SHCLX11FMTIDX format,
     1964static int clipGetSelectionValue(PSHCLX11CTX pCtx, SHCLX11FMTIDX idxFmt,
    19511965                                 CLIPREADX11CBREQ *pReq)
    19521966{
    19531967#ifndef TESTCASE
    19541968    XtGetSelectionValue(pCtx->pWidget, clipGetAtom(pCtx, "CLIPBOARD"),
    1955                         clipAtomForX11Format(pCtx, format),
     1969                        clipAtomForX11Format(pCtx, idxFmt),
    19561970                        clipConvertDataFromX11Callback,
    19571971                        reinterpret_cast<XtPointer>(pReq),
    19581972                        CurrentTime);
    19591973#else
    1960     tstClipRequestData(pCtx, format, (void *)pReq);
     1974    tstClipRequestData(pCtx, idxFmt, (void *)pReq);
    19611975#endif
    19621976
     
    19721986
    19731987    CLIPREADX11CBREQ *pReq = (CLIPREADX11CBREQ *)pvUserData;
    1974     SHCLX11CTX       *pCtx = pReq->mpCtx;
    1975 
    1976     LogFlowFunc(("pReq->mFormat = %02x\n", pReq->mFormat));
     1988    SHCLX11CTX       *pCtx = pReq->pCtx;
     1989
     1990    LogFlowFunc(("pReq->mFormat = %02x\n", pReq->uFmtVBox));
    19771991
    19781992    int rc = VERR_NO_DATA; /* VBox thinks we have data and we don't. */
    19791993
    1980     if (pReq->mFormat & VBOX_SHCL_FMT_UNICODETEXT)
    1981     {
    1982         pReq->mX11Format = pCtx->X11TextFormat;
    1983         if (pReq->mX11Format != SHCLX11FMT_INVALID)
     1994    if (pReq->uFmtVBox & VBOX_SHCL_FMT_UNICODETEXT)
     1995    {
     1996        pReq->idxFmtX11 = pCtx->idxFmtText;
     1997        if (pReq->idxFmtX11 != SHCLX11FMT_INVALID)
    19841998        {
    19851999            /* Send out a request for the data to the current clipboard owner. */
    1986             rc = clipGetSelectionValue(pCtx, pCtx->X11TextFormat, pReq);
    1987         }
    1988     }
    1989     else if (pReq->mFormat & VBOX_SHCL_FMT_BITMAP)
    1990     {
    1991         pReq->mX11Format = pCtx->X11BitmapFormat;
    1992         if (pReq->mX11Format != SHCLX11FMT_INVALID)
     2000            rc = clipGetSelectionValue(pCtx, pCtx->idxFmtText, pReq);
     2001        }
     2002    }
     2003    else if (pReq->uFmtVBox & VBOX_SHCL_FMT_BITMAP)
     2004    {
     2005        pReq->idxFmtX11 = pCtx->idxFmtBmp;
     2006        if (pReq->idxFmtX11 != SHCLX11FMT_INVALID)
    19932007        {
    19942008            /* Send out a request for the data to the current clipboard owner. */
    1995             rc = clipGetSelectionValue(pCtx, pCtx->X11BitmapFormat, pReq);
    1996         }
    1997     }
    1998     else if (pReq->mFormat & VBOX_SHCL_FMT_HTML)
    1999     {
    2000         pReq->mX11Format = pCtx->X11HTMLFormat;
    2001         if (pReq->mX11Format != SHCLX11FMT_INVALID)
     2009            rc = clipGetSelectionValue(pCtx, pCtx->idxFmtBmp, pReq);
     2010        }
     2011    }
     2012    else if (pReq->uFmtVBox & VBOX_SHCL_FMT_HTML)
     2013    {
     2014        pReq->idxFmtX11 = pCtx->idxFmtHTML;
     2015        if (pReq->idxFmtX11 != SHCLX11FMT_INVALID)
    20022016        {
    20032017            /* Send out a request for the data to the current clipboard owner. */
    2004             rc = clipGetSelectionValue(pCtx, pCtx->X11HTMLFormat, pReq);
     2018            rc = clipGetSelectionValue(pCtx, pCtx->idxFmtHTML, pReq);
    20052019        }
    20062020    }
    20072021#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    2008     else if (pReq->mFormat & VBOX_SHCL_FMT_URI_LIST)
    2009     {
    2010         pReq->mX11Format = pCtx->X11URIListFormat;
    2011         if (pReq->mX11Format != SHCLX11FMT_INVALID)
     2022    else if (pReq->uFmtVBox & VBOX_SHCL_FMT_URI_LIST)
     2023    {
     2024        pReq->idxFmtX11 = pCtx->idxFmtURI;
     2025        if (pReq->idxFmtX11 != SHCLX11FMT_INVALID)
    20122026        {
    20132027            /* Send out a request for the data to the current clipboard owner. */
    2014             rc = clipGetSelectionValue(pCtx, pCtx->X11URIListFormat, pReq);
     2028            rc = clipGetSelectionValue(pCtx, pCtx->idxFmtURI, pReq);
    20152029        }
    20162030    }
     
    20252039        /* The clipboard callback was never scheduled, so we must signal
    20262040         * that the request processing is finished and clean up ourselves. */
    2027         ShClX11RequestFromX11CompleteCallback(pReq->mpCtx->pFrontend, rc, pReq->mpReq,
     2041        ShClX11RequestFromX11CompleteCallback(pReq->pCtx->pFrontend, rc, pReq->pReq,
    20282042                                              NULL /* pv */ ,0 /* cb */);
    20292043        RTMemFree(pReq);
     
    20592073    if (pX11Req)
    20602074    {
    2061         pX11Req->mpCtx   = pCtx;
    2062         pX11Req->mFormat = Format;
    2063         pX11Req->mpReq   = pReq;
     2075        pX11Req->pCtx     = pCtx;
     2076        pX11Req->uFmtVBox = Format;
     2077        pX11Req->pReq     = pReq;
    20642078
    20652079        /* We use this to schedule a worker function on the event thread. */
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