diff options
| author | Richard M. Stallman | 1995-02-06 22:53:58 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-02-06 22:53:58 +0000 |
| commit | 55b2d45daa23b6dcb721b471bd2202c87be20820 (patch) | |
| tree | 660b92dc27e04c5ab753c7d2429da116cffca2cd /src | |
| parent | 276cbe5a5f38c5b3313245ceea7d06e01da47f33 (diff) | |
| download | emacs-55b2d45daa23b6dcb721b471bd2202c87be20820.tar.gz emacs-55b2d45daa23b6dcb721b471bd2202c87be20820.zip | |
(x_get_foreign_selection, x_reply_selection_request):
Use an unwind-protect to call x_stop_queuing_selection_requests.
(some_frame_on_display): New function.
(queue_selection_requests_unwind): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xselect.c | 70 |
1 files changed, 63 insertions, 7 deletions
diff --git a/src/xselect.c b/src/xselect.c index 5e7432e9e47..f8f12cbbeeb 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -458,6 +458,34 @@ static Lisp_Object property_change_reply; | |||
| 458 | static struct prop_location *property_change_reply_object; | 458 | static struct prop_location *property_change_reply_object; |
| 459 | 459 | ||
| 460 | static struct prop_location *property_change_wait_list; | 460 | static struct prop_location *property_change_wait_list; |
| 461 | |||
| 462 | static Lisp_Object | ||
| 463 | queue_selection_requests_unwind (frame) | ||
| 464 | Lisp_Object frame; | ||
| 465 | { | ||
| 466 | FRAME_PTR f = XFRAME (frame); | ||
| 467 | |||
| 468 | if (! NILP (frame)) | ||
| 469 | x_stop_queuing_selection_requests (FRAME_X_DISPLAY (f)); | ||
| 470 | } | ||
| 471 | |||
| 472 | /* Return some frame whose display info is DPYINFO. | ||
| 473 | Return nil if there is none. */ | ||
| 474 | |||
| 475 | static Lisp_Object | ||
| 476 | some_frame_on_display (dpyinfo) | ||
| 477 | struct x_display_info *dpyinfo; | ||
| 478 | { | ||
| 479 | Lisp_Object list, frame; | ||
| 480 | |||
| 481 | FOR_EACH_FRAME (list, frame) | ||
| 482 | { | ||
| 483 | if (FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo) | ||
| 484 | return frame; | ||
| 485 | } | ||
| 486 | |||
| 487 | return Qnil; | ||
| 488 | } | ||
| 461 | 489 | ||
| 462 | /* Send the reply to a selection request event EVENT. | 490 | /* Send the reply to a selection request event EVENT. |
| 463 | TYPE is the type of selection data requested. | 491 | TYPE is the type of selection data requested. |
| @@ -516,8 +544,21 @@ x_reply_selection_request (event, format, data, size, type) | |||
| 516 | /* Send an INCR selection. */ | 544 | /* Send an INCR selection. */ |
| 517 | struct prop_location *wait_object; | 545 | struct prop_location *wait_object; |
| 518 | int had_errors; | 546 | int had_errors; |
| 547 | int count = specpdl_ptr - specpdl; | ||
| 548 | Lisp_Object frame; | ||
| 519 | 549 | ||
| 520 | x_start_queuing_selection_requests (display); | 550 | frame = some_frame_on_display (dpyinfo); |
| 551 | |||
| 552 | /* If the display no longer has frames, we can't expect | ||
| 553 | to get many more selection requests from it, so don't | ||
| 554 | bother trying to queue them. */ | ||
| 555 | if (!NILP (frame)) | ||
| 556 | { | ||
| 557 | x_start_queuing_selection_requests (display); | ||
| 558 | |||
| 559 | record_unwind_protect (queue_selection_requests_unwind, | ||
| 560 | frame); | ||
| 561 | } | ||
| 521 | 562 | ||
| 522 | if (x_window_to_frame (window)) /* #### debug */ | 563 | if (x_window_to_frame (window)) /* #### debug */ |
| 523 | error ("attempt to transfer an INCR to ourself!"); | 564 | error ("attempt to transfer an INCR to ourself!"); |
| @@ -528,11 +569,11 @@ x_reply_selection_request (event, format, data, size, type) | |||
| 528 | PropertyDelete); | 569 | PropertyDelete); |
| 529 | 570 | ||
| 530 | XChangeProperty (display, window, reply.property, dpyinfo->Xatom_INCR, | 571 | XChangeProperty (display, window, reply.property, dpyinfo->Xatom_INCR, |
| 531 | 32, PropModeReplace, (unsigned char *) | 572 | 32, PropModeReplace, |
| 532 | &bytes_remaining, 1); | 573 | (unsigned char *) &bytes_remaining, 1); |
| 533 | XSelectInput (display, window, PropertyChangeMask); | 574 | XSelectInput (display, window, PropertyChangeMask); |
| 534 | /* Tell 'em the INCR data is there... */ | 575 | /* Tell 'em the INCR data is there... */ |
| 535 | (void) XSendEvent (display, window, False, 0L, (XEvent *) &reply); | 576 | XSendEvent (display, window, False, 0L, (XEvent *) &reply); |
| 536 | XFlush (display); | 577 | XFlush (display); |
| 537 | 578 | ||
| 538 | had_errors = x_had_errors_p (display); | 579 | had_errors = x_had_errors_p (display); |
| @@ -585,7 +626,8 @@ x_reply_selection_request (event, format, data, size, type) | |||
| 585 | 626 | ||
| 586 | XChangeProperty (display, window, reply.property, type, format, | 627 | XChangeProperty (display, window, reply.property, type, format, |
| 587 | PropModeReplace, data, 0); | 628 | PropModeReplace, data, 0); |
| 588 | x_stop_queuing_selection_requests (display); | 629 | |
| 630 | unbind_to (count, Qnil); | ||
| 589 | } | 631 | } |
| 590 | 632 | ||
| 591 | XFlush (display); | 633 | XFlush (display); |
| @@ -1051,6 +1093,8 @@ x_get_foreign_selection (selection_symbol, target_type) | |||
| 1051 | Atom selection_atom = symbol_to_x_atom (dpyinfo, display, selection_symbol); | 1093 | Atom selection_atom = symbol_to_x_atom (dpyinfo, display, selection_symbol); |
| 1052 | Atom type_atom; | 1094 | Atom type_atom; |
| 1053 | int secs, usecs; | 1095 | int secs, usecs; |
| 1096 | int count = specpdl_ptr - specpdl; | ||
| 1097 | Lisp_Object frame; | ||
| 1054 | 1098 | ||
| 1055 | if (CONSP (target_type)) | 1099 | if (CONSP (target_type)) |
| 1056 | type_atom = symbol_to_x_atom (dpyinfo, display, XCONS (target_type)->car); | 1100 | type_atom = symbol_to_x_atom (dpyinfo, display, XCONS (target_type)->car); |
| @@ -1067,7 +1111,19 @@ x_get_foreign_selection (selection_symbol, target_type) | |||
| 1067 | reading_selection_window = requestor_window; | 1111 | reading_selection_window = requestor_window; |
| 1068 | reading_which_selection = selection_atom; | 1112 | reading_which_selection = selection_atom; |
| 1069 | XCONS (reading_selection_reply)->car = Qnil; | 1113 | XCONS (reading_selection_reply)->car = Qnil; |
| 1070 | x_start_queuing_selection_requests (display); | 1114 | |
| 1115 | frame = some_frame_on_display (dpyinfo); | ||
| 1116 | |||
| 1117 | /* If the display no longer has frames, we can't expect | ||
| 1118 | to get many more selection requests from it, so don't | ||
| 1119 | bother trying to queue them. */ | ||
| 1120 | if (!NILP (frame)) | ||
| 1121 | { | ||
| 1122 | x_start_queuing_selection_requests (display); | ||
| 1123 | |||
| 1124 | record_unwind_protect (queue_selection_requests_unwind, | ||
| 1125 | frame); | ||
| 1126 | } | ||
| 1071 | UNBLOCK_INPUT; | 1127 | UNBLOCK_INPUT; |
| 1072 | 1128 | ||
| 1073 | /* This allows quits. Also, don't wait forever. */ | 1129 | /* This allows quits. Also, don't wait forever. */ |
| @@ -1078,7 +1134,7 @@ x_get_foreign_selection (selection_symbol, target_type) | |||
| 1078 | BLOCK_INPUT; | 1134 | BLOCK_INPUT; |
| 1079 | x_check_errors (display, "Cannot get selection: %s"); | 1135 | x_check_errors (display, "Cannot get selection: %s"); |
| 1080 | x_uncatch_errors (display); | 1136 | x_uncatch_errors (display); |
| 1081 | x_stop_queuing_selection_requests (display); | 1137 | unbind_to (count, Qnil); |
| 1082 | UNBLOCK_INPUT; | 1138 | UNBLOCK_INPUT; |
| 1083 | 1139 | ||
| 1084 | if (NILP (XCONS (reading_selection_reply)->car)) | 1140 | if (NILP (XCONS (reading_selection_reply)->car)) |