Skip to content

Commit

Permalink
Add setRepaintWhenIdle()
Browse files Browse the repository at this point in the history
Add a function which will register a (Idle-) work procedure to do the
redraw when there are no more other events pending.

If the window size has changed after the last redraw, clear the
window to clean up wrongly scaled relicts.
  • Loading branch information
donald committed Mar 22, 2019
1 parent d3dc43d commit 4f22d4d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions xwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,31 @@ static Visual* vis;
static Window win;
static GC gc;
static XtAppContext app_con;
static int workerRegistered=0;
static int last_repaint_width=-1;
static int last_repaint_height=-1;

Boolean doIdleRepaint(XtPointer data) {
(void)data;
XWindowAttributes xwa;

XGetWindowAttributes(dpy, win, &xwa);
if (xwa.width != last_repaint_width || xwa.height != last_repaint_height) {
XClearWindow(dpy, win);
}
repaint(xwa.width, xwa.height);
last_repaint_width=xwa.width;
last_repaint_height=xwa.height;
workerRegistered=0;
return True;
}

static void setRepaintWhenIdle() {
if (!workerRegistered) {
(void)XtAppAddWorkProc(app_con,doIdleRepaint,NULL);
workerRegistered=1;
}
}

static void
a_savesvg(Widget w, XEvent* e, String* params, Cardinal* num_params)
Expand Down

0 comments on commit 4f22d4d

Please sign in to comment.