aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Raeburn2015-10-07 06:04:01 -0400
committerKen Raeburn2015-10-11 01:15:08 -0400
commit5504ede9518053e619b2cc4bb01ce6eff254d3c8 (patch)
tree86e3fb272f4f27d8847291256c71bd5e30e06bfc
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.
-rw-r--r--src/xfns.c2
-rw-r--r--src/xmenu.c2
-rw-r--r--src/xselect.c6
-rw-r--r--src/xterm.c28
-rw-r--r--src/xterm.h1
5 files changed, 31 insertions, 8 deletions
diff --git a/src/xfns.c b/src/xfns.c
index f78e541f747..898359cb8f1 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -759,7 +759,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
759 759
760 /* Check and report errors with the above calls. */ 760 /* Check and report errors with the above calls. */
761 x_check_errors (dpy, "can't set cursor shape: %s"); 761 x_check_errors (dpy, "can't set cursor shape: %s");
762 x_uncatch_errors (); 762 x_uncatch_errors_after_check ();
763 763
764 { 764 {
765 XColor fore_color, back_color; 765 XColor fore_color, back_color;
diff --git a/src/xmenu.c b/src/xmenu.c
index f183c70b110..192ed89e2c6 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -325,7 +325,7 @@ If FRAME is nil or not given, use the selected frame. */)
325 /* Child of win. */ 325 /* Child of win. */
326 &child); 326 &child);
327 error_p = x_had_errors_p (FRAME_X_DISPLAY (f)); 327 error_p = x_had_errors_p (FRAME_X_DISPLAY (f));
328 x_uncatch_errors (); 328 x_uncatch_errors_after_check ();
329 329
330 if (! error_p) 330 if (! error_p)
331 { 331 {
diff --git a/src/xselect.c b/src/xselect.c
index 9aaa10c6efa..9a7e6974cd9 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -316,7 +316,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value,
316 x_catch_errors (display); 316 x_catch_errors (display);
317 XSetSelectionOwner (display, selection_atom, selecting_window, timestamp); 317 XSetSelectionOwner (display, selection_atom, selecting_window, timestamp);
318 x_check_errors (display, "Can't set selection: %s"); 318 x_check_errors (display, "Can't set selection: %s");
319 x_uncatch_errors (); 319 x_uncatch_errors_after_check ();
320 unblock_input (); 320 unblock_input ();
321 321
322 /* Now update the local cache */ 322 /* Now update the local cache */
@@ -1179,7 +1179,7 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
1179 XConvertSelection (display, selection_atom, type_atom, target_property, 1179 XConvertSelection (display, selection_atom, type_atom, target_property,
1180 requestor_window, requestor_time); 1180 requestor_window, requestor_time);
1181 x_check_errors (display, "Can't convert selection: %s"); 1181 x_check_errors (display, "Can't convert selection: %s");
1182 x_uncatch_errors (); 1182 x_uncatch_errors_after_check ();
1183 1183
1184 /* Prepare to block until the reply has been read. */ 1184 /* Prepare to block until the reply has been read. */
1185 reading_selection_window = requestor_window; 1185 reading_selection_window = requestor_window;
@@ -2364,7 +2364,7 @@ If the value is 0 or the atom is not known, return the empty string. */)
2364 x_catch_errors (dpy); 2364 x_catch_errors (dpy);
2365 name = atom ? XGetAtomName (dpy, atom) : empty; 2365 name = atom ? XGetAtomName (dpy, atom) : empty;
2366 had_errors_p = x_had_errors_p (dpy); 2366 had_errors_p = x_had_errors_p (dpy);
2367 x_uncatch_errors (); 2367 x_uncatch_errors_after_check ();
2368 2368
2369 if (!had_errors_p) 2369 if (!had_errors_p)
2370 ret = build_string (name); 2370 ret = build_string (name);
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 }
diff --git a/src/xterm.h b/src/xterm.h
index d8edbc208f4..fe3455ff7ce 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1030,6 +1030,7 @@ extern void x_check_errors (Display *, const char *)
1030 ATTRIBUTE_FORMAT_PRINTF (2, 0); 1030 ATTRIBUTE_FORMAT_PRINTF (2, 0);
1031extern bool x_had_errors_p (Display *); 1031extern bool x_had_errors_p (Display *);
1032extern void x_uncatch_errors (void); 1032extern void x_uncatch_errors (void);
1033extern void x_uncatch_errors_after_check (void);
1033extern void x_clear_errors (Display *); 1034extern void x_clear_errors (Display *);
1034extern void xembed_request_focus (struct frame *); 1035extern void xembed_request_focus (struct frame *);
1035extern void x_ewmh_activate_frame (struct frame *); 1036extern void x_ewmh_activate_frame (struct frame *);