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.
This commit is contained in:
parent
54e3734a32
commit
5504ede951
5 changed files with 31 additions and 8 deletions
|
@ -759,7 +759,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
|
|||
|
||||
/* Check and report errors with the above calls. */
|
||||
x_check_errors (dpy, "can't set cursor shape: %s");
|
||||
x_uncatch_errors ();
|
||||
x_uncatch_errors_after_check ();
|
||||
|
||||
{
|
||||
XColor fore_color, back_color;
|
||||
|
|
|
@ -325,7 +325,7 @@ If FRAME is nil or not given, use the selected frame. */)
|
|||
/* Child of win. */
|
||||
&child);
|
||||
error_p = x_had_errors_p (FRAME_X_DISPLAY (f));
|
||||
x_uncatch_errors ();
|
||||
x_uncatch_errors_after_check ();
|
||||
|
||||
if (! error_p)
|
||||
{
|
||||
|
|
|
@ -316,7 +316,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value,
|
|||
x_catch_errors (display);
|
||||
XSetSelectionOwner (display, selection_atom, selecting_window, timestamp);
|
||||
x_check_errors (display, "Can't set selection: %s");
|
||||
x_uncatch_errors ();
|
||||
x_uncatch_errors_after_check ();
|
||||
unblock_input ();
|
||||
|
||||
/* Now update the local cache */
|
||||
|
@ -1179,7 +1179,7 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
|
|||
XConvertSelection (display, selection_atom, type_atom, target_property,
|
||||
requestor_window, requestor_time);
|
||||
x_check_errors (display, "Can't convert selection: %s");
|
||||
x_uncatch_errors ();
|
||||
x_uncatch_errors_after_check ();
|
||||
|
||||
/* Prepare to block until the reply has been read. */
|
||||
reading_selection_window = requestor_window;
|
||||
|
@ -2364,7 +2364,7 @@ If the value is 0 or the atom is not known, return the empty string. */)
|
|||
x_catch_errors (dpy);
|
||||
name = atom ? XGetAtomName (dpy, atom) : empty;
|
||||
had_errors_p = x_had_errors_p (dpy);
|
||||
x_uncatch_errors ();
|
||||
x_uncatch_errors_after_check ();
|
||||
|
||||
if (!had_errors_p)
|
||||
ret = build_string (name);
|
||||
|
|
28
src/xterm.c
28
src/xterm.c
|
@ -4992,7 +4992,7 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
|
|||
if (x_had_errors_p (FRAME_X_DISPLAY (*fp)))
|
||||
f1 = 0;
|
||||
|
||||
x_uncatch_errors ();
|
||||
x_uncatch_errors_after_check ();
|
||||
|
||||
/* If not, is it one of our scroll bars? */
|
||||
if (! f1)
|
||||
|
@ -9217,7 +9217,10 @@ x_error_catcher (Display *display, XErrorEvent *event)
|
|||
Calling x_check_errors signals an Emacs error if an X error has
|
||||
occurred since the last call to x_catch_errors or x_check_errors.
|
||||
|
||||
Calling x_uncatch_errors resumes the normal error handling. */
|
||||
Calling x_uncatch_errors resumes the normal error handling.
|
||||
Calling x_uncatch_errors_after_check is similar, but skips an XSync
|
||||
to the server, and should be used only immediately after
|
||||
x_had_errors_p or x_check_errors. */
|
||||
|
||||
void
|
||||
x_catch_errors (Display *dpy)
|
||||
|
@ -9233,6 +9236,25 @@ x_catch_errors (Display *dpy)
|
|||
x_error_message = data;
|
||||
}
|
||||
|
||||
/* Undo the last x_catch_errors call.
|
||||
DPY should be the display that was passed to x_catch_errors.
|
||||
|
||||
This version should be used only if the immediately preceding
|
||||
X-protocol-related thing was x_check_errors or x_had_error_p, both
|
||||
of which issue XSync calls, so we don't need to re-sync here. */
|
||||
|
||||
void
|
||||
x_uncatch_errors_after_check (void)
|
||||
{
|
||||
struct x_error_message_stack *tmp;
|
||||
|
||||
block_input ();
|
||||
tmp = x_error_message;
|
||||
x_error_message = x_error_message->prev;
|
||||
xfree (tmp);
|
||||
unblock_input ();
|
||||
}
|
||||
|
||||
/* Undo the last x_catch_errors call.
|
||||
DPY should be the display that was passed to x_catch_errors. */
|
||||
|
||||
|
@ -9928,7 +9950,7 @@ x_wm_supports (struct frame *f, Atom want_atom)
|
|||
XSelectInput (dpy, wmcheck_window, StructureNotifyMask);
|
||||
if (x_had_errors_p (dpy))
|
||||
{
|
||||
x_uncatch_errors ();
|
||||
x_uncatch_errors_after_check ();
|
||||
unblock_input ();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1030,6 +1030,7 @@ extern void x_check_errors (Display *, const char *)
|
|||
ATTRIBUTE_FORMAT_PRINTF (2, 0);
|
||||
extern bool x_had_errors_p (Display *);
|
||||
extern void x_uncatch_errors (void);
|
||||
extern void x_uncatch_errors_after_check (void);
|
||||
extern void x_clear_errors (Display *);
|
||||
extern void xembed_request_focus (struct frame *);
|
||||
extern void x_ewmh_activate_frame (struct frame *);
|
||||
|
|
Loading…
Add table
Reference in a new issue