Changeset 81843 in vbox for trunk/src/VBox/GuestHost/SharedClipboard
- Timestamp:
- Nov 14, 2019 4:30:44 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134637
- Location:
- trunk/src/VBox/GuestHost/SharedClipboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
r81321 r81843 459 459 LogFlowFunc(("fFormats=0x%08X\n", fFormats)); 460 460 461 pFormats-> uFormats = fFormats;461 pFormats->Formats = fFormats; 462 462 pFormats->fFlags = 0; /** @todo Handle flags. */ 463 463 } -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
r81829 r81843 252 252 #endif 253 253 /** What formats does VBox have on offer? */ 254 uint32_tvboxFormats;254 SHCLFORMATS vboxFormats; 255 255 /** Cache of the last unicode data that we received */ 256 256 void *pvUnicodeCache; … … 1100 1100 void ClipDestructX11(CLIPBACKEND *pCtx) 1101 1101 { 1102 if (!pCtx) 1103 return; 1104 1102 1105 if (pCtx->fHaveX11) 1106 { 1103 1107 /* We set this to NULL when the event thread exits. It really should 1104 1108 * have exited at this point, when we are about to unload the code from 1105 1109 * memory. */ 1106 1110 Assert(pCtx->widget == NULL); 1111 } 1112 1107 1113 RTMemFree(pCtx); 1108 1114 } … … 1251 1257 * data returned. 1252 1258 */ 1253 static int clipReadVBoxShCl(CLIPBACKEND *pCtx, uint32_t u32Format,1259 static int clipReadVBoxShCl(CLIPBACKEND *pCtx, SHCLFORMAT Format, 1254 1260 void **ppv, uint32_t *pcb) 1255 1261 { 1262 LogFlowFunc(("pCtx=%p, Format=%02X, ppv=%p, pcb=%p\n", pCtx, Format, ppv, pcb)); 1263 1256 1264 int rc = VINF_SUCCESS; 1257 LogFlowFunc(("pCtx=%p, u32Format=%02X, ppv=%p, pcb=%p\n", pCtx, 1258 u32Format, ppv, pcb)); 1259 if (u32Format == VBOX_SHCL_FMT_UNICODETEXT) 1265 1266 if (Format == VBOX_SHCL_FMT_UNICODETEXT) 1260 1267 { 1261 1268 if (pCtx->pvUnicodeCache == NULL) 1262 rc = ClipRequestDataForX11Callback(pCtx->pFrontend, u32Format,1269 rc = ClipRequestDataForX11Callback(pCtx->pFrontend, Format, 1263 1270 &pCtx->pvUnicodeCache, 1264 1271 &pCtx->cbUnicodeCache); … … 1272 1279 } 1273 1280 else 1274 rc = ClipRequestDataForX11Callback(pCtx->pFrontend, u32Format,1281 rc = ClipRequestDataForX11Callback(pCtx->pFrontend, Format, 1275 1282 ppv, pcb); 1276 1283 if (RT_SUCCESS(rc)) … … 1489 1496 1490 1497 CLIPX11FORMAT x11Format = clipFindX11FormatByAtom(pCtx, *atomTarget); 1491 CLIPFORMAT format = clipRealFormatForX11Format(x11Format); 1492 1493 if ( ((format == UTF8) || (format == TEXT)) 1498 CLIPFORMAT clipFormat = clipRealFormatForX11Format(x11Format); 1499 1500 LogFlowFunc(("fFormats=0x%x, x11Format=%u, clipFormat=%u\n", pCtx->vboxFormats, x11Format, clipFormat)); 1501 1502 if ( ((clipFormat == UTF8) || (clipFormat == TEXT)) 1494 1503 && (pCtx->vboxFormats & VBOX_SHCL_FMT_UNICODETEXT)) 1495 1504 { … … 1499 1508 if (RT_SUCCESS(rc) && (cb == 0)) 1500 1509 rc = VERR_NO_DATA; 1501 if (RT_SUCCESS(rc) && (( format == UTF8) || (format == TEXT)))1510 if (RT_SUCCESS(rc) && ((clipFormat == UTF8) || (clipFormat == TEXT))) 1502 1511 rc = clipWinTxtToUtf8ForX11CB(XtDisplay(pCtx->widget), 1503 1512 (PRTUTF16)pv, cb, atomTarget, … … 1505 1514 pcLenReturn, piFormatReturn); 1506 1515 if (RT_SUCCESS(rc)) 1507 clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, format);1516 clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, clipFormat); 1508 1517 1509 1518 RTMemFree(pv); 1510 1519 } 1511 else if ( ( format == BMP)1520 else if ( (clipFormat == BMP) 1512 1521 && (pCtx->vboxFormats & VBOX_SHCL_FMT_BITMAP)) 1513 1522 { … … 1517 1526 if (RT_SUCCESS(rc) && (cb == 0)) 1518 1527 rc = VERR_NO_DATA; 1519 if (RT_SUCCESS(rc) && ( format == BMP))1528 if (RT_SUCCESS(rc) && (clipFormat == BMP)) 1520 1529 { 1521 1530 /* Create a full BMP from it */ … … 1534 1543 RTMemFree(pv); 1535 1544 } 1536 else if ( ( format == HTML)1545 else if ( (clipFormat == HTML) 1537 1546 && (pCtx->vboxFormats & VBOX_SHCL_FMT_HTML)) 1538 1547 { … … 1557 1566 pcLenReturn, piFormatReturn); 1558 1567 if (RT_SUCCESS(rc)) 1559 clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, format);1568 clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, clipFormat); 1560 1569 1561 1570 RTMemFree(pv); 1562 1571 } 1563 1572 } 1573 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 1574 else if (pCtx->vboxFormats & VBOX_SHCL_FMT_URI_LIST) 1575 { 1576 switch (clipFormat) 1577 { 1578 case TEXT: 1579 RT_FALL_THROUGH(); 1580 case UTF8: 1581 { 1582 void *pv = NULL; 1583 uint32_t cb = 0; 1584 rc = clipReadVBoxShCl(pCtx, VBOX_SHCL_FMT_URI_LIST, &pv, &cb); 1585 1586 RTMemFree(pv); 1587 break; 1588 } 1589 1590 case URI_LIST: 1591 { 1592 break; 1593 } 1594 1595 default: 1596 rc = VERR_NOT_SUPPORTED; 1597 break; 1598 } 1599 } 1600 #endif 1564 1601 else 1602 { 1603 *atomTypeReturn = XT_CONVERT_FAIL; 1604 *pValReturn = (XtPointer)NULL; 1605 *pcLenReturn = 0; 1606 *piFormatReturn = 0; 1607 1565 1608 rc = VERR_NOT_SUPPORTED; 1609 } 1610 1611 if (RT_FAILURE(rc)) 1612 LogRel2(("Shared Clipboard: Converting format 0x%x for X11 (x11Format=%u, clipFormat=%u) failed, rc=%Rrc\n", 1613 pCtx->vboxFormats, x11Format, clipFormat, rc)); 1566 1614 1567 1615 LogFlowFuncLeaveRC(rc); … … 1587 1635 1588 1636 if (!pCtx) 1589 return false;1637 return False; 1590 1638 1591 1639 if (!clipIsSupportedSelectionType(pCtx, *atomSelection)) 1592 return false;1640 return False; 1593 1641 1594 1642 if (*atomTarget == clipGetAtom(pCtx, "TARGETS")) … … 1599 1647 pValReturn, pcLenReturn, piFormatReturn); 1600 1648 1601 LogFlowFunc(("returning , internal status code %Rrc\n", rc));1602 return RT_SUCCESS(rc) ;1649 LogFlowFunc(("returning %RTbool, internal status code %Rrc\n", RT_SUCCESS(rc), rc)); 1650 return RT_SUCCESS(rc) ? True : False; 1603 1651 } 1604 1652 … … 1611 1659 CLIPBACKEND *pCtx; 1612 1660 /** Formats supported by VBox. */ 1613 SHCLFORMATS formats;1661 SHCLFORMATS Formats; 1614 1662 } CLIPNEWVBOXFORMATS, *PCLIPNEWVBOXFORMATS; 1615 1663 … … 1627 1675 * Takes possession of the X11 clipboard (and middle-button selection). 1628 1676 */ 1629 static void clipGrabX11CB(CLIPBACKEND *pCtx, uint32_t u32Formats) 1630 { 1677 static void clipGrabX11CB(CLIPBACKEND *pCtx, SHCLFORMATS Formats) 1678 { 1679 LogFlowFuncEnter(); 1680 1631 1681 if (XtOwnSelection(pCtx->widget, clipGetAtom(pCtx, "CLIPBOARD"), 1632 1682 CurrentTime, clipXtConvertSelectionProc, NULL, 0)) 1633 1683 { 1634 pCtx->vboxFormats = u32Formats;1684 pCtx->vboxFormats = Formats; 1635 1685 /* Grab the middle-button paste selection too. */ 1636 1686 XtOwnSelection(pCtx->widget, clipGetAtom(pCtx, "PRIMARY"), … … 1663 1713 CLIPBACKEND *pCtx = pFormats->pCtx; 1664 1714 1665 uint32_t fFormats = pFormats-> formats;1715 uint32_t fFormats = pFormats->Formats; 1666 1716 1667 1717 RTMemFree(pFormats); … … 1680 1730 * 1681 1731 * @returns VBox status code. 1682 * @param u32FormatsClipboard formats offered.1683 */ 1684 int ClipAnnounceFormatToX11(CLIPBACKEND *pCtx, uint32_t u32Formats)1732 * @param Formats Clipboard formats offered. 1733 */ 1734 int ClipAnnounceFormatToX11(CLIPBACKEND *pCtx, uint32_t Formats) 1685 1735 { 1686 1736 /* … … 1697 1747 { 1698 1748 pFormats->pCtx = pCtx; 1699 pFormats-> formats = u32Formats;1749 pFormats->Formats = Formats; 1700 1750 1701 1751 rc = clipQueueToEventThread(pCtx, clipAnnounceFormatToX11Worker, … … 2289 2339 * @returns VBox status code. 2290 2340 * @param pCtx Context data for the clipboard backend. 2291 * @param u32FormatThe format that the VBox would like to receive the data in.2341 * @param Format The format that the VBox would like to receive the data in. 2292 2342 * @param pReq Read callback request to use. Must be free'd in the callback. 2293 2343 * 2294 2344 * @note We allocate a request structure which must be freed by the worker. 2295 2345 */ 2296 int ClipReadDataFromX11(CLIPBACKEND *pCtx, uint32_t u32Format, CLIPREADCBREQ *pReq)2346 int ClipReadDataFromX11(CLIPBACKEND *pCtx, SHCLFORMAT Format, CLIPREADCBREQ *pReq) 2297 2347 { 2298 2348 /* … … 2308 2358 { 2309 2359 pX11Req->mpCtx = pCtx; 2310 pX11Req->mFormat = u32Format;2360 pX11Req->mFormat = Format; 2311 2361 pX11Req->mpReq = pReq; 2312 2362 … … 2386 2436 2387 2437 /* Return the data in the simulated VBox clipboard. */ 2388 DECLCALLBACK(int) ClipRequestDataForX11Callback(SHCLCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb)2389 { 2390 RT_NOREF(pCtx, u32Format);2438 DECLCALLBACK(int) ClipRequestDataForX11Callback(SHCLCONTEXT *pCtx, uint32_t Format, void **ppv, uint32_t *pcb) 2439 { 2440 RT_NOREF(pCtx, Format); 2391 2441 *pcb = g_tstVBoxDataCb; 2392 2442 if (g_tstVBoxDataPv != NULL) … … 2503 2553 } 2504 2554 2505 /* The formats currently on offer from X11 via the shared clipboard */2555 /* The formats currently on offer from X11 via the shared clipboard. */ 2506 2556 static uint32_t g_fX11Formats = 0; 2507 2557 2508 DECLCALLBACK(void) ClipReportX11FormatsCallback(SHCLCONTEXT *pCtx, uint32_t u32Formats)2558 DECLCALLBACK(void) ClipReportX11FormatsCallback(SHCLCONTEXT *pCtx, SHCLFORMATS Formats) 2509 2559 { 2510 2560 RT_NOREF(pCtx); 2511 g_fX11Formats = u32Formats;2561 g_fX11Formats = Formats; 2512 2562 } 2513 2563 … … 3145 3195 # include <iprt/test.h> 3146 3196 3147 DECLCALLBACK(int) ClipRequestDataForX11Callback(SHCLCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb)3148 { 3149 RT_NOREF(pCtx, u32Format, ppv, pcb);3197 DECLCALLBACK(int) ClipRequestDataForX11Callback(SHCLCONTEXT *pCtx, SHCLFORMAT Format, void **ppv, uint32_t *pcb) 3198 { 3199 RT_NOREF(pCtx, Format, ppv, pcb); 3150 3200 return VERR_NO_DATA; 3151 3201 } 3152 3202 3153 DECLCALLBACK(void) ClipReportX11FormatsCallback(SHCLCONTEXT *pCtx, uint32_t u32Formats)3154 { 3155 RT_NOREF(pCtx, u32Formats);3203 DECLCALLBACK(void) ClipReportX11FormatsCallback(SHCLCONTEXT *pCtx, SHCLFORMATS Formats) 3204 { 3205 RT_NOREF(pCtx, Formats); 3156 3206 } 3157 3207
Note:
See TracChangeset
for help on using the changeset viewer.