From 46f8c9bacf93884dbb92c307ffd2fb3855f5ee8e Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 21 May 2019 09:02:07 -0400 Subject: [PATCH] fixed event loop to ensure a redraw on timeout --- inc/x11.h | 2 +- src/lib/x11.c | 3 +-- src/tide.c | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/inc/x11.h b/inc/x11.h index 3814460..dadf895 100644 --- a/inc/x11.h +++ b/inc/x11.h @@ -134,7 +134,7 @@ void x11_resize(XConf* x, XEvent* e); void x11_mkwin(XConf* x, int width, int height, int evmask); void x11_mkdialog(XConf* x, int width, int height, int evmask); -int x11_process_events(XConf* x, void (*redrawfn)(XConf*)); +void x11_process_events(XConf* x, void (*redrawfn)(XConf*)); void x11_event_loop(XConf* x, void (*redraw)(XConf* x)); int x11_getptr(XConf* x, int* ptrx, int* ptry); uint32_t x11_getkey(XConf* x, XEvent* e); diff --git a/src/lib/x11.c b/src/lib/x11.c index 56296cc..b36cb53 100644 --- a/src/lib/x11.c +++ b/src/lib/x11.c @@ -79,7 +79,7 @@ static void update_state(XConf* x, XEvent* e) { } } -int x11_process_events(XConf* x, void (*redrawfn)(XConf*)) { +void x11_process_events(XConf* x, void (*redrawfn)(XConf*)) { int nqueued, nevents; /* reap zombie background processes */ for (int status; waitpid(-1, &status, WNOHANG) > 0;); @@ -96,7 +96,6 @@ int x11_process_events(XConf* x, void (*redrawfn)(XConf*)) { if (nqueued) redrawfn(x); XFlush(x->display); } while ((nqueued = XEventsQueued(x->display, QueuedAfterFlush)) > 0); - return 0; } void x11_event_loop(XConf* x, void (*redraw)(XConf* x)) { diff --git a/src/tide.c b/src/tide.c index 10399b0..53f3e91 100644 --- a/src/tide.c +++ b/src/tide.c @@ -208,8 +208,8 @@ static void xredraw(XConf* x) { static void xupdate(Job* job) { /* redraw if we have changes or if we have input from a job */ - if (!x11_process_events(&X, xredraw) && !job) - xredraw(&X); + x11_process_events(&X, xredraw); + if (!job) xredraw(&X); } void win_init(void) { @@ -278,7 +278,7 @@ void win_loop(void) { job_spawn(ConnectionNumber(X.display), xupdate, 0, 0); XSync(X.display, False); while (X.running) { - if (job_poll(Timeout)) + if (!job_poll(Timeout)) xupdate(NULL); } } -- 2.51.0