diff options
| author | Po Lu | 2022-07-11 10:07:21 +0800 |
|---|---|---|
| committer | Po Lu | 2022-07-11 10:07:21 +0800 |
| commit | d9464d7fe5d21bd46254bbb691f5d3db34fe6324 (patch) | |
| tree | 42323517c6211abf1022d0a94778429e0fac4142 /src | |
| parent | b283e36cf1902eeb6d532077e1f46270aa1224e1 (diff) | |
| download | emacs-d9464d7fe5d21bd46254bbb691f5d3db34fe6324.tar.gz emacs-d9464d7fe5d21bd46254bbb691f5d3db34fe6324.zip | |
Handle errors sending selection decline events asynchronously
* src/xselect.c (x_decline_selection_request): Handle errors
asynchronously.
* src/xterm.c (x_ignore_errors_for_next_request)
(x_stop_ignoring_errors): Export functions.
* src/xterm.h: Update prototypes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xselect.c | 23 | ||||
| -rw-r--r-- | src/xterm.c | 6 | ||||
| -rw-r--r-- | src/xterm.h | 2 |
3 files changed, 21 insertions, 10 deletions
diff --git a/src/xselect.c b/src/xselect.c index 80db0d1fe2a..25a75aec917 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -437,10 +437,19 @@ static void | |||
| 437 | x_decline_selection_request (struct selection_input_event *event) | 437 | x_decline_selection_request (struct selection_input_event *event) |
| 438 | { | 438 | { |
| 439 | XEvent reply_base; | 439 | XEvent reply_base; |
| 440 | XSelectionEvent *reply = &(reply_base.xselection); | 440 | XSelectionEvent *reply; |
| 441 | Display *dpy; | ||
| 442 | struct x_display_info *dpyinfo; | ||
| 443 | |||
| 444 | reply = &(reply_base.xselection); | ||
| 445 | dpy = SELECTION_EVENT_DISPLAY (event); | ||
| 446 | dpyinfo = x_display_info_for_display (dpy); | ||
| 447 | |||
| 448 | if (!dpyinfo) | ||
| 449 | return; | ||
| 441 | 450 | ||
| 442 | reply->type = SelectionNotify; | 451 | reply->type = SelectionNotify; |
| 443 | reply->display = SELECTION_EVENT_DISPLAY (event); | 452 | reply->display = dpy; |
| 444 | reply->requestor = SELECTION_EVENT_REQUESTOR (event); | 453 | reply->requestor = SELECTION_EVENT_REQUESTOR (event); |
| 445 | reply->selection = SELECTION_EVENT_SELECTION (event); | 454 | reply->selection = SELECTION_EVENT_SELECTION (event); |
| 446 | reply->time = SELECTION_EVENT_TIME (event); | 455 | reply->time = SELECTION_EVENT_TIME (event); |
| @@ -450,10 +459,12 @@ x_decline_selection_request (struct selection_input_event *event) | |||
| 450 | /* The reason for the error may be that the receiver has | 459 | /* The reason for the error may be that the receiver has |
| 451 | died in the meantime. Handle that case. */ | 460 | died in the meantime. Handle that case. */ |
| 452 | block_input (); | 461 | block_input (); |
| 453 | x_catch_errors (reply->display); | 462 | x_ignore_errors_for_next_request (dpyinfo); |
| 454 | XSendEvent (reply->display, reply->requestor, False, 0, &reply_base); | 463 | XSendEvent (dpyinfo->display, reply->requestor, |
| 455 | XFlush (reply->display); | 464 | False, 0, &reply_base); |
| 456 | x_uncatch_errors (); | 465 | x_stop_ignoring_errors (dpyinfo); |
| 466 | |||
| 467 | XFlush (dpyinfo->display); | ||
| 457 | unblock_input (); | 468 | unblock_input (); |
| 458 | } | 469 | } |
| 459 | 470 | ||
diff --git a/src/xterm.c b/src/xterm.c index ac4e210786e..39ce415472a 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -1121,8 +1121,6 @@ static void x_scroll_bar_end_update (struct x_display_info *, struct scroll_bar | |||
| 1121 | #ifdef HAVE_X_I18N | 1121 | #ifdef HAVE_X_I18N |
| 1122 | static int x_filter_event (struct x_display_info *, XEvent *); | 1122 | static int x_filter_event (struct x_display_info *, XEvent *); |
| 1123 | #endif | 1123 | #endif |
| 1124 | static void x_ignore_errors_for_next_request (struct x_display_info *); | ||
| 1125 | static void x_stop_ignoring_errors (struct x_display_info *); | ||
| 1126 | static void x_clean_failable_requests (struct x_display_info *); | 1124 | static void x_clean_failable_requests (struct x_display_info *); |
| 1127 | 1125 | ||
| 1128 | static struct frame *x_tooltip_window_to_frame (struct x_display_info *, | 1126 | static struct frame *x_tooltip_window_to_frame (struct x_display_info *, |
| @@ -23039,7 +23037,7 @@ x_clean_failable_requests (struct x_display_info *dpyinfo) | |||
| 23039 | + (last - first)); | 23037 | + (last - first)); |
| 23040 | } | 23038 | } |
| 23041 | 23039 | ||
| 23042 | static void | 23040 | void |
| 23043 | x_ignore_errors_for_next_request (struct x_display_info *dpyinfo) | 23041 | x_ignore_errors_for_next_request (struct x_display_info *dpyinfo) |
| 23044 | { | 23042 | { |
| 23045 | struct x_failable_request *request, *max; | 23043 | struct x_failable_request *request, *max; |
| @@ -23092,7 +23090,7 @@ x_ignore_errors_for_next_request (struct x_display_info *dpyinfo) | |||
| 23092 | dpyinfo->next_failable_request++; | 23090 | dpyinfo->next_failable_request++; |
| 23093 | } | 23091 | } |
| 23094 | 23092 | ||
| 23095 | static void | 23093 | void |
| 23096 | x_stop_ignoring_errors (struct x_display_info *dpyinfo) | 23094 | x_stop_ignoring_errors (struct x_display_info *dpyinfo) |
| 23097 | { | 23095 | { |
| 23098 | struct x_failable_request *range; | 23096 | struct x_failable_request *range; |
diff --git a/src/xterm.h b/src/xterm.h index 92e88bb50fa..a1ddf13463c 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -1463,6 +1463,8 @@ extern bool x_had_errors_p (Display *); | |||
| 1463 | extern void x_unwind_errors_to (int); | 1463 | extern void x_unwind_errors_to (int); |
| 1464 | extern void x_uncatch_errors (void); | 1464 | extern void x_uncatch_errors (void); |
| 1465 | extern void x_uncatch_errors_after_check (void); | 1465 | extern void x_uncatch_errors_after_check (void); |
| 1466 | extern void x_ignore_errors_for_next_request (struct x_display_info *); | ||
| 1467 | extern void x_stop_ignoring_errors (struct x_display_info *); | ||
| 1466 | extern void x_clear_errors (Display *); | 1468 | extern void x_clear_errors (Display *); |
| 1467 | extern void x_set_window_size (struct frame *, bool, int, int); | 1469 | extern void x_set_window_size (struct frame *, bool, int, int); |
| 1468 | extern void x_set_last_user_time_from_lisp (struct x_display_info *, Time); | 1470 | extern void x_set_last_user_time_from_lisp (struct x_display_info *, Time); |