From: Po Lu Date: Thu, 4 Aug 2022 01:13:53 +0000 (+0800) Subject: Avoid redundant calls to XFlush in x_make_frame_visible X-Git-Tag: emacs-29.0.90~1447^2~496 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cb8eb5e83050f0c58f06820d2f192e583018a66f;p=emacs.git 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. --- diff --git a/src/xterm.c b/src/xterm.c index f82340958e5..63e62f39bef 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -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); } }