Avoid redundant calls to XFlush in x_make_frame_visible

* src/xterm.c (x_make_frame_visible): Keep track of whether or
not the output buffer was implictly flushed before issuing
XFlush.
This commit is contained in:
Po Lu 2022-08-04 09:13:53 +08:00
parent 9e9b0e13bc
commit cb8eb5e830

View file

@ -25750,6 +25750,7 @@ x_make_frame_visible (struct frame *f)
struct x_display_info *dpyinfo;
struct x_output *output;
#endif
bool output_flushed;
if (FRAME_PARENT_FRAME (f))
{
@ -25840,8 +25841,6 @@ x_make_frame_visible (struct frame *f)
}
}
XFlush (FRAME_X_DISPLAY (f));
/* Synchronize to ensure Emacs knows the frame is visible
before we do anything else. We do this loop with input not blocked
so that incoming events are handled. */
@ -25860,6 +25859,10 @@ x_make_frame_visible (struct frame *f)
/* This must come after we set COUNT. */
unblock_input ();
/* Keep track of whether or not the output buffer was flushed, to
avoid any extra flushes. */
output_flushed = false;
/* We unblock here so that arriving X events are processed. */
/* Now move the window back to where it was "supposed to be".
@ -25893,6 +25896,7 @@ x_make_frame_visible (struct frame *f)
there, and take the potential window manager hit. */
XGetGeometry (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
&rootw, &x, &y, &width, &height, &border, &depth);
output_flushed = true;
if (original_left != x || original_top != y)
XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
@ -25927,7 +25931,11 @@ x_make_frame_visible (struct frame *f)
(f, build_string ("x_make_frame_visible"));
x_wait_for_event (f, MapNotify);
output_flushed = true;
}
if (!output_flushed)
x_flush (f);
}
}