aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
authorKen Raeburn2015-10-07 06:04:01 -0400
committerKen Raeburn2015-10-11 01:15:08 -0400
commit5504ede9518053e619b2cc4bb01ce6eff254d3c8 (patch)
tree86e3fb272f4f27d8847291256c71bd5e30e06bfc /src/xterm.c
parent54e3734a322aca9d396e4c7b0e73f08ac6c12501 (diff)
downloademacs-5504ede9518053e619b2cc4bb01ce6eff254d3c8.tar.gz
emacs-5504ede9518053e619b2cc4bb01ce6eff254d3c8.zip
Introduce x_uncatch_errors_after_check to reduce XSync calls.
Both x_had_errors_p and x_check_errors call XSync, so if they're immediately followed by x_uncatch_errors, its XSync call will be redundant, resulting in a wasted round trip to the X server. * src/xterm.c (x_uncatch_errors_after_check): New routine; a copy of x_uncatch_errors without the XSync call. (XTmouse_position, x_wm_supports): * src/xfns.c (x_set_mouse_color): * src/xmenu.c (Fx_menu_bar_open_internal): * src/xselect.c (x_own_selection, x_get_foreign_selection): (Fx_get_atom_name): Call it instead of x_uncatch_errors. * src/xterm.h (x_uncatch_errors_after_check): Declare.
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/xterm.c b/src/xterm.c
index cd6cdb044c9..6e870c5ebb9 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -4992,7 +4992,7 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
4992 if (x_had_errors_p (FRAME_X_DISPLAY (*fp))) 4992 if (x_had_errors_p (FRAME_X_DISPLAY (*fp)))
4993 f1 = 0; 4993 f1 = 0;
4994 4994
4995 x_uncatch_errors (); 4995 x_uncatch_errors_after_check ();
4996 4996
4997 /* If not, is it one of our scroll bars? */ 4997 /* If not, is it one of our scroll bars? */
4998 if (! f1) 4998 if (! f1)
@@ -9217,7 +9217,10 @@ x_error_catcher (Display *display, XErrorEvent *event)
9217 Calling x_check_errors signals an Emacs error if an X error has 9217 Calling x_check_errors signals an Emacs error if an X error has
9218 occurred since the last call to x_catch_errors or x_check_errors. 9218 occurred since the last call to x_catch_errors or x_check_errors.
9219 9219
9220 Calling x_uncatch_errors resumes the normal error handling. */ 9220 Calling x_uncatch_errors resumes the normal error handling.
9221 Calling x_uncatch_errors_after_check is similar, but skips an XSync
9222 to the server, and should be used only immediately after
9223 x_had_errors_p or x_check_errors. */
9221 9224
9222void 9225void
9223x_catch_errors (Display *dpy) 9226x_catch_errors (Display *dpy)
@@ -9234,6 +9237,25 @@ x_catch_errors (Display *dpy)
9234} 9237}
9235 9238
9236/* Undo the last x_catch_errors call. 9239/* Undo the last x_catch_errors call.
9240 DPY should be the display that was passed to x_catch_errors.
9241
9242 This version should be used only if the immediately preceding
9243 X-protocol-related thing was x_check_errors or x_had_error_p, both
9244 of which issue XSync calls, so we don't need to re-sync here. */
9245
9246void
9247x_uncatch_errors_after_check (void)
9248{
9249 struct x_error_message_stack *tmp;
9250
9251 block_input ();
9252 tmp = x_error_message;
9253 x_error_message = x_error_message->prev;
9254 xfree (tmp);
9255 unblock_input ();
9256}
9257
9258/* Undo the last x_catch_errors call.
9237 DPY should be the display that was passed to x_catch_errors. */ 9259 DPY should be the display that was passed to x_catch_errors. */
9238 9260
9239void 9261void
@@ -9928,7 +9950,7 @@ x_wm_supports (struct frame *f, Atom want_atom)
9928 XSelectInput (dpy, wmcheck_window, StructureNotifyMask); 9950 XSelectInput (dpy, wmcheck_window, StructureNotifyMask);
9929 if (x_had_errors_p (dpy)) 9951 if (x_had_errors_p (dpy))
9930 { 9952 {
9931 x_uncatch_errors (); 9953 x_uncatch_errors_after_check ();
9932 unblock_input (); 9954 unblock_input ();
9933 return false; 9955 return false;
9934 } 9956 }