Mercurial > emacs
comparison src/xselect.c @ 13942:b01288cb5fc8
(x_get_foreign_selection): Renamed local variables
requester_window (from requestor_window), requester_time (from
requestor_time).
(syms_of_xselect): Doc fix for x-selection-timeout.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 04 Jan 1996 22:58:25 +0000 |
parents | 037f27af8c7b |
children | 51c6f601f42b |
comparison
equal
deleted
inserted
replaced
13941:b9e41e8f770d | 13942:b01288cb5fc8 |
---|---|
382 Fcons (handler_fn, Fcons (value, Qnil)))); | 382 Fcons (handler_fn, Fcons (value, Qnil)))); |
383 } | 383 } |
384 | 384 |
385 /* Subroutines of x_reply_selection_request. */ | 385 /* Subroutines of x_reply_selection_request. */ |
386 | 386 |
387 /* Send a SelectionNotify event to the requestor with property=None, | 387 /* Send a SelectionNotify event to the requester with property=None, |
388 meaning we were unable to do what they wanted. */ | 388 meaning we were unable to do what they wanted. */ |
389 | 389 |
390 static void | 390 static void |
391 x_decline_selection_request (event) | 391 x_decline_selection_request (event) |
392 struct input_event *event; | 392 struct input_event *event; |
393 { | 393 { |
394 XSelectionEvent reply; | 394 XSelectionEvent reply; |
395 reply.type = SelectionNotify; | 395 reply.type = SelectionNotify; |
396 reply.display = SELECTION_EVENT_DISPLAY (event); | 396 reply.display = SELECTION_EVENT_DISPLAY (event); |
397 reply.requestor = SELECTION_EVENT_REQUESTOR (event); | 397 reply.requester = SELECTION_EVENT_REQUESTER (event); |
398 reply.selection = SELECTION_EVENT_SELECTION (event); | 398 reply.selection = SELECTION_EVENT_SELECTION (event); |
399 reply.time = SELECTION_EVENT_TIME (event); | 399 reply.time = SELECTION_EVENT_TIME (event); |
400 reply.target = SELECTION_EVENT_TARGET (event); | 400 reply.target = SELECTION_EVENT_TARGET (event); |
401 reply.property = None; | 401 reply.property = None; |
402 | 402 |
403 BLOCK_INPUT; | 403 BLOCK_INPUT; |
404 XSendEvent (reply.display, reply.requestor, False, 0L, | 404 XSendEvent (reply.display, reply.requester, False, 0L, |
405 (XEvent *) &reply); | 405 (XEvent *) &reply); |
406 XFlush (reply.display); | 406 XFlush (reply.display); |
407 UNBLOCK_INPUT; | 407 UNBLOCK_INPUT; |
408 } | 408 } |
409 | 409 |
410 /* This is the selection request currently being processed. | 410 /* This is the selection request currently being processed. |
411 It is set to zero when the request is fully processed. */ | 411 It is set to zero when the request is fully processed. */ |
412 static struct input_event *x_selection_current_request; | 412 static struct input_event *x_selection_current_request; |
413 | 413 |
414 /* Used as an unwind-protect clause so that, if a selection-converter signals | 414 /* Used as an unwind-protect clause so that, if a selection-converter signals |
415 an error, we tell the requestor that we were unable to do what they wanted | 415 an error, we tell the requester that we were unable to do what they wanted |
416 before we throw to top-level or go into the debugger or whatever. */ | 416 before we throw to top-level or go into the debugger or whatever. */ |
417 | 417 |
418 static Lisp_Object | 418 static Lisp_Object |
419 x_selection_request_lisp_error (ignore) | 419 x_selection_request_lisp_error (ignore) |
420 Lisp_Object ignore; | 420 Lisp_Object ignore; |
496 unsigned char *data; | 496 unsigned char *data; |
497 Atom type; | 497 Atom type; |
498 { | 498 { |
499 XSelectionEvent reply; | 499 XSelectionEvent reply; |
500 Display *display = SELECTION_EVENT_DISPLAY (event); | 500 Display *display = SELECTION_EVENT_DISPLAY (event); |
501 Window window = SELECTION_EVENT_REQUESTOR (event); | 501 Window window = SELECTION_EVENT_REQUESTER (event); |
502 int bytes_remaining; | 502 int bytes_remaining; |
503 int format_bytes = format/8; | 503 int format_bytes = format/8; |
504 int max_bytes = SELECTION_QUANTUM (display); | 504 int max_bytes = SELECTION_QUANTUM (display); |
505 struct x_display_info *dpyinfo = x_display_info_for_display (display); | 505 struct x_display_info *dpyinfo = x_display_info_for_display (display); |
506 | 506 |
507 if (max_bytes > MAX_SELECTION_QUANTUM) | 507 if (max_bytes > MAX_SELECTION_QUANTUM) |
508 max_bytes = MAX_SELECTION_QUANTUM; | 508 max_bytes = MAX_SELECTION_QUANTUM; |
509 | 509 |
510 reply.type = SelectionNotify; | 510 reply.type = SelectionNotify; |
511 reply.display = display; | 511 reply.display = display; |
512 reply.requestor = window; | 512 reply.requester = window; |
513 reply.selection = SELECTION_EVENT_SELECTION (event); | 513 reply.selection = SELECTION_EVENT_SELECTION (event); |
514 reply.time = SELECTION_EVENT_TIME (event); | 514 reply.time = SELECTION_EVENT_TIME (event); |
515 reply.target = SELECTION_EVENT_TARGET (event); | 515 reply.target = SELECTION_EVENT_TARGET (event); |
516 reply.property = SELECTION_EVENT_PROPERTY (event); | 516 reply.property = SELECTION_EVENT_PROPERTY (event); |
517 if (reply.property == None) | 517 if (reply.property == None) |
574 XFlush (display); | 574 XFlush (display); |
575 | 575 |
576 had_errors = x_had_errors_p (display); | 576 had_errors = x_had_errors_p (display); |
577 UNBLOCK_INPUT; | 577 UNBLOCK_INPUT; |
578 | 578 |
579 /* First, wait for the requestor to ack by deleting the property. | 579 /* First, wait for the requester to ack by deleting the property. |
580 This can run random lisp code (process handlers) or signal. */ | 580 This can run random lisp code (process handlers) or signal. */ |
581 if (! had_errors) | 581 if (! had_errors) |
582 wait_for_property_change (wait_object); | 582 wait_for_property_change (wait_object); |
583 | 583 |
584 while (bytes_remaining) | 584 while (bytes_remaining) |
605 UNBLOCK_INPUT; | 605 UNBLOCK_INPUT; |
606 | 606 |
607 if (had_errors) | 607 if (had_errors) |
608 break; | 608 break; |
609 | 609 |
610 /* Now wait for the requestor to ack this chunk by deleting the | 610 /* Now wait for the requester to ack this chunk by deleting the |
611 property. This can run random lisp code or signal. | 611 property. This can run random lisp code or signal. |
612 */ | 612 */ |
613 wait_for_property_change (wait_object); | 613 wait_for_property_change (wait_object); |
614 } | 614 } |
615 /* Now write a zero-length chunk to the property to tell the requestor | 615 /* Now write a zero-length chunk to the property to tell the requester |
616 that we're done. */ | 616 that we're done. */ |
617 #if 0 | 617 #if 0 |
618 fprintf (stderr," INCR done\n"); | 618 fprintf (stderr," INCR done\n"); |
619 #endif | 619 #endif |
620 BLOCK_INPUT; | 620 BLOCK_INPUT; |
1028 static Lisp_Object | 1028 static Lisp_Object |
1029 fetch_multiple_target (event) | 1029 fetch_multiple_target (event) |
1030 XSelectionRequestEvent *event; | 1030 XSelectionRequestEvent *event; |
1031 { | 1031 { |
1032 Display *display = event->display; | 1032 Display *display = event->display; |
1033 Window window = event->requestor; | 1033 Window window = event->requester; |
1034 Atom target = event->target; | 1034 Atom target = event->target; |
1035 Atom selection_atom = event->selection; | 1035 Atom selection_atom = event->selection; |
1036 int result; | 1036 int result; |
1037 | 1037 |
1038 return | 1038 return |
1083 | 1083 |
1084 static Lisp_Object | 1084 static Lisp_Object |
1085 x_get_foreign_selection (selection_symbol, target_type) | 1085 x_get_foreign_selection (selection_symbol, target_type) |
1086 Lisp_Object selection_symbol, target_type; | 1086 Lisp_Object selection_symbol, target_type; |
1087 { | 1087 { |
1088 Window requestor_window = FRAME_X_WINDOW (selected_frame); | 1088 Window requester_window = FRAME_X_WINDOW (selected_frame); |
1089 Display *display = FRAME_X_DISPLAY (selected_frame); | 1089 Display *display = FRAME_X_DISPLAY (selected_frame); |
1090 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (selected_frame); | 1090 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (selected_frame); |
1091 Time requestor_time = last_event_timestamp; | 1091 Time requester_time = last_event_timestamp; |
1092 Atom target_property = dpyinfo->Xatom_EMACS_TMP; | 1092 Atom target_property = dpyinfo->Xatom_EMACS_TMP; |
1093 Atom selection_atom = symbol_to_x_atom (dpyinfo, display, selection_symbol); | 1093 Atom selection_atom = symbol_to_x_atom (dpyinfo, display, selection_symbol); |
1094 Atom type_atom; | 1094 Atom type_atom; |
1095 int secs, usecs; | 1095 int secs, usecs; |
1096 int count = specpdl_ptr - specpdl; | 1096 int count = specpdl_ptr - specpdl; |
1102 type_atom = symbol_to_x_atom (dpyinfo, display, target_type); | 1102 type_atom = symbol_to_x_atom (dpyinfo, display, target_type); |
1103 | 1103 |
1104 BLOCK_INPUT; | 1104 BLOCK_INPUT; |
1105 x_catch_errors (display); | 1105 x_catch_errors (display); |
1106 XConvertSelection (display, selection_atom, type_atom, target_property, | 1106 XConvertSelection (display, selection_atom, type_atom, target_property, |
1107 requestor_window, requestor_time); | 1107 requester_window, requester_time); |
1108 XFlush (display); | 1108 XFlush (display); |
1109 | 1109 |
1110 /* Prepare to block until the reply has been read. */ | 1110 /* Prepare to block until the reply has been read. */ |
1111 reading_selection_window = requestor_window; | 1111 reading_selection_window = requester_window; |
1112 reading_which_selection = selection_atom; | 1112 reading_which_selection = selection_atom; |
1113 XCONS (reading_selection_reply)->car = Qnil; | 1113 XCONS (reading_selection_reply)->car = Qnil; |
1114 | 1114 |
1115 frame = some_frame_on_display (dpyinfo); | 1115 frame = some_frame_on_display (dpyinfo); |
1116 | 1116 |
1140 if (NILP (XCONS (reading_selection_reply)->car)) | 1140 if (NILP (XCONS (reading_selection_reply)->car)) |
1141 error ("timed out waiting for reply from selection owner"); | 1141 error ("timed out waiting for reply from selection owner"); |
1142 | 1142 |
1143 /* Otherwise, the selection is waiting for us on the requested property. */ | 1143 /* Otherwise, the selection is waiting for us on the requested property. */ |
1144 return | 1144 return |
1145 x_get_window_property_as_lisp_data (display, requestor_window, | 1145 x_get_window_property_as_lisp_data (display, requester_window, |
1146 target_property, target_type, | 1146 target_property, target_type, |
1147 selection_atom); | 1147 selection_atom); |
1148 } | 1148 } |
1149 | 1149 |
1150 /* Subroutines of x_get_window_property_as_lisp_data */ | 1150 /* Subroutines of x_get_window_property_as_lisp_data */ |
1194 } | 1194 } |
1195 | 1195 |
1196 total_size = bytes_remaining + 1; | 1196 total_size = bytes_remaining + 1; |
1197 *data_ret = (unsigned char *) xmalloc (total_size); | 1197 *data_ret = (unsigned char *) xmalloc (total_size); |
1198 | 1198 |
1199 /* Now read, until weve gotten it all. */ | 1199 /* Now read, until we've gotten it all. */ |
1200 while (bytes_remaining) | 1200 while (bytes_remaining) |
1201 { | 1201 { |
1202 #if 0 | 1202 #if 0 |
1203 int last = bytes_remaining; | 1203 int last = bytes_remaining; |
1204 #endif | 1204 #endif |
1271 { | 1271 { |
1272 unsigned char *tmp_data; | 1272 unsigned char *tmp_data; |
1273 int tmp_size_bytes; | 1273 int tmp_size_bytes; |
1274 wait_for_property_change (wait_object); | 1274 wait_for_property_change (wait_object); |
1275 /* expect it again immediately, because x_get_window_property may | 1275 /* expect it again immediately, because x_get_window_property may |
1276 .. no it wont, I dont get it. | 1276 .. no it won't, I don't get it. |
1277 .. Ok, I get it now, the Xt code that implements INCR is broken. | 1277 .. Ok, I get it now, the Xt code that implements INCR is broken. |
1278 */ | 1278 */ |
1279 x_get_window_property (display, window, property, | 1279 x_get_window_property (display, window, property, |
1280 &tmp_data, &tmp_size_bytes, | 1280 &tmp_data, &tmp_size_bytes, |
1281 type_ret, format_ret, size_ret, 1); | 1281 type_ret, format_ret, size_ret, 1); |
1695 | 1695 |
1696 void | 1696 void |
1697 x_handle_selection_notify (event) | 1697 x_handle_selection_notify (event) |
1698 XSelectionEvent *event; | 1698 XSelectionEvent *event; |
1699 { | 1699 { |
1700 if (event->requestor != reading_selection_window) | 1700 if (event->requester != reading_selection_window) |
1701 return; | 1701 return; |
1702 if (event->selection != reading_which_selection) | 1702 if (event->selection != reading_which_selection) |
1703 return; | 1703 return; |
1704 | 1704 |
1705 XCONS (reading_selection_reply)->car = Qt; | 1705 XCONS (reading_selection_reply)->car = Qt; |
2140 it merely informs you that they have happened."); | 2140 it merely informs you that they have happened."); |
2141 Vx_sent_selection_hooks = Qnil; | 2141 Vx_sent_selection_hooks = Qnil; |
2142 | 2142 |
2143 DEFVAR_INT ("x-selection-timeout", &x_selection_timeout, | 2143 DEFVAR_INT ("x-selection-timeout", &x_selection_timeout, |
2144 "Number of milliseconds to wait for a selection reply.\n\ | 2144 "Number of milliseconds to wait for a selection reply.\n\ |
2145 If the selection owner doens't reply in this time, we give up.\n\ | 2145 If the selection owner doesn't reply in this time, we give up.\n\ |
2146 A value of 0 means wait as long as necessary. This is initialized from the\n\ | 2146 A value of 0 means wait as long as necessary. This is initialized from the\n\ |
2147 \"*selectionTimeout\" resource."); | 2147 \"*selectionTimeout\" resource."); |
2148 x_selection_timeout = 0; | 2148 x_selection_timeout = 0; |
2149 | 2149 |
2150 QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY); | 2150 QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY); |