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);
}
}
-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);
}
{
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))
#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);
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;
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);
}
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);
}
{
/* 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);
}