]> git.mdlowis.com Git - projs/tide.git/commitdiff
reworked event loop for x11 to have a 100ms timeout. This allows us to refresh period...
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 27 Apr 2017 16:10:13 +0000 (12:10 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 27 Apr 2017 16:10:13 +0000 (12:10 -0400)
lib/x11.c

index 27104fc8d2b459f19ec2f9a74808e9f5c46a340e..cdf49e2801643df46d1291d9585da71d2af6e6f6 100644 (file)
--- a/lib/x11.c
+++ b/lib/x11.c
@@ -6,6 +6,8 @@
 #include <utf.h>
 #include <edit.h>
 #include <locale.h>
+#include <sys/time.h>
+#include <sys/types.h>
 
 static struct XSel* selfetch(Atom atom); 
 static void selclear(XEvent* evnt);
@@ -324,9 +326,19 @@ void x11_handle_events(void) {
 }
 
 void x11_loop(void) {
+    fd_set fds;
+    int xfd = ConnectionNumber(X.display);
     for (XEvent e; Running;) {
-        XPeekEvent(X.display,&e);
-        x11_handle_events();
+        struct timeval tv = { .tv_usec = 100000 };
+        FD_ZERO(&fds);
+        FD_SET(xfd, &fds);
+    
+        int ready = select(xfd+1, &fds, NULL, NULL, &tv);
+        if (ready > 0)
+            x11_handle_events();
+        //else
+        //    timer expired
+        
         if (Running) {
             /* redraw the window */
             Config->redraw(X.width, X.height);