comparison src/xselect.c @ 83533:02e39decdc84

Merged from emacs@sv.gnu.org Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-351 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-352 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-353 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-354 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-355 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-356 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-357 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-358 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-359 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-360 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-361 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-362 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-363 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-364 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-365 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-366 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-367 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-368 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-369 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-370 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-115 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-116 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-117 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-118 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-119 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-120 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-573
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 29 Jul 2006 09:59:12 +0000
parents 414faf8dce4e e650d66ac6db
children 694bbb62a75d
comparison
equal deleted inserted replaced
83532:b19aaf4ab0ee 83533:02e39decdc84
560 || 560 ||
561 (CONSP (XCDR (check)) 561 (CONSP (XCDR (check))
562 && INTEGERP (XCAR (XCDR (check))) 562 && INTEGERP (XCAR (XCDR (check)))
563 && NILP (XCDR (XCDR (check)))))) 563 && NILP (XCDR (XCDR (check))))))
564 return value; 564 return value;
565 else 565
566 return 566 signal_error ("Invalid data returned by selection-conversion function",
567 Fsignal (Qerror, 567 list2 (handler_fn, value));
568 Fcons (build_string ("invalid data returned by selection-conversion function"),
569 Fcons (handler_fn, Fcons (value, Qnil))));
570 } 568 }
571 569
572 /* Subroutines of x_reply_selection_request. */ 570 /* Subroutines of x_reply_selection_request. */
573 571
574 /* Send a SelectionNotify event to the requestor with property=None, 572 /* Send a SelectionNotify event to the requestor with property=None,
1354 { 1352 {
1355 Lisp_Object vec2 = XVECTOR (obj)->contents [i]; 1353 Lisp_Object vec2 = XVECTOR (obj)->contents [i];
1356 CHECK_VECTOR (vec2); 1354 CHECK_VECTOR (vec2);
1357 if (XVECTOR (vec2)->size != 2) 1355 if (XVECTOR (vec2)->size != 2)
1358 /* ??? Confusing error message */ 1356 /* ??? Confusing error message */
1359 Fsignal (Qerror, Fcons (build_string ("vectors must be of length 2"), 1357 signal_error ("Vectors must be of length 2", vec2);
1360 Fcons (vec2, Qnil)));
1361 XVECTOR (vec)->contents [i] = Fmake_vector (2, Qnil); 1358 XVECTOR (vec)->contents [i] = Fmake_vector (2, Qnil);
1362 XVECTOR (XVECTOR (vec)->contents [i])->contents [0] 1359 XVECTOR (XVECTOR (vec)->contents [i])->contents [0]
1363 = XVECTOR (vec2)->contents [0]; 1360 = XVECTOR (vec2)->contents [0];
1364 XVECTOR (XVECTOR (vec)->contents [i])->contents [1] 1361 XVECTOR (XVECTOR (vec)->contents [i])->contents [1]
1365 = XVECTOR (vec2)->contents [1]; 1362 = XVECTOR (vec2)->contents [1];
1732 int there_is_a_selection_owner; 1729 int there_is_a_selection_owner;
1733 BLOCK_INPUT; 1730 BLOCK_INPUT;
1734 there_is_a_selection_owner 1731 there_is_a_selection_owner
1735 = XGetSelectionOwner (display, selection_atom); 1732 = XGetSelectionOwner (display, selection_atom);
1736 UNBLOCK_INPUT; 1733 UNBLOCK_INPUT;
1737 Fsignal (Qerror, 1734 if (there_is_a_selection_owner)
1738 there_is_a_selection_owner 1735 signal_error ("Selection owner couldn't convert",
1739 ? Fcons (build_string ("selection owner couldn't convert"), 1736 actual_type
1740 actual_type 1737 ? list2 (target_type,
1741 ? Fcons (target_type, 1738 x_atom_to_symbol (display, actual_type))
1742 Fcons (x_atom_to_symbol (display, 1739 : target_type);
1743 actual_type), 1740 else
1744 Qnil)) 1741 signal_error ("No selection",
1745 : Fcons (target_type, Qnil)) 1742 x_atom_to_symbol (display, selection_atom));
1746 : Fcons (build_string ("no selection"),
1747 Fcons (x_atom_to_symbol (display,
1748 selection_atom),
1749 Qnil)));
1750 } 1743 }
1751 1744
1752 if (actual_type == dpyinfo->Xatom_INCR) 1745 if (actual_type == dpyinfo->Xatom_INCR)
1753 { 1746 {
1754 /* That wasn't really the data, just the beginning. */ 1747 /* That wasn't really the data, just the beginning. */
1944 } 1937 }
1945 else if (STRINGP (obj)) 1938 else if (STRINGP (obj))
1946 { 1939 {
1947 if (SCHARS (obj) < SBYTES (obj)) 1940 if (SCHARS (obj) < SBYTES (obj))
1948 /* OBJ is a multibyte string containing a non-ASCII char. */ 1941 /* OBJ is a multibyte string containing a non-ASCII char. */
1949 Fsignal (Qerror, /* Qselection_error */ 1942 signal_error ("Non-ASCII string must be encoded in advance", obj);
1950 Fcons (build_string
1951 ("Non-ASCII string must be encoded in advance"),
1952 Fcons (obj, Qnil)));
1953 if (NILP (type)) 1943 if (NILP (type))
1954 type = QSTRING; 1944 type = QSTRING;
1955 *format_ret = 8; 1945 *format_ret = 8;
1956 *size_ret = SBYTES (obj); 1946 *size_ret = SBYTES (obj);
1957 *data_ret = SDATA (obj); 1947 *data_ret = SDATA (obj);
2008 for (i = 0; i < *size_ret; i++) 1998 for (i = 0; i < *size_ret; i++)
2009 if (SYMBOLP (XVECTOR (obj)->contents [i])) 1999 if (SYMBOLP (XVECTOR (obj)->contents [i]))
2010 (*(Atom **) data_ret) [i] 2000 (*(Atom **) data_ret) [i]
2011 = symbol_to_x_atom (dpyinfo, display, XVECTOR (obj)->contents [i]); 2001 = symbol_to_x_atom (dpyinfo, display, XVECTOR (obj)->contents [i]);
2012 else 2002 else
2013 Fsignal (Qerror, /* Qselection_error */ 2003 signal_error ("All elements of selection vector must have same type", obj);
2014 Fcons (build_string
2015 ("all elements of selection vector must have same type"),
2016 Fcons (obj, Qnil)));
2017 } 2004 }
2018 #if 0 /* #### MULTIPLE doesn't work yet */ 2005 #if 0 /* #### MULTIPLE doesn't work yet */
2019 else if (VECTORP (XVECTOR (obj)->contents [0])) 2006 else if (VECTORP (XVECTOR (obj)->contents [0]))
2020 /* This vector is an ATOM_PAIR set */ 2007 /* This vector is an ATOM_PAIR set */
2021 { 2008 {
2027 for (i = 0; i < *size_ret; i++) 2014 for (i = 0; i < *size_ret; i++)
2028 if (VECTORP (XVECTOR (obj)->contents [i])) 2015 if (VECTORP (XVECTOR (obj)->contents [i]))
2029 { 2016 {
2030 Lisp_Object pair = XVECTOR (obj)->contents [i]; 2017 Lisp_Object pair = XVECTOR (obj)->contents [i];
2031 if (XVECTOR (pair)->size != 2) 2018 if (XVECTOR (pair)->size != 2)
2032 Fsignal (Qerror, 2019 signal_error (
2033 Fcons (build_string 2020 "Elements of the vector must be vectors of exactly two elements",
2034 ("elements of the vector must be vectors of exactly two elements"), 2021 pair);
2035 Fcons (pair, Qnil)));
2036 2022
2037 (*(Atom **) data_ret) [i * 2] 2023 (*(Atom **) data_ret) [i * 2]
2038 = symbol_to_x_atom (dpyinfo, display, 2024 = symbol_to_x_atom (dpyinfo, display,
2039 XVECTOR (pair)->contents [0]); 2025 XVECTOR (pair)->contents [0]);
2040 (*(Atom **) data_ret) [(i * 2) + 1] 2026 (*(Atom **) data_ret) [(i * 2) + 1]
2041 = symbol_to_x_atom (dpyinfo, display, 2027 = symbol_to_x_atom (dpyinfo, display,
2042 XVECTOR (pair)->contents [1]); 2028 XVECTOR (pair)->contents [1]);
2043 } 2029 }
2044 else 2030 else
2045 Fsignal (Qerror, 2031 signal_error ("All elements of the vector must be of the same type",
2046 Fcons (build_string 2032 obj);
2047 ("all elements of the vector must be of the same type"),
2048 Fcons (obj, Qnil)));
2049 2033
2050 } 2034 }
2051 #endif 2035 #endif
2052 else 2036 else
2053 /* This vector is an INTEGER set, or something like it */ 2037 /* This vector is an INTEGER set, or something like it */
2058 *format_ret = 16; 2042 *format_ret = 16;
2059 for (i = 0; i < *size_ret; i++) 2043 for (i = 0; i < *size_ret; i++)
2060 if (CONSP (XVECTOR (obj)->contents [i])) 2044 if (CONSP (XVECTOR (obj)->contents [i]))
2061 *format_ret = 32; 2045 *format_ret = 32;
2062 else if (!INTEGERP (XVECTOR (obj)->contents [i])) 2046 else if (!INTEGERP (XVECTOR (obj)->contents [i]))
2063 Fsignal (Qerror, /* Qselection_error */ 2047 signal_error (/* Qselection_error */
2064 Fcons (build_string 2048 "Elements of selection vector must be integers or conses of integers",
2065 ("elements of selection vector must be integers or conses of integers"), 2049 obj);
2066 Fcons (obj, Qnil)));
2067 2050
2068 /* Use sizeof(long) even if it is more than 32 bits. See comment 2051 /* Use sizeof(long) even if it is more than 32 bits. See comment
2069 in x_get_window_property and x_fill_property_data. */ 2052 in x_get_window_property and x_fill_property_data. */
2070 2053
2071 if (*format_ret == 32) data_size = sizeof(long); 2054 if (*format_ret == 32) data_size = sizeof(long);
2078 (*((unsigned short **) data_ret)) [i] 2061 (*((unsigned short **) data_ret)) [i]
2079 = (unsigned short) cons_to_long (XVECTOR (obj)->contents [i]); 2062 = (unsigned short) cons_to_long (XVECTOR (obj)->contents [i]);
2080 } 2063 }
2081 } 2064 }
2082 else 2065 else
2083 Fsignal (Qerror, /* Qselection_error */ 2066 signal_error (/* Qselection_error */ "Unrecognized selection data", obj);
2084 Fcons (build_string ("unrecognized selection data"),
2085 Fcons (obj, Qnil)));
2086 2067
2087 *type_ret = symbol_to_x_atom (dpyinfo, display, type); 2068 *type_ret = symbol_to_x_atom (dpyinfo, display, type);
2088 } 2069 }
2089 2070
2090 static Lisp_Object 2071 static Lisp_Object
2369 UNBLOCK_INPUT; 2350 UNBLOCK_INPUT;
2370 } 2351 }
2371 2352
2372 2353
2373 #define CHECK_CUT_BUFFER(symbol) \ 2354 #define CHECK_CUT_BUFFER(symbol) \
2374 { CHECK_SYMBOL ((symbol)); \ 2355 do { CHECK_SYMBOL ((symbol)); \
2375 if (!EQ((symbol), QCUT_BUFFER0) && !EQ((symbol), QCUT_BUFFER1) \ 2356 if (!EQ((symbol), QCUT_BUFFER0) && !EQ((symbol), QCUT_BUFFER1) \
2376 && !EQ((symbol), QCUT_BUFFER2) && !EQ((symbol), QCUT_BUFFER3) \ 2357 && !EQ((symbol), QCUT_BUFFER2) && !EQ((symbol), QCUT_BUFFER3) \
2377 && !EQ((symbol), QCUT_BUFFER4) && !EQ((symbol), QCUT_BUFFER5) \ 2358 && !EQ((symbol), QCUT_BUFFER4) && !EQ((symbol), QCUT_BUFFER5) \
2378 && !EQ((symbol), QCUT_BUFFER6) && !EQ((symbol), QCUT_BUFFER7)) \ 2359 && !EQ((symbol), QCUT_BUFFER6) && !EQ((symbol), QCUT_BUFFER7)) \
2379 Fsignal (Qerror, \ 2360 signal_error ("Doesn't name a cut buffer", (symbol)); \
2380 Fcons (build_string ("doesn't name a cut buffer"), \ 2361 } while (0)
2381 Fcons ((symbol), Qnil))); \
2382 }
2383 2362
2384 DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal, 2363 DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal,
2385 Sx_get_cut_buffer_internal, 1, 1, 0, 2364 Sx_get_cut_buffer_internal, 1, 1, 0,
2386 doc: /* Returns the value of the named cut buffer (typically CUT_BUFFER0). */) 2365 doc: /* Returns the value of the named cut buffer (typically CUT_BUFFER0). */)
2387 (buffer) 2366 (buffer)
2414 &type, &format, &size, 0); 2393 &type, &format, &size, 0);
2415 if (!data || !format) 2394 if (!data || !format)
2416 return Qnil; 2395 return Qnil;
2417 2396
2418 if (format != 8 || type != XA_STRING) 2397 if (format != 8 || type != XA_STRING)
2419 Fsignal (Qerror, 2398 signal_error ("Cut buffer doesn't contain 8-bit data",
2420 Fcons (build_string ("cut buffer doesn't contain 8-bit data"), 2399 list2 (x_atom_to_symbol (display, type),
2421 Fcons (x_atom_to_symbol (display, type), 2400 make_number (format)));
2422 Fcons (make_number (format), Qnil))));
2423 2401
2424 ret = (bytes ? make_unibyte_string ((char *) data, bytes) : Qnil); 2402 ret = (bytes ? make_unibyte_string ((char *) data, bytes) : Qnil);
2425 /* Use xfree, not XFree, because x_get_window_property 2403 /* Use xfree, not XFree, because x_get_window_property
2426 calls xmalloc itself. */ 2404 calls xmalloc itself. */
2427 xfree (data); 2405 xfree (data);