Changeset 21430 in vbox for trunk/src/VBox/GuestHost/SharedClipboard
- Timestamp:
- Jul 9, 2009 11:26:00 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49818
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/x11-clipboard.cpp
r21429 r21430 333 333 CLIPFORMAT enmBestTextTarget = INVALID; 334 334 AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT); 335 Assert PtrReturn(pTargets, NIL_CLIPX11FORMAT);335 AssertReturn(VALID_PTR(pTargets) || cTargets == 0, NIL_CLIPX11FORMAT); 336 336 for (unsigned i = 0; i < cTargets; ++i) 337 337 { … … 390 390 bool changed = false; 391 391 AssertPtrReturnVoid(pCtx); 392 Assert PtrReturnVoid(pTargets);392 AssertReturnVoid(VALID_PTR(pTargets) || cTargets == 0); 393 393 CLIPX11FORMAT bestTextFormat; 394 394 bestTextFormat = clipGetTextFormatFromTargets(pCtx, pTargets, cTargets); … … 414 414 415 415 /** 416 * Update the context's information about targets currently supported by X11, 417 * based on an array of X11 atoms. 418 * @param pCtx the context to be updated 419 * @param pTargets the array of atoms describing the targets supported 420 * @param cTargets the size of the array @a pTargets 421 */ 422 static void clipUpdateX11Targets(CLIPBACKEND *pCtx, Atom *pTargets, 423 size_t cTargets) 424 { 425 bool changed = true; 426 427 Log3 (("%s: called\n", __PRETTY_FUNCTION__)); 428 if (pCtx->fOwnsClipboard) 429 /* VBox raced us and we lost. So we don't want to report anything. */ 430 return; 431 clipGetFormatsFromTargets(pCtx, pTargets, cTargets, &changed); 432 if (changed) 433 clipReportFormatsToVBox(pCtx); 434 } 435 436 /** 416 437 * Notify the VBox clipboard about available data formats, based on the 417 438 * "targets" information obtained from the X11 clipboard. … … 425 446 CLIPBACKEND *pCtx = 426 447 reinterpret_cast<CLIPBACKEND *>(pClientData); 427 Atom *pTargets = reinterpret_cast<Atom *>(pValue); 428 size_t cTargets = *pcLen; 429 bool changed = true; 430 431 Log3 (("%s: called\n", __PRETTY_FUNCTION__)); 432 if (pCtx->fOwnsClipboard) 433 /* VBox raced us and we lost. So we don't want to report anything. */ 434 changed = false; 435 else if ( (*atomType == XT_CONVERT_FAIL) /* timeout */ 436 || !pTargets /* Conversion failed */) 437 clipResetX11Formats(pCtx); 438 else 439 clipGetFormatsFromTargets(pCtx, pTargets, cTargets, &changed); 440 if (changed) 441 clipReportFormatsToVBox(pCtx); 448 Atom *pTargets = (*atomType == XT_CONVERT_FAIL) ? NULL /* timeout */ 449 : (Atom *)pValue; 450 size_t cTargets = pTargets ? *pcLen : 0; 451 clipUpdateX11Targets(pCtx, pTargets, cTargets); 442 452 XtFree(reinterpret_cast<char *>(pValue)); 443 453 } … … 1588 1598 } 1589 1599 1590 static bool clipPollTargets()1591 {1592 if (!g_pfnPoller)1593 return false;1594 g_pfnPoller(g_pPollerData, NULL);1595 return true;1596 }1597 1598 1600 /* For the purpose of the test case, we just execute the procedure to be 1599 1601 * scheduled, as we are running single threaded. */ … … 1957 1959 } 1958 1960 1961 static void clipSendTargetUpdate(CLIPBACKEND *pCtx) 1962 { 1963 clipUpdateX11Targets(pCtx, g_selTarget, RT_ELEMENTS(g_selTarget)); 1964 } 1965 1959 1966 /* Configure if and how the X11 TARGETS clipboard target will fail */ 1960 1967 static void clipSetTargetsFailure(bool fTimeout, bool fFailure) … … 2053 2060 { 2054 2061 bool retval = false; 2055 if (!clipPollTargets()) 2056 RTPrintf("Failed to poll for targets\n"); 2057 else if (clipQueryFormats() != VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT) 2062 clipSendTargetUpdate(pCtx); 2063 if (clipQueryFormats() != VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT) 2058 2064 RTPrintf("Wrong targets reported: %02X\n", clipQueryFormats()); 2059 2065 else … … 2112 2118 { 2113 2119 bool retval = false; 2114 if (!clipPollTargets()) 2115 RTPrintf("Failed to poll for targets\n"); 2116 else if (clipQueryFormats() != VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT) 2120 clipSendTargetUpdate(pCtx); 2121 if (clipQueryFormats() != VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT) 2117 2122 RTPrintf("Wrong targets reported: %02X\n", clipQueryFormats()); 2118 2123 else … … 2335 2340 clipSetSelectionValues("CLIPBOARD", XA_STRING, "Test", 2336 2341 sizeof("Test"), 8); 2337 if (!clipPollTargets()) 2338 { 2339 RTPrintf("Failed to poll for targets\n"); 2340 ++cErrs; 2341 } 2342 else if (clipQueryFormats() != 0) 2342 clipSendTargetUpdate(pCtx); 2343 if (clipQueryFormats() != 0) 2343 2344 { 2344 2345 RTPrintf("Failed to send a format update notification\n"); … … 2398 2399 } 2399 2400 2400 /*** Targets timeout from X11 ***/2401 RTPrintf(TEST_NAME ": TESTING X11 targets timeout\n");2402 clipSetSelectionValues("UTF8_STRING", XA_STRING, "hello world",2403 sizeof("hello world"), 8);2404 clipSetTargetsFailure(true, false);2405 if (!clipPollTargets())2406 {2407 RTPrintf("Failed to poll for targets\n");2408 ++cErrs;2409 }2410 else if (clipQueryFormats() != 0)2411 {2412 RTPrintf("Wrong targets reported: %02X\n", clipQueryFormats());2413 ++cErrs;2414 }2415 2416 2401 /*** Targets failure from X11 ***/ 2417 2402 RTPrintf(TEST_NAME ": TESTING X11 targets conversion failure\n"); … … 2419 2404 sizeof("hello world"), 8); 2420 2405 clipSetTargetsFailure(false, true); 2421 if (!clipPollTargets()) 2422 { 2423 RTPrintf("Failed to poll for targets\n"); 2424 ++cErrs; 2425 } 2426 else if (clipQueryFormats() != 0) 2406 clipUpdateX11Targets(pCtx, NULL, 0); 2407 if (clipQueryFormats() != 0) 2427 2408 { 2428 2409 RTPrintf("Wrong targets reported: %02X\n", clipQueryFormats());
Note:
See TracChangeset
for help on using the changeset viewer.