Changeset 21425 in vbox for trunk/src/VBox/GuestHost
- Timestamp:
- Jul 9, 2009 11:05:49 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/x11-clipboard.cpp
r21269 r21425 319 319 320 320 /** 321 * Go through an array of X11 clipboard targets to see if we can support any322 * of them and if relevant to choose the ones we prefer (e.g. we like Utf8323 * better than compound text).321 * Go through an array of X11 clipboard targets to see if they contain a text 322 * format we can support, and if so choose the ones we prefer (e.g. we like 323 * Utf8 better than compound text). 324 324 * @param pCtx the clipboard backend context structure 325 325 * @param pTargets the list of targets 326 326 * @param cTargets the size of the list in @a pTargets 327 * @param pChanged This is set to true if the formats available have changed 328 * from VBox's point of view, and to false otherwise. 329 * Somehow this didn't feel right as a return value. 330 */ 331 void clipGetFormatsFromTargets(CLIPBACKEND *pCtx, Atom *pTargets, 332 size_t cTargets, bool *pChanged) 333 { 334 bool changed = false; 327 */ 328 static CLIPX11FORMAT clipGetTextFormatFromTargets(CLIPBACKEND *pCtx, 329 Atom *pTargets, 330 size_t cTargets) 331 { 335 332 CLIPX11FORMAT bestTextFormat = NIL_CLIPX11FORMAT; 336 333 CLIPFORMAT enmBestTextTarget = INVALID; 337 AssertPtrReturn Void(pCtx);338 AssertPtrReturn Void(pTargets);334 AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT); 335 AssertPtrReturn(pTargets, NIL_CLIPX11FORMAT); 339 336 for (unsigned i = 0; i < cTargets; ++i) 340 337 { … … 352 349 } 353 350 } 351 return bestTextFormat; 352 } 353 354 #ifdef TESTCASE 355 static bool clipTestTextFormatConversion(CLIPBACKEND *pCtx) 356 { 357 bool success = true; 358 Atom targets[3]; 359 CLIPX11FORMAT x11Format; 360 targets[0] = clipGetAtom(NULL, "COMPOUND_TEXT"); 361 targets[1] = clipGetAtom(NULL, "text/plain"); 362 targets[2] = clipGetAtom(NULL, "TARGETS"); 363 x11Format = clipGetTextFormatFromTargets(pCtx, targets, 3); 364 if (clipRealFormatForX11Format(x11Format) != CTEXT) 365 success = false; 366 targets[0] = clipGetAtom(NULL, "UTF8_STRING"); 367 targets[1] = clipGetAtom(NULL, "text/plain"); 368 targets[2] = clipGetAtom(NULL, "COMPOUND_TEXT"); 369 x11Format = clipGetTextFormatFromTargets(pCtx, targets, 3); 370 if (clipRealFormatForX11Format(x11Format) != UTF8) 371 success = false; 372 return success; 373 } 374 #endif 375 376 /** 377 * Go through an array of X11 clipboard targets to see if we can support any 378 * of them and if relevant to choose the ones we prefer (e.g. we like Utf8 379 * better than compound text). 380 * @param pCtx the clipboard backend context structure 381 * @param pTargets the list of targets 382 * @param cTargets the size of the list in @a pTargets 383 * @param pChanged This is set to true if the formats available have changed 384 * from VBox's point of view, and to false otherwise. 385 * Somehow this didn't feel right as a return value. 386 */ 387 static void clipGetFormatsFromTargets(CLIPBACKEND *pCtx, Atom *pTargets, 388 size_t cTargets, bool *pChanged) 389 { 390 bool changed = false; 391 AssertPtrReturnVoid(pCtx); 392 AssertPtrReturnVoid(pTargets); 393 CLIPX11FORMAT bestTextFormat; 394 bestTextFormat = clipGetTextFormatFromTargets(pCtx, pTargets, cTargets); 354 395 if (pCtx->X11TextFormat != bestTextFormat) 355 396 { … … 1057 1098 } 1058 1099 1059 /** Gives up ownership of the X11 clipboard */1060 static void clipGiveUpX11CB(CLIPBACKEND *pCtx)1061 {1062 XtDisownSelection(pCtx->widget, clipGetAtom(pCtx->widget, "CLIPBOARD"),1063 CurrentTime);1064 XtDisownSelection(pCtx->widget, clipGetAtom(pCtx->widget, "PRIMARY"),1065 CurrentTime);1066 pCtx->fOwnsClipboard = false;1067 pCtx->vboxFormats = 0;1068 }1069 1070 1100 /** 1071 1101 * Take possession of the X11 clipboard (and middle-button selection). … … 1767 1797 /* The current values of the X selection, which will be returned to the 1768 1798 * XtGetSelectionValue callback. */ 1769 static Atom g_selTarget[ 3] = { 0 };1799 static Atom g_selTarget[1] = { 0 }; 1770 1800 static Atom g_selType = 0; 1771 1801 static const void *g_pSelData = NULL; … … 1901 1931 Atom clipAtom = clipGetAtom(NULL, "CLIPBOARD"); 1902 1932 g_selTarget[0] = clipGetAtom(NULL, pcszTarget); 1903 g_selTarget[1] = clipGetAtom(NULL, "text/plain");1904 g_selTarget[2] = clipGetAtom(NULL, "TARGETS");1905 1933 g_selType = type; 1906 1934 g_pSelData = data; … … 2362 2390 } 2363 2391 2392 /*** X11 text format conversion ***/ 2393 RTPrintf(TEST_NAME ": TESTING selection of X11 text formats\n"); 2394 if (!clipTestTextFormatConversion(pCtx)) 2395 { 2396 RTPrintf(TEST_NAME ": Failed to select the right X11 text formats\n"); 2397 ++cErrs; 2398 } 2399 2364 2400 /*** Utf-8 from VBox ***/ 2365 2401 RTPrintf(TEST_NAME ": TESTING reading Utf-8 from VBox\n");
Note:
See TracChangeset
for help on using the changeset viewer.