From 4bbae2a9a1266b890938b9b0a96611dace2fa885 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 31 Oct 2019 12:32:10 -0400 Subject: [PATCH] added more telemetry and fixed erroneous handling of MappingNotify events --- inc/x11.h | 2 +- src/lib/x11.c | 20 ++++++++++++++------ src/lib/x11_gc.c | 8 +++++++- src/tide.c | 5 +++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/inc/x11.h b/inc/x11.h index d32fb26..3527646 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); -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); diff --git a/src/lib/x11.c b/src/lib/x11.c index 74fe61d..13abb86 100644 --- a/src/lib/x11.c +++ b/src/lib/x11.c @@ -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)) diff --git a/src/lib/x11_gc.c b/src/lib/x11_gc.c index 8d81aca..4fdb37a 100644 --- a/src/lib/x11_gc.c +++ b/src/lib/x11_gc.c @@ -1,8 +1,10 @@ #include +#include #include 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); } diff --git a/src/tide.c b/src/tide.c index 96816d0..f8b4905 100644 --- a/src/tide.c +++ b/src/tide.c @@ -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); } -- 2.52.0