aboutsummaryrefslogtreecommitdiffstats
path: root/src/xselect.c
diff options
context:
space:
mode:
authorPo Lu2022-07-11 10:07:21 +0800
committerPo Lu2022-07-11 10:07:21 +0800
commitd9464d7fe5d21bd46254bbb691f5d3db34fe6324 (patch)
tree42323517c6211abf1022d0a94778429e0fac4142 /src/xselect.c
parentb283e36cf1902eeb6d532077e1f46270aa1224e1 (diff)
downloademacs-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/xselect.c')
-rw-r--r--src/xselect.c23
1 files changed, 17 insertions, 6 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
437x_decline_selection_request (struct selection_input_event *event) 437x_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