]> git.mdlowis.com Git - projs/tide.git/commitdiff
added more telemetry and fixed erroneous handling of MappingNotify events
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 31 Oct 2019 16:32:10 +0000 (12:32 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 31 Oct 2019 16:32:10 +0000 (12:32 -0400)
inc/x11.h
src/lib/x11.c
src/lib/x11_gc.c
src/tide.c

index d32fb268c820f6ecd0610f7bd621b580b0a9c22c..35276462d04278f228d2ad4d7ae79d02616402e3 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);
-bool x11_process_events(XConf* x);
+void x11_process_events(XConf* x);
 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 74fe61d5658485ccf496ac26d941f594e9d2d0ca..13abb86f6720d73b2f9112fb58c3fca88c0751b5 100644 (file)
@@ -94,23 +94,22 @@ static void update_state(XConf* x, XEvent* e)
     }
 }
 
-bool x11_process_events(XConf* x)
+void x11_process_events(XConf* x)
 {
-    bool has_event = false;
     int nevents;
     /* reap zombie background processes */
     for (int status; waitpid(-1, &status, WNOHANG) > 0;);
     /* process the entire event queue */
-    while (XEventsQueued(x->display, QueuedAfterFlush))
+    while (XEventsQueued(x->display, QueuedAfterReading))
     {
+        telem_send("EV_READ_QUEUE(pending: %d)\n", XPending(x->display));
         XGetMotionEvents(x->display, x->self, CurrentTime, CurrentTime, &nevents);
         for (XEvent e; XPending(x->display);)
         {
-            has_event = true;
             XNextEvent(x->display, &e);
             update_state(x, &e);
             if (!XFilterEvent(&e, None) && x->eventfns[e.type])
-            {
+            {;
                 telem_send("EV_HANDLE(type: %d)\n", e.type);
                 (x->eventfns[e.type])(x, &e);
             }
@@ -118,9 +117,18 @@ bool x11_process_events(XConf* x)
             {
                 telem_send("EV_IGNORE(type: %d)\n", e.type);
             }
+
+            /* log error here */
+            XErrorEvent* err = x11_error_get();
+            if (err)
+            {
+                char msg[8192];
+                XGetErrorText(x->display, err->error_code, msg, sizeof(msg));
+                telem_send("XERROR(%s)\n", msg);
+                x11_error_clear();
+            }
         }
     }
-    return has_event;
 }
 
 void x11_event_loop(XConf* x, void (*redraw)(XConf* x))
index 8d81acadc87258aaf1182588dcc38b19aa2ac8fb..4fdb37a3bc2925de69eb69a68f457e4adc1ada1b 100644 (file)
@@ -1,8 +1,10 @@
 #include <x11.h>
+#include <io.h>
 #include <X11/extensions/Xinerama.h>
 
 static void xfocus(XConf* x, XEvent* e)
 {
+    telem_send("XFOCUS(focus: %d)\n", (e->type == FocusIn));
     if (x->xic)
     {
         (e->type == FocusIn ? XSetICFocus : XUnsetICFocus)(x->xic);
@@ -11,6 +13,7 @@ static void xfocus(XConf* x, XEvent* e)
 
 void x11_resize(XConf* x, XEvent* e)
 {
+    telem_send("XRESIZE(w: %d, h: %d)\n", e->xconfigure.width, e->xconfigure.height);
     if (e->xconfigure.width != x->width || e->xconfigure.height != x->height)
     {
         x->width  = e->xconfigure.width;
@@ -23,7 +26,10 @@ void x11_resize(XConf* x, XEvent* e)
 
 void x11_mapnotify(XConf* x, XEvent* e)
 {
-    x11_resize(x, e);
+    telem_send("XMAPNOTIFY(0x%x)\n", e->xmap.window);
+    XFreePixmap(x->display, x->pixmap);
+    x->pixmap = XCreatePixmap(x->display, x->self, x->width, x->height, x->depth);
+    XftDrawChange(x->xft, x->pixmap);
     XWarpPointer(x->display, None, x->self, 0, 0, x->width, x->height, x->width/2, x->height/2);
 }
 
index 96816d0ab5a3f237b06a7ab2382a82c09cd5ce27..f8b49054eeacf9ec38ca1084379e801f189a27f0 100644 (file)
@@ -235,9 +235,10 @@ static void xclientmsg(XConf* x, XEvent* e)
 
 void xresize(XConf* x, XEvent* e)
 {
-    telem_send("RESIZE(w: %d, h: %d)\n", e->xconfigure.width, e->xconfigure.height);
     if (e->xconfigure.width != x->width || e->xconfigure.height != x->height)
+    {
         view_sync(win_view(EDIT));
+    }
     x11_resize(x, e);
 }
 
@@ -281,7 +282,7 @@ static void xupdate(Job* job)
 {
     /* redraw if we have changes or if we have input from a job */
     x11_process_events(&X);
-    if (x11_process_events(&X) || !job)
+    if (!job)
     {
         xredraw(&X);
     }