The problem is the logic. The clock draw needs it's own 'true' loop for some reason.. but of course that never ends so the next part of the program can't take place. So, I added the XPending() (EDIT: as you did but I shifted the paint() call to before the XPending())call to the true loop, reduced the sleep a bit and it works, but it tends to flicker a bit more. It's taking too long to draw. The clock face is quite complex, figuring out 56 different angles to draw at, plus font characters then the actual hand drawing operation. This (I think) can be sped up if I put the actual face on another surface, however, once the hands are drawn that surface needs to be refreshed. I'll think about that, (as I have done).
Code: Select all
while (1) {
paint(cs, width, height, style);
while (XPending (dpy)) {
XNextEvent(dpy, &e);
if (e.type == KeyPress) {
char buf[128] = {0};
KeySym keysym;
XLookupString(&e.xkey, buf, sizeof(buf), &keysym, NULL);
if (keysym == XK_q) {
goto finish;
}
} else if (e.type == ButtonPress) {
XSetInputFocus (dpy, win, RevertToNone, CurrentTime);
}
}
usleep(200000); /*reduced as Xpending() takes time */
}
finish:
cairo_surface_destroy(cs);
XCloseDisplay(dpy);
I'll also look into XShapeCombineMask().