Changeset 99250 in vbox for trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
- Timestamp:
- Mar 31, 2023 9:19:29 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
r99203 r99250 1689 1689 pCtx->vboxFormats, idxFmtX11, g_aFormats[idxFmtX11].pcszAtom, fmtX11)); 1690 1690 1691 #ifdef LOG_ENABLED1692 1691 char *pszFmts = ShClFormatsToStrA(pCtx->vboxFormats); 1693 1692 AssertPtrReturn(pszFmts, VERR_NO_MEMORY); 1694 1693 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)); 1696 1695 RTStrFree(pszFmts); 1697 #endif1698 1696 1699 1697 void *pv = NULL; … … 2007 2005 AssertPtrReturnVoid(pReq); 2008 2006 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)); 2010 2008 2011 2009 LogRel2(("Shared Clipboard: Converting X11 format '%s' to VBox format %#x\n", … … 2253 2251 { 2254 2252 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 2255 2266 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 } 2257 2271 else 2258 2272 { 2259 CLIPREADX11CBREQ *pReq = (CLIPREADX11CBREQ *)pClient;2260 if (pReq->pCtx->Callbacks.pfnOnClipboardRead)2273 if ( pReq 2274 && pReq->pCtx->Callbacks.pfnOnClipboardRead) 2261 2275 { 2262 2276 void *pvData = NULL; 2263 2277 size_t cbData = 0; 2264 intrc = 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); 2265 2279 if (RT_SUCCESS(rc)) 2266 2280 { … … 2269 2283 RTMemFree(pvData); 2270 2284 } 2271 else2272 clipConvertDataFromX11Worker(pClient, NULL, 0);2273 2285 } 2274 2286 else /* Call with current data provided by X (default). */ … … 2276 2288 } 2277 2289 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 2278 2297 XtFree((char *)pvSrc); 2279 2298 } 2280 2299 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 */ 2309 static 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 2284 2319 #ifndef TESTCASE 2285 XtGetSelectionValue(pCtx->pWidget, clipGetAtom(pCtx, "CLIPBOARD"),2320 XtGetSelectionValue(pCtx->pWidget, clipGetAtom(pCtx, pszWhere), 2286 2321 clipAtomForX11Format(pCtx, idxFmt), 2287 2322 clipConvertDataFromX11, … … 2293 2328 2294 2329 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 */ 2342 static int clipGetSelectionValue(PSHCLX11CTX pCtx, SHCLX11FMTIDX idxFmt, CLIPREADX11CBREQ *pReq) 2343 { 2344 return clipGetSelectionValueEx(pCtx, "CLIPBOARD", idxFmt, pReq); 2295 2345 } 2296 2346
Note:
See TracChangeset
for help on using the changeset viewer.