- Timestamp:
- Jul 2, 2009 9:53:03 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/x11-clipboard.cpp
r20966 r21184 62 62 INVALID = 0, 63 63 TARGETS, 64 TEXT, /* Treat this as Utf8, but it may really be ascii */ 64 65 CTEXT, 65 66 UTF8 … … 85 86 { "text/plain;charset=utf-8", UTF8, 86 87 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT }, 87 { "STRING", UTF8, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT },88 { "TEXT", UTF8, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT },89 { "text/plain", UTF8, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT },88 { "STRING", TEXT, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT }, 89 { "TEXT", TEXT, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT }, 90 { "text/plain", TEXT, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT }, 90 91 { "COMPOUND_TEXT", CTEXT, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT } 91 92 }; … … 333 334 bool changed = false; 334 335 CLIPX11FORMAT bestTextFormat = NIL_CLIPX11FORMAT; 336 CLIPFORMAT enmBestTextTarget = INVALID; 335 337 AssertPtrReturnVoid(pCtx); 336 338 AssertPtrReturnVoid(pTargets); 337 339 for (unsigned i = 0; i < cTargets; ++i) 338 340 { 339 CLIPFORMAT enmBestTextTarget = INVALID;340 341 CLIPX11FORMAT format = clipFindX11FormatByAtom(pCtx->widget, 341 342 pTargets[i]); … … 355 356 changed = true; 356 357 pCtx->X11TextFormat = bestTextFormat; 358 #if defined(DEBUG) && !defined(TESTCASE) 359 for (unsigned i = 0; i < cTargets; ++i) 360 if (pTargets[i]) 361 { 362 char *pszName = XGetAtomName(XtDisplay(pCtx->widget), 363 pTargets[i]); 364 Log2(("%s: found target %s\n", __PRETTY_FUNCTION__, pszName)); 365 XFree(pszName); 366 } 367 #endif 357 368 } 358 369 pCtx->X11BitmapFormat = INVALID; /* not yet supported */ … … 959 970 *atomTarget); 960 971 CLIPFORMAT format = clipRealFormatForX11Format(x11Format); 961 if ( ((format == UTF8) || (format == CTEXT) )972 if ( ((format == UTF8) || (format == CTEXT) || (format == TEXT)) 962 973 && (pCtx->vboxFormats & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)) 963 974 { … … 969 980 if (RT_SUCCESS(rc) && (cb == 0)) 970 981 rc = VERR_NO_DATA; 971 if (RT_SUCCESS(rc) && ( format == UTF8))982 if (RT_SUCCESS(rc) && ((format == UTF8) || (format == TEXT))) 972 983 rc = clipWinTxtToUtf8ForX11CB(XtDisplay(pCtx->widget), 973 984 (PRTUTF16)pv, cb, atomTarget, … … 1395 1406 break; 1396 1407 case UTF8: 1408 case TEXT: 1397 1409 { 1398 1410 /* If we are given broken Utf-8, we treat it as Latin1. Is … … 1515 1527 #ifdef TESTCASE 1516 1528 1529 /** @todo This unit test currently works by emulating the X11 and X toolkit 1530 * APIs to exercise the code, since I didn't want to rewrite the code too much 1531 * when I wrote the tests. However, this makes it rather ugly and hard to 1532 * understand. Anyone doing any work on the code should feel free to 1533 * rewrite the tests and the code to make them cleaner and more readable. */ 1534 1517 1535 #include <iprt/initterm.h> 1518 1536 #include <iprt/stream.h> … … 1755 1773 /* The current values of the X selection, which will be returned to the 1756 1774 * XtGetSelectionValue callback. */ 1757 static Atom g_selTarget = 0;1775 static Atom g_selTarget[3] = { 0 }; 1758 1776 static Atom g_selType = 0; 1759 1777 static const void *g_pSelData = NULL; … … 1773 1791 && selection != clipGetAtom(NULL, "CLIPBOARD") 1774 1792 && selection != clipGetAtom(NULL, "TARGETS")) 1775 || ( target != g_selTarget 1793 || ( target != g_selTarget[0] 1776 1794 && target != clipGetAtom(NULL, "TARGETS"))) 1777 1795 { 1778 1796 /* Otherwise this is probably a caller error. */ 1779 Assert(target != g_selTarget );1797 Assert(target != g_selTarget[0]); 1780 1798 callback(widget, closure, &selection, &type, NULL, &count, &format); 1781 1799 /* Could not convert to target. */ … … 1790 1808 pValue = (XtPointer) RTMemDup(&g_selTarget, sizeof(g_selTarget)); 1791 1809 type = g_fTargetsTimeout ? XT_CONVERT_FAIL : XA_ATOM; 1792 count = g_fTargetsFailure ? 0 : 1;1810 count = g_fTargetsFailure ? 0 : RT_ELEMENTS(g_selTarget); 1793 1811 format = 32; 1794 1812 } … … 1888 1906 { 1889 1907 Atom clipAtom = clipGetAtom(NULL, "CLIPBOARD"); 1890 g_selTarget = clipGetAtom(NULL, pcszTarget); 1908 g_selTarget[0] = clipGetAtom(NULL, pcszTarget); 1909 g_selTarget[1] = clipGetAtom(NULL, "text/plain"); 1910 g_selTarget[2] = clipGetAtom(NULL, "TARGETS"); 1891 1911 g_selType = type; 1892 1912 g_pSelData = data;
Note:
See TracChangeset
for help on using the changeset viewer.