diff options
| author | Kenichi Handa | 2002-08-14 00:58:39 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-08-14 00:58:39 +0000 |
| commit | 5109c8dd99e30ce5520df9fc093d7ff58dd15d8c (patch) | |
| tree | 512913389ec124b99b25d6448b563489a8401747 | |
| parent | 13a45e6cd871c01f013676b415fc2735a06c4b2e (diff) | |
| download | emacs-5109c8dd99e30ce5520df9fc093d7ff58dd15d8c.tar.gz emacs-5109c8dd99e30ce5520df9fc093d7ff58dd15d8c.zip | |
(QUTF8_STRING): New variable.
(symbol_to_x_atom): Pay attention to QUTF8_STRING.
(x_atom_to_symbol): Likewise.
(x_get_local_selection): New argument local_request. If it is
nonzero, call handler_fn with the second arg nil.
(x_handle_selection_request): Call x_get_local_selection with
local_request 0.
(lisp_data_to_selection_data): Don't encode the string here.
(Fx_get_selection_internal): Call x_get_local_selection with
local_request 1.
(syms_of_xselect): Intern and staticpro QUTF8_STRING.
| -rw-r--r-- | src/xselect.c | 64 |
1 files changed, 21 insertions, 43 deletions
diff --git a/src/xselect.c b/src/xselect.c index 5519eecf64c..cbef1ad3aa0 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -40,7 +40,7 @@ static Lisp_Object x_atom_to_symbol P_ ((Display *dpy, Atom atom)); | |||
| 40 | static Atom symbol_to_x_atom P_ ((struct x_display_info *, Display *, | 40 | static Atom symbol_to_x_atom P_ ((struct x_display_info *, Display *, |
| 41 | Lisp_Object)); | 41 | Lisp_Object)); |
| 42 | static void x_own_selection P_ ((Lisp_Object, Lisp_Object)); | 42 | static void x_own_selection P_ ((Lisp_Object, Lisp_Object)); |
| 43 | static Lisp_Object x_get_local_selection P_ ((Lisp_Object, Lisp_Object)); | 43 | static Lisp_Object x_get_local_selection P_ ((Lisp_Object, Lisp_Object, int)); |
| 44 | static void x_decline_selection_request P_ ((struct input_event *)); | 44 | static void x_decline_selection_request P_ ((struct input_event *)); |
| 45 | static Lisp_Object x_selection_request_lisp_error P_ ((Lisp_Object)); | 45 | static Lisp_Object x_selection_request_lisp_error P_ ((Lisp_Object)); |
| 46 | static Lisp_Object queue_selection_requests_unwind P_ ((Lisp_Object)); | 46 | static Lisp_Object queue_selection_requests_unwind P_ ((Lisp_Object)); |
| @@ -96,6 +96,7 @@ Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP, | |||
| 96 | QATOM_PAIR; | 96 | QATOM_PAIR; |
| 97 | 97 | ||
| 98 | Lisp_Object QCOMPOUND_TEXT; /* This is a type of selection. */ | 98 | Lisp_Object QCOMPOUND_TEXT; /* This is a type of selection. */ |
| 99 | Lisp_Object QUTF8_STRING; /* This is a type of selection. */ | ||
| 99 | 100 | ||
| 100 | Lisp_Object Qcompound_text_with_extensions; | 101 | Lisp_Object Qcompound_text_with_extensions; |
| 101 | 102 | ||
| @@ -182,6 +183,7 @@ symbol_to_x_atom (dpyinfo, display, sym) | |||
| 182 | if (EQ (sym, QTIMESTAMP)) return dpyinfo->Xatom_TIMESTAMP; | 183 | if (EQ (sym, QTIMESTAMP)) return dpyinfo->Xatom_TIMESTAMP; |
| 183 | if (EQ (sym, QTEXT)) return dpyinfo->Xatom_TEXT; | 184 | if (EQ (sym, QTEXT)) return dpyinfo->Xatom_TEXT; |
| 184 | if (EQ (sym, QCOMPOUND_TEXT)) return dpyinfo->Xatom_COMPOUND_TEXT; | 185 | if (EQ (sym, QCOMPOUND_TEXT)) return dpyinfo->Xatom_COMPOUND_TEXT; |
| 186 | if (EQ (sym, QUTF8_STRING)) return dpyinfo->Xatom_UTF8_STRING; | ||
| 185 | if (EQ (sym, QDELETE)) return dpyinfo->Xatom_DELETE; | 187 | if (EQ (sym, QDELETE)) return dpyinfo->Xatom_DELETE; |
| 186 | if (EQ (sym, QMULTIPLE)) return dpyinfo->Xatom_MULTIPLE; | 188 | if (EQ (sym, QMULTIPLE)) return dpyinfo->Xatom_MULTIPLE; |
| 187 | if (EQ (sym, QINCR)) return dpyinfo->Xatom_INCR; | 189 | if (EQ (sym, QINCR)) return dpyinfo->Xatom_INCR; |
| @@ -264,6 +266,8 @@ x_atom_to_symbol (dpy, atom) | |||
| 264 | return QTEXT; | 266 | return QTEXT; |
| 265 | if (atom == dpyinfo->Xatom_COMPOUND_TEXT) | 267 | if (atom == dpyinfo->Xatom_COMPOUND_TEXT) |
| 266 | return QCOMPOUND_TEXT; | 268 | return QCOMPOUND_TEXT; |
| 269 | if (atom == dpyinfo->Xatom_UTF8_STRING) | ||
| 270 | return QUTF8_STRING; | ||
| 267 | if (atom == dpyinfo->Xatom_DELETE) | 271 | if (atom == dpyinfo->Xatom_DELETE) |
| 268 | return QDELETE; | 272 | return QDELETE; |
| 269 | if (atom == dpyinfo->Xatom_MULTIPLE) | 273 | if (atom == dpyinfo->Xatom_MULTIPLE) |
| @@ -350,14 +354,15 @@ x_own_selection (selection_name, selection_value) | |||
| 350 | /* Given a selection-name and desired type, look up our local copy of | 354 | /* Given a selection-name and desired type, look up our local copy of |
| 351 | the selection value and convert it to the type. | 355 | the selection value and convert it to the type. |
| 352 | The value is nil or a string. | 356 | The value is nil or a string. |
| 353 | This function is used both for remote requests | 357 | This function is used both for remote requests (LOCAL_REQUEST is zero) |
| 354 | and for local x-get-selection-internal. | 358 | and for local x-get-selection-internal (LOCAL_REQUEST is nonzero). |
| 355 | 359 | ||
| 356 | This calls random Lisp code, and may signal or gc. */ | 360 | This calls random Lisp code, and may signal or gc. */ |
| 357 | 361 | ||
| 358 | static Lisp_Object | 362 | static Lisp_Object |
| 359 | x_get_local_selection (selection_symbol, target_type) | 363 | x_get_local_selection (selection_symbol, target_type, local_request) |
| 360 | Lisp_Object selection_symbol, target_type; | 364 | Lisp_Object selection_symbol, target_type; |
| 365 | int local_request; | ||
| 361 | { | 366 | { |
| 362 | Lisp_Object local_value; | 367 | Lisp_Object local_value; |
| 363 | Lisp_Object handler_fn, value, type, check; | 368 | Lisp_Object handler_fn, value, type, check; |
| @@ -404,7 +409,8 @@ x_get_local_selection (selection_symbol, target_type) | |||
| 404 | pair = XVECTOR (pairs)->contents [i]; | 409 | pair = XVECTOR (pairs)->contents [i]; |
| 405 | XVECTOR (pair)->contents [1] | 410 | XVECTOR (pair)->contents [1] |
| 406 | = x_get_local_selection (XVECTOR (pair)->contents [0], | 411 | = x_get_local_selection (XVECTOR (pair)->contents [0], |
| 407 | XVECTOR (pair)->contents [1]); | 412 | XVECTOR (pair)->contents [1], |
| 413 | local_request); | ||
| 408 | } | 414 | } |
| 409 | return pairs; | 415 | return pairs; |
| 410 | } | 416 | } |
| @@ -421,7 +427,7 @@ x_get_local_selection (selection_symbol, target_type) | |||
| 421 | handler_fn = Fcdr (Fassq (target_type, Vselection_converter_alist)); | 427 | handler_fn = Fcdr (Fassq (target_type, Vselection_converter_alist)); |
| 422 | if (!NILP (handler_fn)) | 428 | if (!NILP (handler_fn)) |
| 423 | value = call3 (handler_fn, | 429 | value = call3 (handler_fn, |
| 424 | selection_symbol, target_type, | 430 | selection_symbol, (local_request ? Qnil : target_type), |
| 425 | XCAR (XCDR (local_value))); | 431 | XCAR (XCDR (local_value))); |
| 426 | else | 432 | else |
| 427 | value = Qnil; | 433 | value = Qnil; |
| @@ -801,7 +807,7 @@ x_handle_selection_request (event) | |||
| 801 | /* Convert lisp objects back into binary data */ | 807 | /* Convert lisp objects back into binary data */ |
| 802 | 808 | ||
| 803 | converted_selection | 809 | converted_selection |
| 804 | = x_get_local_selection (selection_symbol, target_symbol); | 810 | = x_get_local_selection (selection_symbol, target_symbol, 0); |
| 805 | 811 | ||
| 806 | if (! NILP (converted_selection)) | 812 | if (! NILP (converted_selection)) |
| 807 | { | 813 | { |
| @@ -1758,42 +1764,13 @@ lisp_data_to_selection_data (display, obj, | |||
| 1758 | } | 1764 | } |
| 1759 | else if (STRINGP (obj)) | 1765 | else if (STRINGP (obj)) |
| 1760 | { | 1766 | { |
| 1761 | /* Since we are now handling multilingual text, we must consider | 1767 | xassert (! STRING_MULTIBYTE (obj)); |
| 1762 | sending back compound text. */ | ||
| 1763 | int stringp; | ||
| 1764 | extern Lisp_Object Qcompound_text; | ||
| 1765 | |||
| 1766 | if (NILP (Vnext_selection_coding_system)) | ||
| 1767 | Vnext_selection_coding_system = Vselection_coding_system; | ||
| 1768 | |||
| 1769 | *format_ret = 8; | ||
| 1770 | /* If the requested type is STRING, we must encode the selected | ||
| 1771 | text as a string, even if the coding system set by the user | ||
| 1772 | is ctext or its derivatives. */ | ||
| 1773 | if (EQ (type, QSTRING) | ||
| 1774 | && (EQ (Vnext_selection_coding_system, Qcompound_text) | ||
| 1775 | || EQ (Vnext_selection_coding_system, | ||
| 1776 | Qcompound_text_with_extensions))) | ||
| 1777 | { | ||
| 1778 | Lisp_Object unibyte_string; | ||
| 1779 | |||
| 1780 | unibyte_string = string_make_unibyte (obj); | ||
| 1781 | *data_ret = SDATA (unibyte_string); | ||
| 1782 | *nofree_ret = 1; | ||
| 1783 | *size_ret = SBYTES (unibyte_string); | ||
| 1784 | } | ||
| 1785 | else | ||
| 1786 | { | ||
| 1787 | *data_ret = x_encode_text (obj, Vnext_selection_coding_system, 1, | ||
| 1788 | (int *) size_ret, &stringp); | ||
| 1789 | *nofree_ret = (*data_ret == SDATA (obj)); | ||
| 1790 | } | ||
| 1791 | if (NILP (type)) | 1768 | if (NILP (type)) |
| 1792 | type = (stringp ? QSTRING : QCOMPOUND_TEXT); | 1769 | type = QSTRING; |
| 1793 | Vlast_coding_system_used = (*nofree_ret | 1770 | *format_ret = 8; |
| 1794 | ? Qraw_text | 1771 | *size_ret = SBYTES (obj); |
| 1795 | : Vnext_selection_coding_system); | 1772 | *data_ret = SDATA (obj); |
| 1796 | Vnext_selection_coding_system = Qnil; | 1773 | *nofree_ret = 1; |
| 1797 | } | 1774 | } |
| 1798 | else if (SYMBOLP (obj)) | 1775 | else if (SYMBOLP (obj)) |
| 1799 | { | 1776 | { |
| @@ -2025,7 +2002,7 @@ TYPE is the type of data desired, typically `STRING'. */) | |||
| 2025 | #endif | 2002 | #endif |
| 2026 | CHECK_SYMBOL (target_type); | 2003 | CHECK_SYMBOL (target_type); |
| 2027 | 2004 | ||
| 2028 | val = x_get_local_selection (selection_symbol, target_type); | 2005 | val = x_get_local_selection (selection_symbol, target_type, 1); |
| 2029 | 2006 | ||
| 2030 | if (NILP (val)) | 2007 | if (NILP (val)) |
| 2031 | { | 2008 | { |
| @@ -2446,6 +2423,7 @@ A value of 0 means wait as long as necessary. This is initialized from the | |||
| 2446 | QTIMESTAMP = intern ("TIMESTAMP"); staticpro (&QTIMESTAMP); | 2423 | QTIMESTAMP = intern ("TIMESTAMP"); staticpro (&QTIMESTAMP); |
| 2447 | QTEXT = intern ("TEXT"); staticpro (&QTEXT); | 2424 | QTEXT = intern ("TEXT"); staticpro (&QTEXT); |
| 2448 | QCOMPOUND_TEXT = intern ("COMPOUND_TEXT"); staticpro (&QCOMPOUND_TEXT); | 2425 | QCOMPOUND_TEXT = intern ("COMPOUND_TEXT"); staticpro (&QCOMPOUND_TEXT); |
| 2426 | QUTF8_STRING = intern ("UTF8_STRING"); staticpro (&QUTF8_STRING); | ||
| 2449 | QTIMESTAMP = intern ("TIMESTAMP"); staticpro (&QTIMESTAMP); | 2427 | QTIMESTAMP = intern ("TIMESTAMP"); staticpro (&QTIMESTAMP); |
| 2450 | QDELETE = intern ("DELETE"); staticpro (&QDELETE); | 2428 | QDELETE = intern ("DELETE"); staticpro (&QDELETE); |
| 2451 | QMULTIPLE = intern ("MULTIPLE"); staticpro (&QMULTIPLE); | 2429 | QMULTIPLE = intern ("MULTIPLE"); staticpro (&QMULTIPLE); |