aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Raeburn2015-10-02 05:00:23 -0400
committerKen Raeburn2015-10-11 01:15:12 -0400
commitfcb5d3e8b158f7ea8492aa14f79804fae18e76f9 (patch)
tree0e0429c3a6242ca93628c5b7490ef28a94db99f1
parent5504ede9518053e619b2cc4bb01ce6eff254d3c8 (diff)
downloademacs-fcb5d3e8b158f7ea8492aa14f79804fae18e76f9.tar.gz
emacs-fcb5d3e8b158f7ea8492aa14f79804fae18e76f9.zip
Add x_catch_errors_with_handler.
* src/xterm.c (struct x_error_message_stack): Add new fields for a callback function and associated data pointer. (x_error_catcher): If the callback function is set, call it after saving the error message string. (x_catch_errors_with_handler): Renamed from x_catch_errors but now accepts a callback function and data pointer. (x_catch_errors): Now a wrapper function. * src/xterm.h (x_special_error_handler): New typedef. (x_catch_errors_with_handler): Declare.
-rw-r--r--src/xterm.c16
-rw-r--r--src/xterm.h5
2 files changed, 20 insertions, 1 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 6e870c5ebb9..7ff6b17c30a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9190,6 +9190,8 @@ x_text_icon (struct frame *f, const char *icon_name)
9190struct x_error_message_stack { 9190struct x_error_message_stack {
9191 char string[X_ERROR_MESSAGE_SIZE]; 9191 char string[X_ERROR_MESSAGE_SIZE];
9192 Display *dpy; 9192 Display *dpy;
9193 x_special_error_handler handler;
9194 void *handler_data;
9193 struct x_error_message_stack *prev; 9195 struct x_error_message_stack *prev;
9194}; 9196};
9195static struct x_error_message_stack *x_error_message; 9197static struct x_error_message_stack *x_error_message;
@@ -9204,6 +9206,9 @@ x_error_catcher (Display *display, XErrorEvent *event)
9204 XGetErrorText (display, event->error_code, 9206 XGetErrorText (display, event->error_code,
9205 x_error_message->string, 9207 x_error_message->string,
9206 X_ERROR_MESSAGE_SIZE); 9208 X_ERROR_MESSAGE_SIZE);
9209 if (x_error_message->handler)
9210 x_error_message->handler (display, event, x_error_message->string,
9211 x_error_message->handler_data);
9207} 9212}
9208 9213
9209/* Begin trapping X errors for display DPY. Actually we trap X errors 9214/* Begin trapping X errors for display DPY. Actually we trap X errors
@@ -9223,7 +9228,8 @@ x_error_catcher (Display *display, XErrorEvent *event)
9223 x_had_errors_p or x_check_errors. */ 9228 x_had_errors_p or x_check_errors. */
9224 9229
9225void 9230void
9226x_catch_errors (Display *dpy) 9231x_catch_errors_with_handler (Display *dpy, x_special_error_handler handler,
9232 void *handler_data)
9227{ 9233{
9228 struct x_error_message_stack *data = xmalloc (sizeof *data); 9234 struct x_error_message_stack *data = xmalloc (sizeof *data);
9229 9235
@@ -9232,10 +9238,18 @@ x_catch_errors (Display *dpy)
9232 9238
9233 data->dpy = dpy; 9239 data->dpy = dpy;
9234 data->string[0] = 0; 9240 data->string[0] = 0;
9241 data->handler = handler;
9242 data->handler_data = handler_data;
9235 data->prev = x_error_message; 9243 data->prev = x_error_message;
9236 x_error_message = data; 9244 x_error_message = data;
9237} 9245}
9238 9246
9247void
9248x_catch_errors (Display *dpy)
9249{
9250 x_catch_errors_with_handler (dpy, NULL, NULL);
9251}
9252
9239/* Undo the last x_catch_errors call. 9253/* Undo the last x_catch_errors call.
9240 DPY should be the display that was passed to x_catch_errors. 9254 DPY should be the display that was passed to x_catch_errors.
9241 9255
diff --git a/src/xterm.h b/src/xterm.h
index fe3455ff7ce..f7d2803ff29 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1024,8 +1024,13 @@ XrmDatabase x_load_resources (Display *, const char *, const char *,
1024 1024
1025/* Defined in xterm.c */ 1025/* Defined in xterm.c */
1026 1026
1027typedef void (*x_special_error_handler)(Display *, XErrorEvent *, char *,
1028 void *);
1029
1027extern bool x_text_icon (struct frame *, const char *); 1030extern bool x_text_icon (struct frame *, const char *);
1028extern void x_catch_errors (Display *); 1031extern void x_catch_errors (Display *);
1032extern void x_catch_errors_with_handler (Display *, x_special_error_handler,
1033 void *);
1029extern void x_check_errors (Display *, const char *) 1034extern void x_check_errors (Display *, const char *)
1030 ATTRIBUTE_FORMAT_PRINTF (2, 0); 1035 ATTRIBUTE_FORMAT_PRINTF (2, 0);
1031extern bool x_had_errors_p (Display *); 1036extern bool x_had_errors_p (Display *);