]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed event loop to ensure a redraw on timeout
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 21 May 2019 13:02:07 +0000 (09:02 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 21 May 2019 13:02:07 +0000 (09:02 -0400)
inc/x11.h
src/lib/x11.c
src/tide.c

index 3814460f9c5a285a50adf3124128e0dd13061fac..dadf8958ea4484fd26426bdaaf9b708bb1307894 100644 (file)
--- 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);
index 56296ccf26652c50cef5536794b3e8bc408704cb..b36cb53bda2d5c575cf04a5e1e4739aa37a67120 100644 (file)
@@ -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)) {
index 10399b0bca4d696a5825815b1214423d4009c571..53f3e91ab4ec023811747c1c67536855240a853b 100644 (file)
@@ -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);
     }
 }