X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu.c;h=d0c63db313a62716f0c4530ad28887e40a13e371;hb=c24f22a36bb986287f2b53116dff6479c434bc7d;hp=a799f14300e7ad479c682c5c710bccd21ed99a11;hpb=b95e61c9b7310deb452a5dfe404cc1a8f9930117;p=dmenu.git diff --git a/dmenu.c b/dmenu.c index a799f14..d0c63db 100644 --- a/dmenu.c +++ b/dmenu.c @@ -213,8 +213,8 @@ drawmenu(void) { void drawtext(const char *text, unsigned long col[ColLast]) { - int i, x, y, h, len, olen; char buf[256]; + int i, x, y, h, len, olen; XRectangle r = { dc.x, dc.y, dc.w, dc.h }; XSetForeground(dpy, dc.gc, col[ColBG]); @@ -226,7 +226,7 @@ drawtext(const char *text, unsigned long col[ColLast]) { y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; x = dc.x + (h / 2); /* shorten text if necessary */ - for(len = MIN(olen, sizeof buf); len && textnw(buf, len) > dc.w - h; len--); + for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--); if(!len) return; memcpy(buf, text, len); @@ -280,8 +280,6 @@ initfont(const char *fontstr) { if(!fontstr || fontstr[0] == '\0') eprint("error, cannot load font: '%s'\n", fontstr); missing = NULL; - if(dc.font.set) - XFreeFontSet(dpy, dc.font.set); dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); if(missing) XFreeStringList(missing);