aboutsummaryrefslogtreecommitdiffstats
path: root/src/xselect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xselect.c')
-rw-r--r--src/xselect.c137
1 files changed, 39 insertions, 98 deletions
diff --git a/src/xselect.c b/src/xselect.c
index 459e5335123..6d076235316 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -183,8 +183,7 @@ static int x_queue_selection_requests;
183/* Queue up an SELECTION_REQUEST_EVENT *EVENT, to be processed later. */ 183/* Queue up an SELECTION_REQUEST_EVENT *EVENT, to be processed later. */
184 184
185static void 185static void
186x_queue_event (event) 186x_queue_event (struct input_event *event)
187 struct input_event *event;
188{ 187{
189 struct selection_event_queue *queue_tmp; 188 struct selection_event_queue *queue_tmp;
190 189
@@ -215,7 +214,7 @@ x_queue_event (event)
215/* Start queuing SELECTION_REQUEST_EVENT events. */ 214/* Start queuing SELECTION_REQUEST_EVENT events. */
216 215
217static void 216static void
218x_start_queuing_selection_requests () 217x_start_queuing_selection_requests (void)
219{ 218{
220 if (x_queue_selection_requests) 219 if (x_queue_selection_requests)
221 abort (); 220 abort ();
@@ -227,7 +226,7 @@ x_start_queuing_selection_requests ()
227/* Stop queuing SELECTION_REQUEST_EVENT events. */ 226/* Stop queuing SELECTION_REQUEST_EVENT events. */
228 227
229static void 228static void
230x_stop_queuing_selection_requests () 229x_stop_queuing_selection_requests (void)
231{ 230{
232 TRACE1 ("x_stop_queuing_selection_requests %d", x_queue_selection_requests); 231 TRACE1 ("x_stop_queuing_selection_requests %d", x_queue_selection_requests);
233 --x_queue_selection_requests; 232 --x_queue_selection_requests;
@@ -250,10 +249,7 @@ x_stop_queuing_selection_requests ()
250 roundtrip whenever possible. */ 249 roundtrip whenever possible. */
251 250
252static Atom 251static Atom
253symbol_to_x_atom (dpyinfo, display, sym) 252symbol_to_x_atom (struct x_display_info *dpyinfo, Display *display, Lisp_Object sym)
254 struct x_display_info *dpyinfo;
255 Display *display;
256 Lisp_Object sym;
257{ 253{
258 Atom val; 254 Atom val;
259 if (NILP (sym)) return 0; 255 if (NILP (sym)) return 0;
@@ -297,9 +293,7 @@ symbol_to_x_atom (dpyinfo, display, sym)
297 and calls to intern whenever possible. */ 293 and calls to intern whenever possible. */
298 294
299static Lisp_Object 295static Lisp_Object
300x_atom_to_symbol (dpy, atom) 296x_atom_to_symbol (Display *dpy, Atom atom)
301 Display *dpy;
302 Atom atom;
303{ 297{
304 struct x_display_info *dpyinfo; 298 struct x_display_info *dpyinfo;
305 char *str; 299 char *str;
@@ -382,8 +376,7 @@ x_atom_to_symbol (dpy, atom)
382 our selection. */ 376 our selection. */
383 377
384static void 378static void
385x_own_selection (selection_name, selection_value) 379x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value)
386 Lisp_Object selection_name, selection_value;
387{ 380{
388 struct frame *sf = SELECTED_FRAME (); 381 struct frame *sf = SELECTED_FRAME ();
389 Window selecting_window; 382 Window selecting_window;
@@ -449,9 +442,7 @@ x_own_selection (selection_name, selection_value)
449 This calls random Lisp code, and may signal or gc. */ 442 This calls random Lisp code, and may signal or gc. */
450 443
451static Lisp_Object 444static Lisp_Object
452x_get_local_selection (selection_symbol, target_type, local_request) 445x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, int local_request)
453 Lisp_Object selection_symbol, target_type;
454 int local_request;
455{ 446{
456 Lisp_Object local_value; 447 Lisp_Object local_value;
457 Lisp_Object handler_fn, value, type, check; 448 Lisp_Object handler_fn, value, type, check;
@@ -561,8 +552,7 @@ x_get_local_selection (selection_symbol, target_type, local_request)
561 meaning we were unable to do what they wanted. */ 552 meaning we were unable to do what they wanted. */
562 553
563static void 554static void
564x_decline_selection_request (event) 555x_decline_selection_request (struct input_event *event)
565 struct input_event *event;
566{ 556{
567 XSelectionEvent reply; 557 XSelectionEvent reply;
568 558
@@ -597,8 +587,7 @@ static struct x_display_info *selection_request_dpyinfo;
597 before we throw to top-level or go into the debugger or whatever. */ 587 before we throw to top-level or go into the debugger or whatever. */
598 588
599static Lisp_Object 589static Lisp_Object
600x_selection_request_lisp_error (ignore) 590x_selection_request_lisp_error (Lisp_Object ignore)
601 Lisp_Object ignore;
602{ 591{
603 if (x_selection_current_request != 0 592 if (x_selection_current_request != 0
604 && selection_request_dpyinfo->display) 593 && selection_request_dpyinfo->display)
@@ -607,8 +596,7 @@ x_selection_request_lisp_error (ignore)
607} 596}
608 597
609static Lisp_Object 598static Lisp_Object
610x_catch_errors_unwind (dummy) 599x_catch_errors_unwind (Lisp_Object dummy)
611 Lisp_Object dummy;
612{ 600{
613 BLOCK_INPUT; 601 BLOCK_INPUT;
614 x_uncatch_errors (); 602 x_uncatch_errors ();
@@ -634,10 +622,10 @@ struct prop_location
634 struct prop_location *next; 622 struct prop_location *next;
635}; 623};
636 624
637static struct prop_location *expect_property_change (); 625static struct prop_location *expect_property_change (Display *display, Window window, Atom property, int state);
638static void wait_for_property_change (); 626static void wait_for_property_change (struct prop_location *location);
639static void unexpect_property_change (); 627static void unexpect_property_change (struct prop_location *location);
640static int waiting_for_other_props_on_window (); 628static int waiting_for_other_props_on_window (Display *display, Window window);
641 629
642static int prop_location_identifier; 630static int prop_location_identifier;
643 631
@@ -648,8 +636,7 @@ static struct prop_location *property_change_reply_object;
648static struct prop_location *property_change_wait_list; 636static struct prop_location *property_change_wait_list;
649 637
650static Lisp_Object 638static Lisp_Object
651queue_selection_requests_unwind (tem) 639queue_selection_requests_unwind (Lisp_Object tem)
652 Lisp_Object tem;
653{ 640{
654 x_stop_queuing_selection_requests (); 641 x_stop_queuing_selection_requests ();
655 return Qnil; 642 return Qnil;
@@ -659,8 +646,7 @@ queue_selection_requests_unwind (tem)
659 Return nil if there is none. */ 646 Return nil if there is none. */
660 647
661static Lisp_Object 648static Lisp_Object
662some_frame_on_display (dpyinfo) 649some_frame_on_display (struct x_display_info *dpyinfo)
663 struct x_display_info *dpyinfo;
664{ 650{
665 Lisp_Object list, frame; 651 Lisp_Object list, frame;
666 652
@@ -684,11 +670,7 @@ static int x_reply_selection_request_cnt;
684#endif /* TRACE_SELECTION */ 670#endif /* TRACE_SELECTION */
685 671
686static void 672static void
687x_reply_selection_request (event, format, data, size, type) 673x_reply_selection_request (struct input_event *event, int format, unsigned char *data, int size, Atom type)
688 struct input_event *event;
689 int format, size;
690 unsigned char *data;
691 Atom type;
692{ 674{
693 XSelectionEvent reply; 675 XSelectionEvent reply;
694 Display *display = SELECTION_EVENT_DISPLAY (event); 676 Display *display = SELECTION_EVENT_DISPLAY (event);
@@ -881,8 +863,7 @@ x_reply_selection_request (event, format, data, size, type)
881 This is called from keyboard.c when such an event is found in the queue. */ 863 This is called from keyboard.c when such an event is found in the queue. */
882 864
883static void 865static void
884x_handle_selection_request (event) 866x_handle_selection_request (struct input_event *event)
885 struct input_event *event;
886{ 867{
887 struct gcpro gcpro1, gcpro2, gcpro3; 868 struct gcpro gcpro1, gcpro2, gcpro3;
888 Lisp_Object local_selection_data; 869 Lisp_Object local_selection_data;
@@ -1002,8 +983,7 @@ x_handle_selection_request (event)
1002 This is called from keyboard.c when such an event is found in the queue. */ 983 This is called from keyboard.c when such an event is found in the queue. */
1003 984
1004static void 985static void
1005x_handle_selection_clear (event) 986x_handle_selection_clear (struct input_event *event)
1006 struct input_event *event;
1007{ 987{
1008 Display *display = SELECTION_EVENT_DISPLAY (event); 988 Display *display = SELECTION_EVENT_DISPLAY (event);
1009 Atom selection = SELECTION_EVENT_SELECTION (event); 989 Atom selection = SELECTION_EVENT_SELECTION (event);
@@ -1085,8 +1065,7 @@ x_handle_selection_clear (event)
1085} 1065}
1086 1066
1087void 1067void
1088x_handle_selection_event (event) 1068x_handle_selection_event (struct input_event *event)
1089 struct input_event *event;
1090{ 1069{
1091 TRACE0 ("x_handle_selection_event"); 1070 TRACE0 ("x_handle_selection_event");
1092 1071
@@ -1106,8 +1085,7 @@ x_handle_selection_event (event)
1106 We do this when about to delete a frame. */ 1085 We do this when about to delete a frame. */
1107 1086
1108void 1087void
1109x_clear_frame_selections (f) 1088x_clear_frame_selections (FRAME_PTR f)
1110 FRAME_PTR f;
1111{ 1089{
1112 Lisp_Object frame; 1090 Lisp_Object frame;
1113 Lisp_Object rest; 1091 Lisp_Object rest;
@@ -1168,9 +1146,7 @@ x_clear_frame_selections (f)
1168 are on the list of what we are waiting for. */ 1146 are on the list of what we are waiting for. */
1169 1147
1170static int 1148static int
1171waiting_for_other_props_on_window (display, window) 1149waiting_for_other_props_on_window (Display *display, Window window)
1172 Display *display;
1173 Window window;
1174{ 1150{
1175 struct prop_location *rest = property_change_wait_list; 1151 struct prop_location *rest = property_change_wait_list;
1176 while (rest) 1152 while (rest)
@@ -1187,11 +1163,7 @@ waiting_for_other_props_on_window (display, window)
1187 this awaited property change. */ 1163 this awaited property change. */
1188 1164
1189static struct prop_location * 1165static struct prop_location *
1190expect_property_change (display, window, property, state) 1166expect_property_change (Display *display, Window window, Atom property, int state)
1191 Display *display;
1192 Window window;
1193 Atom property;
1194 int state;
1195{ 1167{
1196 struct prop_location *pl = (struct prop_location *) xmalloc (sizeof *pl); 1168 struct prop_location *pl = (struct prop_location *) xmalloc (sizeof *pl);
1197 pl->identifier = ++prop_location_identifier; 1169 pl->identifier = ++prop_location_identifier;
@@ -1209,8 +1181,7 @@ expect_property_change (display, window, property, state)
1209 IDENTIFIER is the number that uniquely identifies the entry. */ 1181 IDENTIFIER is the number that uniquely identifies the entry. */
1210 1182
1211static void 1183static void
1212unexpect_property_change (location) 1184unexpect_property_change (struct prop_location *location)
1213 struct prop_location *location;
1214{ 1185{
1215 struct prop_location *prev = 0, *rest = property_change_wait_list; 1186 struct prop_location *prev = 0, *rest = property_change_wait_list;
1216 while (rest) 1187 while (rest)
@@ -1232,8 +1203,7 @@ unexpect_property_change (location)
1232/* Remove the property change expectation element for IDENTIFIER. */ 1203/* Remove the property change expectation element for IDENTIFIER. */
1233 1204
1234static Lisp_Object 1205static Lisp_Object
1235wait_for_property_change_unwind (loc) 1206wait_for_property_change_unwind (Lisp_Object loc)
1236 Lisp_Object loc;
1237{ 1207{
1238 struct prop_location *location = XSAVE_VALUE (loc)->pointer; 1208 struct prop_location *location = XSAVE_VALUE (loc)->pointer;
1239 1209
@@ -1247,8 +1217,7 @@ wait_for_property_change_unwind (loc)
1247 IDENTIFIER should be the value that expect_property_change returned. */ 1217 IDENTIFIER should be the value that expect_property_change returned. */
1248 1218
1249static void 1219static void
1250wait_for_property_change (location) 1220wait_for_property_change (struct prop_location *location)
1251 struct prop_location *location;
1252{ 1221{
1253 int secs, usecs; 1222 int secs, usecs;
1254 int count = SPECPDL_INDEX (); 1223 int count = SPECPDL_INDEX ();
@@ -1286,8 +1255,7 @@ wait_for_property_change (location)
1286/* Called from XTread_socket in response to a PropertyNotify event. */ 1255/* Called from XTread_socket in response to a PropertyNotify event. */
1287 1256
1288void 1257void
1289x_handle_property_notify (event) 1258x_handle_property_notify (XPropertyEvent *event)
1290 XPropertyEvent *event;
1291{ 1259{
1292 struct prop_location *prev = 0, *rest = property_change_wait_list; 1260 struct prop_location *prev = 0, *rest = property_change_wait_list;
1293 1261
@@ -1378,8 +1346,7 @@ static Window reading_selection_window;
1378 Converts this to Lisp data and returns it. */ 1346 Converts this to Lisp data and returns it. */
1379 1347
1380static Lisp_Object 1348static Lisp_Object
1381x_get_foreign_selection (selection_symbol, target_type, time_stamp) 1349x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, Lisp_Object time_stamp)
1382 Lisp_Object selection_symbol, target_type, time_stamp;
1383{ 1350{
1384 struct frame *sf = SELECTED_FRAME (); 1351 struct frame *sf = SELECTED_FRAME ();
1385 Window requestor_window; 1352 Window requestor_window;
@@ -1809,11 +1776,7 @@ x_get_window_property_as_lisp_data (display, window, property, target_type,
1809 1776
1810 1777
1811static Lisp_Object 1778static Lisp_Object
1812selection_data_to_lisp_data (display, data, size, type, format) 1779selection_data_to_lisp_data (Display *display, unsigned char *data, int size, Atom type, int format)
1813 Display *display;
1814 unsigned char *data;
1815 Atom type;
1816 int size, format;
1817{ 1780{
1818 struct x_display_info *dpyinfo = x_display_info_for_display (display); 1781 struct x_display_info *dpyinfo = x_display_info_for_display (display);
1819 1782
@@ -2071,8 +2034,7 @@ lisp_data_to_selection_data (display, obj,
2071} 2034}
2072 2035
2073static Lisp_Object 2036static Lisp_Object
2074clean_local_selection_data (obj) 2037clean_local_selection_data (Lisp_Object obj)
2075 Lisp_Object obj;
2076{ 2038{
2077 if (CONSP (obj) 2039 if (CONSP (obj)
2078 && INTEGERP (XCAR (obj)) 2040 && INTEGERP (XCAR (obj))
@@ -2112,8 +2074,7 @@ clean_local_selection_data (obj)
2112 We store t there if the reply is successful, lambda if not. */ 2074 We store t there if the reply is successful, lambda if not. */
2113 2075
2114void 2076void
2115x_handle_selection_notify (event) 2077x_handle_selection_notify (XSelectionEvent *event)
2116 XSelectionEvent *event;
2117{ 2078{
2118 if (event->requestor != reading_selection_window) 2079 if (event->requestor != reading_selection_window)
2119 return; 2080 return;
@@ -2254,8 +2215,7 @@ Disowning it means there is no such selection. */)
2254 This is used when we kill a buffer. */ 2215 This is used when we kill a buffer. */
2255 2216
2256void 2217void
2257x_disown_buffer_selections (buffer) 2218x_disown_buffer_selections (Lisp_Object buffer)
2258 Lisp_Object buffer;
2259{ 2219{
2260 Lisp_Object tail; 2220 Lisp_Object tail;
2261 struct buffer *buf = XBUFFER (buffer); 2221 struct buffer *buf = XBUFFER (buffer);
@@ -2332,9 +2292,7 @@ and t is the same as `SECONDARY'. */)
2332 2292
2333/* Ensure that all 8 cut buffers exist. ICCCM says we gotta... */ 2293/* Ensure that all 8 cut buffers exist. ICCCM says we gotta... */
2334static void 2294static void
2335initialize_cut_buffers (display, window) 2295initialize_cut_buffers (Display *display, Window window)
2336 Display *display;
2337 Window window;
2338{ 2296{
2339 unsigned char *data = (unsigned char *) ""; 2297 unsigned char *data = (unsigned char *) "";
2340 BLOCK_INPUT; 2298 BLOCK_INPUT;
@@ -2530,8 +2488,7 @@ Positive N means shift the values forward, negative means backward. */)
2530 bit parts of a 32 bit number). */ 2488 bit parts of a 32 bit number). */
2531 2489
2532int 2490int
2533x_check_property_data (data) 2491x_check_property_data (Lisp_Object data)
2534 Lisp_Object data;
2535{ 2492{
2536 Lisp_Object iter; 2493 Lisp_Object iter;
2537 int size = 0; 2494 int size = 0;
@@ -2564,11 +2521,7 @@ x_check_property_data (data)
2564 XClientMessageEvent). */ 2521 XClientMessageEvent). */
2565 2522
2566void 2523void
2567x_fill_property_data (dpy, data, ret, format) 2524x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format)
2568 Display *dpy;
2569 Lisp_Object data;
2570 void *ret;
2571 int format;
2572{ 2525{
2573 long val; 2526 long val;
2574 long *d32 = (long *) ret; 2527 long *d32 = (long *) ret;
@@ -2620,12 +2573,7 @@ x_fill_property_data (dpy, data, ret, format)
2620 Also see comment for selection_data_to_lisp_data above. */ 2573 Also see comment for selection_data_to_lisp_data above. */
2621 2574
2622Lisp_Object 2575Lisp_Object
2623x_property_data_to_lisp (f, data, type, format, size) 2576x_property_data_to_lisp (struct frame *f, unsigned char *data, Atom type, int format, long unsigned int size)
2624 struct frame *f;
2625 unsigned char *data;
2626 Atom type;
2627 int format;
2628 unsigned long size;
2629{ 2577{
2630 return selection_data_to_lisp_data (FRAME_X_DISPLAY (f), 2578 return selection_data_to_lisp_data (FRAME_X_DISPLAY (f),
2631 data, size*format/8, type, format); 2579 data, size*format/8, type, format);
@@ -2634,10 +2582,7 @@ x_property_data_to_lisp (f, data, type, format, size)
2634/* Get the mouse position in frame relative coordinates. */ 2582/* Get the mouse position in frame relative coordinates. */
2635 2583
2636static void 2584static void
2637mouse_position_for_drop (f, x, y) 2585mouse_position_for_drop (FRAME_PTR f, int *x, int *y)
2638 FRAME_PTR f;
2639 int *x;
2640 int *y;
2641{ 2586{
2642 Window root, dummy_window; 2587 Window root, dummy_window;
2643 int dummy; 2588 int dummy;
@@ -2759,11 +2704,7 @@ FRAME is on. If FRAME is nil, the selected frame is used. */)
2759/* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. */ 2704/* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. */
2760 2705
2761int 2706int
2762x_handle_dnd_message (f, event, dpyinfo, bufp) 2707x_handle_dnd_message (struct frame *f, XClientMessageEvent *event, struct x_display_info *dpyinfo, struct input_event *bufp)
2763 struct frame *f;
2764 XClientMessageEvent *event;
2765 struct x_display_info *dpyinfo;
2766 struct input_event *bufp;
2767{ 2708{
2768 Lisp_Object vec; 2709 Lisp_Object vec;
2769 Lisp_Object frame; 2710 Lisp_Object frame;
@@ -2935,7 +2876,7 @@ are ignored. */)
2935 2876
2936 2877
2937void 2878void
2938syms_of_xselect () 2879syms_of_xselect (void)
2939{ 2880{
2940 defsubr (&Sx_get_selection_internal); 2881 defsubr (&Sx_get_selection_internal);
2941 defsubr (&Sx_own_selection_internal); 2882 defsubr (&Sx_own_selection_internal);