From 61a1f997427306dc15055499283eb3966ec4906b Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 26 Nov 2018 23:35:50 -0500 Subject: [PATCH] tried adding background color --- src/pick.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/pick.c b/src/pick.c index d4befea..44445cd 100644 --- a/src/pick.c +++ b/src/pick.c @@ -122,7 +122,24 @@ static void xresize(XConf* x, XEvent* e) { } } +static void xftcolor(XConf* x, XftColor* xc, unsigned int c) { + #define COLOR(c) ((c) | ((c) >> 8)) + xc->color.alpha = 0xFFFF; + xc->color.red = COLOR((c & 0x00FF0000) >> 8); + xc->color.green = COLOR((c & 0x0000FF00)); + xc->color.blue = COLOR((c & 0x000000FF) << 8); + XftColorAllocValue(x->display, x->visual, x->colormap, &(xc->color), xc); +} + +static void draw_rect(XConf* x, int color, int px, int py, int width, int height) { + XftColor clr; + xftcolor(x, &clr, color); + XftDrawRect(x->xft, &clr, px, py, width, height); + XftColorFree(x->display, x->visual, x->colormap, &clr); +} + static void redraw(XConf* x) { + draw_rect(x, 0x0, 0, 0, x->width, x->height); } void filter(void) { @@ -134,6 +151,7 @@ void filter(void) { x.eventfns[KeyPress] = xkeypress; x.eventfns[ButtonPress] = xbtnpress; x.eventfns[ConfigureNotify] = xresize; + redraw(&x); while (true) { x11_event_loop(&x); redraw(&x); -- 2.54.0