summaryrefslogtreecommitdiff
path: root/src/xselect.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-07-11 10:07:21 +0800
committerPo Lu <luangruo@yahoo.com>2022-07-11 10:07:21 +0800
commitd9464d7fe5d21bd46254bbb691f5d3db34fe6324 (patch)
tree42323517c6211abf1022d0a94778429e0fac4142 /src/xselect.c
parentb283e36cf1902eeb6d532077e1f46270aa1224e1 (diff)
downloademacs-d9464d7fe5d21bd46254bbb691f5d3db34fe6324.tar.gz
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
x_decline_selection_request (struct selection_input_event *event)
{
XEvent reply_base;
- XSelectionEvent *reply = &(reply_base.xselection);
+ XSelectionEvent *reply;
+ Display *dpy;
+ struct x_display_info *dpyinfo;
+
+ reply = &(reply_base.xselection);
+ dpy = SELECTION_EVENT_DISPLAY (event);
+ dpyinfo = x_display_info_for_display (dpy);
+
+ if (!dpyinfo)
+ return;
reply->type = SelectionNotify;
- reply->display = SELECTION_EVENT_DISPLAY (event);
+ reply->display = dpy;
reply->requestor = SELECTION_EVENT_REQUESTOR (event);
reply->selection = SELECTION_EVENT_SELECTION (event);
reply->time = SELECTION_EVENT_TIME (event);
@@ -450,10 +459,12 @@ x_decline_selection_request (struct selection_input_event *event)
/* The reason for the error may be that the receiver has
died in the meantime. Handle that case. */
block_input ();
- x_catch_errors (reply->display);
- XSendEvent (reply->display, reply->requestor, False, 0, &reply_base);
- XFlush (reply->display);
- x_uncatch_errors ();
+ x_ignore_errors_for_next_request (dpyinfo);
+ XSendEvent (dpyinfo->display, reply->requestor,
+ False, 0, &reply_base);
+ x_stop_ignoring_errors (dpyinfo);
+
+ XFlush (dpyinfo->display);
unblock_input ();
}