Index: trunk/Ohana/src/kapa2/src/CheckPipe.c
===================================================================
--- trunk/Ohana/src/kapa2/src/CheckPipe.c	(revision 36487)
+++ trunk/Ohana/src/kapa2/src/CheckPipe.c	(revision 36833)
@@ -1,3 +1,4 @@
 # include "Ximage.h"
+# include <errno.h>
 # define STRCONST(A) ((int)(0x1000000*A[0] + 0x10000*A[1] + 0x100*A[2] + 0x1*A[3]))
 
@@ -41,6 +42,11 @@
   word[4] = 0;
   switch (status) {
-  case -1:                          /* no input from pipe: continue */
-    return (TRUE);
+  case -1:
+    if (errno == EAGAIN) {
+      /* no input from pipe: continue */
+      return (TRUE);
+    } 
+    perror ("exiting due to problem with socket connection in CheckPipe");
+    return (FALSE);
     break;
 
Index: trunk/Ohana/src/kapa2/src/EventLoop.c
===================================================================
--- trunk/Ohana/src/kapa2/src/EventLoop.c	(revision 36487)
+++ trunk/Ohana/src/kapa2/src/EventLoop.c	(revision 36833)
@@ -1,3 +1,4 @@
 # include "Ximage.h"
+# define DEBUG 0
 
 /* list events being selected below, all other masks are ignored */ 
@@ -6,9 +7,27 @@
 int LastEvent (Display *display, int type, XEvent *event) {
 
-  int found;
+  int found, Nfound;
 
   found = FALSE;
+  Nfound = 0;
   while (XCheckTypedEvent (display, type, event)) {
+    // If the link is slow, then I should wait a little while for some config events to
+    // build up (typically, the window is being dragged around, so we get a whole series of 
+    // config events.  the flush / sync time is slow on a slow link, so we should try to wait
+    // for the config events to stop, but on a timescale deteremined by the flush/sync time
+    // if (type == ConfigureNotify) fprintf (stderr, "config (%d)\n", Nfound);
+    Nfound ++;
     found = TRUE;
+  }
+  if (DEBUG && found) {
+    if (type == ConfigureNotify) fprintf (stderr, "config (%d)\n", Nfound);
+    if (type == CirculateNotify) fprintf (stderr, "circul (%d)\n", Nfound);
+    if (type == Expose) fprintf (stderr, "expose (%d)\n", Nfound);
+  }
+
+  // if I have a ConfigureNotify event, I should purge all Expose events as well:
+  if (found && (type == ConfigureNotify)) {
+    XEvent discard;
+    while (XCheckTypedEvent (display, Expose, &discard));
   }
   return (found);
@@ -38,13 +57,14 @@
 
     if (XEventsQueued (display, QueuedAfterFlush) < 1) {
-      /* fprintf (stderr, "."); */
       usleep (50000);
       continue;
     }
 
+    // If I have a config event, I want to also purge all expose events
+
     /* grab the last entry for these events */
-    if (LastEvent (display, ConfigureNotify, &event)) Reconfig (&event);
-    if (LastEvent (display, CirculateNotify, &event)) Reconfig (&event);
-    if (LastEvent (display, Expose,          &event)) Refresh ();
+    if (LastEvent (display, ConfigureNotify, &event)) { Reconfig (&event); continue; }
+    if (LastEvent (display, CirculateNotify, &event)) { Reconfig (&event); continue; }
+    if (LastEvent (display, Expose,          &event)) { Refresh (); continue; }
     if (LastEvent (display, MappingNotify,   &event)) XRefreshKeyboardMapping ((XMappingEvent *) &event);
     if (LastEvent (display, MotionNotify,    &event)) UpdatePointer (graphic, (XMotionEvent *) &event);
Index: trunk/Ohana/src/kapa2/src/FlushDisplay.c
===================================================================
--- trunk/Ohana/src/kapa2/src/FlushDisplay.c	(revision 36487)
+++ trunk/Ohana/src/kapa2/src/FlushDisplay.c	(revision 36833)
@@ -30,5 +30,7 @@
 
   if (flush) {
-    XFlush (graphic->display);
+    // I changed XFlush to XSync to avoid lag
+    // of the display (build up of config events)
+    XSync (graphic->display, FALSE);
     reftime = now;
   }
Index: trunk/Ohana/src/kapa2/src/Refresh.c
===================================================================
--- trunk/Ohana/src/kapa2/src/Refresh.c	(revision 36487)
+++ trunk/Ohana/src/kapa2/src/Refresh.c	(revision 36833)
@@ -47,5 +47,4 @@
   Y0 = graphic[0].dy - graphic[0].dy * section[0].y - dY;
   X0 = graphic[0].dx * section[0].x;
-  // fprintf (stderr, "section: (%s) %d %d - %d %d\n", section[0].name, X0, Y0, dX, dY);
 
   XFillRectangle (graphic[0].display,  graphic[0].window, graphic[0].gc, X0, Y0, dX, dY);
