VirtualBox

Changeset 87082 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Dec 10, 2020 10:01:11 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141862
Message:

Shared Clipboard: Simplified and cleaned up the X11 callback handling to actually do what they advertise in case no data is available. This also makes the surround code a lot easier to understand / follow.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp

    r86969 r87082  
    103103 * @returns VBox status code. VERR_NO_DATA if no data available.
    104104 * @param   pCtx                Our context information.
    105  * @param   Format              The format of the data being requested.
    106  * @param   ppv                 On success and if pcb > 0, this will point to a buffer
    107  *                              to be freed with RTMemFree containing the data read.
    108  * @param   pcb                 On success, this contains the number of bytes of data returned.
    109  */
    110 DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT Format, void **ppv, uint32_t *pcb)
    111 {
    112     RT_NOREF(pCtx);
    113 
    114     LogFlowFunc(("Format=0x%x\n", Format));
     105 * @param   uFmt                The format of the data being requested.
     106 * @param   ppv                 Returns an allocated buffer with data read from the host on success.
     107 *                              Needs to be free'd with RTMemFree() by the caller.
     108 * @param   pcb                 Returns the amount of data read (in bytes) on success.
     109 */
     110DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb)
     111{
     112    LogFlowFunc(("pCtx=%p, uFmt=%#x\n", pCtx, uFmt));
    115113
    116114    int rc = VINF_SUCCESS;
    117115
    118     uint32_t cbRead = 0;
    119 
    120116#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    121     if (Format == VBOX_SHCL_FMT_URI_LIST)
     117    if (uFmt == VBOX_SHCL_FMT_URI_LIST)
    122118    {
    123119        //rc = VbglR3ClipboardRootListRead()
     120
     121        rc = VERR_NO_DATA;
    124122    }
    125123    else
    126124#endif
    127125    {
     126        uint32_t cbRead = 0;
     127
    128128        uint32_t cbData = _4K; /** @todo Make this dynamic. */
    129129        void    *pvData = RTMemAlloc(cbData);
    130130        if (pvData)
    131131        {
    132             rc = VbglR3ClipboardReadDataEx(&pCtx->CmdCtx, Format, pvData, cbData, &cbRead);
     132            rc = VbglR3ClipboardReadDataEx(&pCtx->CmdCtx, uFmt, pvData, cbData, &cbRead);
    133133        }
    134134        else
     
    148148            if (pvData)
    149149            {
    150                 rc = VbglR3ClipboardReadDataEx(&pCtx->CmdCtx, Format, pvData, cbData, &cbRead);
     150                rc = VbglR3ClipboardReadDataEx(&pCtx->CmdCtx, uFmt, pvData, cbData, &cbRead);
    151151                if (rc == VINF_BUFFER_OVERFLOW)
    152152                    rc = VERR_BUFFER_OVERFLOW;
     
    176176    }
    177177
     178    if (RT_FAILURE(rc))
     179        LogRel(("Requesting data in format %#x from host failed with %Rrc\n", uFmt, rc));
     180
    178181    LogFlowFuncLeaveRC(rc);
    179182    return rc;
     
    201204    RT_NOREF(pCtx);
    202205
    203     LogFlowFunc(("Formats=0x%x\n", fFormats));
     206    LogFlowFunc(("fFormats=%#x\n", fFormats));
    204207
    205208    int rc2 = VbglR3ClipboardReportFormats(pCtx->CmdCtx.idClient, fFormats);
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