]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid redundant calls to XFlush in x_make_frame_visible
authorPo Lu <luangruo@yahoo.com>
Thu, 4 Aug 2022 01:13:53 +0000 (09:13 +0800)
committerPo Lu <luangruo@yahoo.com>
Thu, 4 Aug 2022 01:13:53 +0000 (09:13 +0800)
* src/xterm.c (x_make_frame_visible): Keep track of whether or
not the output buffer was implictly flushed before issuing
XFlush.

src/xterm.c

index f82340958e5250c7eb68a39a22da3c9b57b023b0..63e62f39befaeb8f9bf1bf107bc6aa2a5053e578 100644 (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);
   }
 }