diff options
author | Anselm R. Garbe <arg@10kloc.org> | 2006-08-25 14:45:17 +0200 |
---|---|---|
committer | Anselm R. Garbe <arg@10kloc.org> | 2006-08-25 14:45:17 +0200 |
commit | 13ef97e65ea5a713a3d5ab46916d1ac6d071b825 (patch) | |
tree | b8a9f831677cbd40cc27e1f0c8bf313b7e04addb /draw.c | |
parent | 65be999a3f76ad51fb97e12f2fb481f5038f6817 (diff) | |
download | dmenu-13ef97e65ea5a713a3d5ab46916d1ac6d071b825.tar.gz dmenu-13ef97e65ea5a713a3d5ab46916d1ac6d071b825.tar.bz2 dmenu-13ef97e65ea5a713a3d5ab46916d1ac6d071b825.zip |
updated dmenu to borderless drawing as well
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 33 |
1 files changed, 8 insertions, 25 deletions
@@ -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); } } |