From 13ef97e65ea5a713a3d5ab46916d1ac6d071b825 Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Fri, 25 Aug 2006 14:45:17 +0200 Subject: updated dmenu to borderless drawing as well --- draw.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'draw.c') diff --git a/draw.c b/draw.c index 38ae8c3..d0f21cd 100644 --- a/draw.c +++ b/draw.c @@ -24,37 +24,21 @@ textnw(const char *text, unsigned int len) /* extern */ void -drawtext(const char *text, Bool invert, Bool border) +drawtext(const char *text, unsigned long col[ColLast]) { int x, y, w, h; static char buf[256]; unsigned int len, olen; XGCValues gcv; - XPoint points[5]; XRectangle r = { dc.x, dc.y, dc.w, dc.h }; - XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg); + XSetForeground(dpy, dc.gc, col[ColBG]); XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); - w = 0; - if(border) { - points[0].x = dc.x; - points[0].y = dc.y; - points[1].x = dc.w - 1; - points[1].y = 0; - points[2].x = 0; - points[2].y = dc.h - 1; - points[3].x = -(dc.w - 1); - points[3].y = 0; - points[4].x = 0; - points[4].y = -(dc.h - 1); - XSetForeground(dpy, dc.gc, dc.border); - XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); - } - if(!text) return; + w = 0; olen = len = strlen(text); if(len >= sizeof(buf)) len = sizeof(buf) - 1; @@ -80,17 +64,16 @@ drawtext(const char *text, Bool invert, Bool border) if(w > dc.w) return; /* too long */ - gcv.foreground = invert ? dc.bg : dc.fg; - gcv.background = invert ? dc.fg : dc.bg; + gcv.foreground = col[ColFG]; if(dc.font.set) { - XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv); - XmbDrawImageString(dpy, dc.drawable, dc.font.set, dc.gc, + XChangeGC(dpy, dc.gc, GCForeground, &gcv); + XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); } else { gcv.font = dc.font.xfont->fid; - XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv); - XDrawImageString(dpy, dc.drawable, dc.gc, x, y, buf, len); + XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv); + XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); } } -- cgit v1.2.3