Changeset 199
- Timestamp:
- 01/12/08 23:09:19 (1 year ago)
- Files:
-
- xsel/trunk/xsel.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
xsel/trunk/xsel.c
r198 r199 62 62 static Atom text_atom; /* The TEXT atom */ 63 63 static Atom utf8_atom; /* The UTF8 atom */ 64 static Atom local_target; /* UTF8_STRING or STRING */65 64 66 65 /* Number of selection targets served by this. … … 629 628 *(int *)value); 630 629 keep_waiting = False; 631 } else if (target != utf8_atom && target != XA_STRING && request_target != delete_atom) { 630 } else if (target != utf8_atom && target != XA_STRING && 631 request_target != delete_atom) { 632 632 /* Report non-TEXT atoms */ 633 633 print_debug (D_WARN, "Selection (type %s) is not a string.", … … 705 705 return retval; 706 706 } 707 708 /* 709 * get_selection_text (Atom selection) 710 * 711 * Retrieve a text selection. First attempt to retrieve it as UTF_STRING, 712 * and if that fails attempt to retrieve it as a plain XA_STRING. 713 * 714 * NB. Before implementing this, an attempt was made to query TARGETS and 715 * request UTF8_STRING only if listed there, as described in: 716 * http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text 717 * However, that did not seem to work reliably when tested against various 718 * applications (eg. Mozilla Firefox). This method is of course more 719 * reliable. 720 */ 721 static unsigned char * 722 get_selection_text (Atom selection) 723 { 724 unsigned char * retval; 725 726 if ((retval = get_selection (selection, utf8_atom)) == NULL) 727 retval = get_selection (selection, XA_STRING); 728 729 return retval; 730 } 731 707 732 708 733 /* … … 1303 1328 static HandleResult 1304 1329 handle_utf8_string (Display * display, Window requestor, Atom property, 1305 unsigned char * sel, Atom selection, Time time,1306 MultTrack * mparent)1330 unsigned char * sel, Atom selection, Time time, 1331 MultTrack * mparent) 1307 1332 { 1308 1333 return … … 1360 1385 } else if (mt->atoms[i] == utf8_atom) { 1361 1386 retval |= handle_utf8_string (mt->display, mt->requestor, mt->atoms[i+1], 1362 mt->sel, mt->selection, mt->time, mt);1387 mt->sel, mt->selection, mt->time, mt); 1363 1388 } else if (mt->atoms[i] == delete_atom) { 1364 1389 retval |= handle_delete (mt->display, mt->requestor, mt->atoms[i+1]); … … 1537 1562 ev.property = xsr->property; 1538 1563 hr = handle_utf8_string (ev.display, ev.requestor, ev.property, sel, 1539 ev.selection, ev.time, NULL);1564 ev.selection, ev.time, NULL); 1540 1565 } else if (ev.target == delete_atom) { 1541 1566 /* Received DELETE request */ … … 1750 1775 unsigned char * text1, * text2; 1751 1776 1752 text1 = get_selection (XA_PRIMARY, local_target);1753 text2 = get_selection (XA_SECONDARY, local_target);1777 text1 = get_selection_text (XA_PRIMARY); 1778 text2 = get_selection_text (XA_SECONDARY); 1754 1779 1755 1780 set_selection_pair__daemon (text1, text2); … … 1768 1793 unsigned char * text1, * text2; 1769 1794 1770 text1 = get_selection (XA_PRIMARY, local_target);1771 text2 = get_selection (XA_SECONDARY, local_target);1795 text1 = get_selection_text (XA_PRIMARY); 1796 text2 = get_selection_text (XA_SECONDARY); 1772 1797 1773 1798 set_selection_pair__daemon (text2, text1); … … 1945 1970 1946 1971 NUM_TARGETS=0; 1972 1947 1973 /* Get the TIMESTAMP atom */ 1948 1974 timestamp_atom = XInternAtom (display, "TIMESTAMP", False); … … 1991 2017 NUM_TARGETS++; 1992 2018 1993 if( need_utf8 == True) {1994 local_target=utf8_atom;1995 } else {1996 local_target=XA_STRING;1997 }1998 1999 2019 /* handle selection keeping and exit if so */ 2000 2020 if (do_keep) { … … 2017 2037 if (do_output || !dont_output) { 2018 2038 /* Get the current selection */ 2019 old_sel = get_selection (selection, local_target);2039 old_sel = get_selection_text (selection); 2020 2040 if (old_sel) printf ("%s", old_sel); 2021 2041 } … … 2029 2049 else if (do_input || !dont_input) { 2030 2050 if (do_append) { 2031 if (!old_sel) old_sel = get_selection (selection, local_target);2051 if (!old_sel) old_sel = get_selection_text (selection); 2032 2052 new_sel = copy_sel (old_sel); 2033 2053 }
