Skip to content

Commit

Permalink
Little improvment for repainting
Browse files Browse the repository at this point in the history
  • Loading branch information
niclas committed Mar 20, 2019
1 parent dce795b commit 99a44dd
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions xwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <stdlib.h> /* for exit() */
#endif

#include <sys/time.h>

/*
* IMPORTS: routines that this module vectors out to
*/
Expand Down Expand Up @@ -67,6 +69,11 @@ extern void xdrawrect();
*/
static void help_popup();
static void help_popdown();
static struct timeval last_repaint;
static long int timediff(struct timeval* t1, struct timeval* t2)
{
return 1000000 * (t2->tv_sec - t1->tv_sec) + t2->tv_usec - t1->tv_usec;
}

static String fallback_resources[] = {
"*window.width: 600",
Expand Down Expand Up @@ -338,10 +345,20 @@ static void
c_resize(Widget w, XtPointer data, XEvent* event, Boolean* continue_to_dispatch)
{
UNUSED(w, data, event, continue_to_dispatch);
/*
* printf("Resize\n");
*/
/*
* printf("Resize\n");
*/
long int diff;
struct timeval t;

gettimeofday(&t, NULL);
diff = timediff(&last_repaint, &t);

if (diff < (long int)50000)
return;
xrepaint();

gettimeofday(&last_repaint, NULL);
}

static void
Expand All @@ -351,6 +368,14 @@ c_repaint(Widget w, XtPointer data, XEvent* event, Boolean* continue_to_dispatch
/*
* printf("Expose\n");
*/
long int diff;
struct timeval t;

gettimeofday(&t, NULL);
diff = timediff(&last_repaint, &t);

if (diff < (long int)50000)
return;
xrepaint_noclear();
}

Expand Down

0 comments on commit 99a44dd

Please sign in to comment.