Patch by Paul Vojta to fix expose events in online mf
(closed bug report of texlive-bin in Debian)
(tex-k mailing list 20170526)
---
 texk/web2c/window/x11-Xt.c |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

--- texlive-bin.orig/texk/web2c/window/x11-Xt.c
+++ texlive-bin/texk/web2c/window/x11-Xt.c
@@ -42,7 +42,8 @@
 
 
 /* Don't paint anything until we're mapped.  */
-static Boolean mf_mapped;
+static Boolean mf_mapped = False;
+static Boolean mf_awaiting_expose = True;
 
 #ifdef MF_XT_DEBUG
 static int mf_max_x, mf_max_y;
@@ -150,10 +151,8 @@
      sits in XTMainLoop, if the server supports backing store
      and save unders this will help keep the output looking
      nice.  */
-  xwa.backing_store = Always;
-  xwa.save_under = True;
-  XChangeWindowAttributes (mf_display, mf_window,
-			   CWBackingStore | CWSaveUnder, &xwa);
+  xwa.backing_store = WhenMapped;
+  XChangeWindowAttributes (mf_display, mf_window, CWBackingStore, &xwa);
 
   gcv.background = mf_x11_resources.mf_bg;
   gcv.foreground = mf_x11_resources.mf_fg;
@@ -174,7 +173,14 @@
 void
 mf_x11_updatescreen (void)
 {
+  XEvent event;
+
   mf_events ();
+  while (mf_awaiting_expose)
+    {
+      XtAppNextEvent (mf_app, &event);
+      XtDispatchEvent (&event);
+    }
   mf_redraw ();
 
 #ifdef MF_XT_DEBUG
@@ -327,6 +333,7 @@
 	continue;
 
       mf_redraw ();
+      mf_awaiting_expose = False;
     }
 }
 
