# include "Ximage.h"

static struct timeval reftime; 
static char reftimeset = FALSE;
# define DTIME(A,B) ((A.tv_sec - B.tv_sec) + 1e-6*(A.tv_usec - B.tv_usec))

void FlushDisplay (Display *display) {

  struct timeval now;
  int flush;
  double dtime;

  flush = FALSE;
  if (!reftimeset) {
    flush = TRUE;
    gettimeofday (&reftime, NULL);
  } 

  gettimeofday (&now, NULL);
  dtime = DTIME (now, reftime);

  if (dtime > 0.1) {
    flush = TRUE;
  }

  if (flush) {
    XFlush (display);
    reftime = now;
  }

}

