summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Roovers <jer@gentoo.org>2014-01-22 14:46:24 +0000
committerJeroen Roovers <jer@gentoo.org>2014-01-22 14:46:24 +0000
commitc5e92df6118e69b54d20077507355a5d7a48c96f (patch)
treea6683a024547ec218b3fcfb6794b312905405dd5 /x11-misc/dmenu
parentUpdate new build options for latest git head. (diff)
downloadhistorical-c5e92df6118e69b54d20077507355a5d7a48c96f.tar.gz
historical-c5e92df6118e69b54d20077507355a5d7a48c96f.tar.bz2
historical-c5e92df6118e69b54d20077507355a5d7a48c96f.zip
Clean up patch. Revision bump for a slightly different patch by Hans-Peter Deifel (bug #498924).
Package-Manager: portage-2.2.8-r1/cvs/Linux x86_64 Manifest-Sign-Key: 0xA792A613
Diffstat (limited to 'x11-misc/dmenu')
-rw-r--r--x11-misc/dmenu/ChangeLog11
-rw-r--r--x11-misc/dmenu/Manifest12
-rw-r--r--x11-misc/dmenu/dmenu-4.5-r4.ebuild59
-rw-r--r--x11-misc/dmenu/files/dmenu-4.5-xft-2.patch66
-rw-r--r--x11-misc/dmenu/files/dmenu-4.5-xft-3.patch412
5 files changed, 520 insertions, 40 deletions
diff --git a/x11-misc/dmenu/ChangeLog b/x11-misc/dmenu/ChangeLog
index b3e4b750e732..47c8a05ec3ff 100644
--- a/x11-misc/dmenu/ChangeLog
+++ b/x11-misc/dmenu/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for x11-misc/dmenu
-# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/x11-misc/dmenu/ChangeLog,v 1.110 2013/12/23 22:51:23 jer Exp $
+# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/x11-misc/dmenu/ChangeLog,v 1.111 2014/01/22 14:46:23 jer Exp $
+
+*dmenu-4.5-r4 (22 Jan 2014)
+
+ 22 Jan 2014; Jeroen Roovers <jer@gentoo.org> +dmenu-4.5-r4.ebuild,
+ files/dmenu-4.5-xft-2.patch, +files/dmenu-4.5-xft-3.patch:
+ Clean up patch. Revision bump for a slightly different patch by Hans-Peter
+ Deifel (bug #498924).
23 Dec 2013; Jeroen Roovers <jer@gentoo.org> dmenu-4.5-r3.ebuild:
Quote make command line variables (bug #495128).
diff --git a/x11-misc/dmenu/Manifest b/x11-misc/dmenu/Manifest
index 7cb27dde937a..8da5a70ab22f 100644
--- a/x11-misc/dmenu/Manifest
+++ b/x11-misc/dmenu/Manifest
@@ -1,15 +1,17 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
-AUX dmenu-4.5-xft-2.patch 12640 SHA256 a4bad8b00d9aad39b8b0268ab9afc468b9fbf0e15647d27fd2c97b86faeefaa4 SHA512 a6e6712e49ebd5b883a78f0968074fc89d46acdf3285e464bba62b2c06026958aa3008369a0274fe68332f93fc2259d30c7ae6d96c9597d54cf205161b9d4e81 WHIRLPOOL 9713e6e313c03b90fc112d1d4ebb711253d1632d766966363849b396ce0001cb0244a8c5121ee2da44c0b68fd081c65a4e4469c5fc4f4435f13ba4fee8924c90
+AUX dmenu-4.5-xft-2.patch 11556 SHA256 339cc52981c46fcbd7e4bc5b3b33cfec2ca3a9d48f16ff994327371a79c99386 SHA512 8fd0c59b5faa0e30a7fed40736680f1328087595d26b593b7e0a9250f8c43793456638fcfb3794f2dc057853a38d2ccce4690cb62ac4a00c074d3f07404a3168 WHIRLPOOL 3c0cd74e5b8f94eb720a5ef8acb6334308fef871c0f2e7df7daada0f9ddfd5c439e065deffa027b4d04949d9099283cec3797f5690d61319debce26ba9006d47
+AUX dmenu-4.5-xft-3.patch 11564 SHA256 8a32e9a433dcd71480df349e33f7f4935d80f080931832133a75cb15903626c3 SHA512 19457aa5727bb5a694ef8f6de3ccacb7edb7efff5cd93503cf97b2b6f18b4a3b230155b9e58bf4d0afb22f50fbc425b9257abea350f023d3f0bd15f1259b20f9 WHIRLPOOL 2caa27f4c81a16ad095733dafdff588e48b7109ef03445b0415c8ef042e8a8e88f680d148065810a282d63dab921b4e6faff5f29ec5455a38ae8ed3f1a8f7c73
DIST dmenu-4.5.tar.gz 11543 SHA256 082cd698d82125ca0b3989006fb84ac4675c2a5585bf5bb8af0ea09cfb95a850 SHA512 872dee68c35a93c663eb0a941653eaaa4aa83d8379e05b4dbca089a2c9335036b496de85d8ddf7af1228a5625490a06a89031fb1aac726236b608b952962c248 WHIRLPOOL b91660f3028d314f1a10b994af73e6239c4aaabda6c9ab269bda7e37e0cd22c0eaf3b93998c4cb0fe1f9d8f2fd198afc2e70c237a46921ece9fd9a697f58c869
EBUILD dmenu-4.5-r3.ebuild 1479 SHA256 f4cac368326c302772179a9d636c06e966005243d8aad596eeb07a1cdf8c2dfa SHA512 fe4d804236dfdf976ff349d90a884f355ea99c133cc4907cf5db7fa07f9a51fa6a99f4c63b8ba65380c96b318547fa4b423dd90e4b8593dddfba5500002a1526 WHIRLPOOL 8fe35131619b1f823cc2a0beb1b03a8a1c6f246d62de4c9d0ab6bc9c4ed60f1e2bebf2e90691622765c1b2b9c1a0ea520f25c0548733213fe79734f9d3e1c2d0
-MISC ChangeLog 12357 SHA256 fd9ffd06d0b132285942a35cb65b19894a5e64f588522763c369d17664a7405a SHA512 2764fd42af26a80e3033e6d1876de1e7366b3bc7a4f17871281fa8d7377ff4644c778f38b669e1a5fd0d00fd37fad49fdcd4644a4235ebf5a7a86f0568809010 WHIRLPOOL 0e3270740ed5ab159955e2a1a055ed8ff9582e0338af1f28dcbff0b895cc7ea84fba9160e00024b52e9bc3b272ed9aeb3e9e88715456bce8995ce26d8a7a61d9
+EBUILD dmenu-4.5-r4.ebuild 1484 SHA256 50406d18a4d7997607c4149af3756df4155c5ba676196f558168840b70f31fb6 SHA512 d164e3b5739809dbde17cda5a9a558c81e95caf23be6c51013936f98ca66b193d85dbffc8d396d6970e4604cf100ceb0663131468b650a25fe78a5d2e8037593 WHIRLPOOL 9ea33bac4397bbbbe2766d970b0968286263affb95c454997dca5a3f9a3a710c0674b5a511a1edd6d6a9d76d1c0ef66a417a6f6564286f4e6142628e8a8117db
+MISC ChangeLog 12618 SHA256 a6e8f2ade2168da42b0421c10af43720a1146bca3fd4ee2afa5796df6ad6d05d SHA512 c013e749b28d93b6fde1d2c3666c69eff5cd116c2ca0db7348f11c5f302f3eb4911b1ef5676f1f430ace3cd6aaa4d4968f95f5e005e80476adb8d0be6d989600 WHIRLPOOL 1c28d3986627d895a2122a95fe6b184fc69f74e221b8a7a64bcbbf1a703d73188c70eabe77c2490515b21a24b9ed59967fc2fe4fd69641e8a52a7e90f595a74e
MISC metadata.xml 328 SHA256 849994be8ceade2d17e28f22db54a0c2732509f7be7741ddcfad2c2c80bb09dc SHA512 7dfeba848d22dc9f4953acbaefdfffea99cb5eaf11f8c397d8ee4a14fb31454652f9eb48b126e55c7d50cb030ebf42e802a85948401b67130408ff85d5ea2ae7 WHIRLPOOL a8b014b6d17c4f5588bf66edd90234de8990eb1c896f92e6882a82919f2f7996ef45989c2cac75bd08961d5a48a9343f38447faa396aec2408a55251deb8c01b
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
-iEYEAREIAAYFAlK4vmwACgkQVWmRsqeSphMHPwCfb/QZp295q95JhP7d31lIOG/e
-BTUAn0vfSTApbXflQ0SYYssvr06Qhjaj
-=czjn
+iEYEAREIAAYFAlLf2cAACgkQVWmRsqeSphM7ewCeIElO/5KD3+KP68NRCxQte77R
+2voAnAzLXEYBg6B42GS+TRGXd2Ix6VE6
+=Vx73
-----END PGP SIGNATURE-----
diff --git a/x11-misc/dmenu/dmenu-4.5-r4.ebuild b/x11-misc/dmenu/dmenu-4.5-r4.ebuild
new file mode 100644
index 000000000000..09968ab1054e
--- /dev/null
+++ b/x11-misc/dmenu/dmenu-4.5-r4.ebuild
@@ -0,0 +1,59 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/x11-misc/dmenu/dmenu-4.5-r4.ebuild,v 1.1 2014/01/22 14:46:23 jer Exp $
+
+EAPI=5
+inherit eutils toolchain-funcs
+
+DESCRIPTION="a generic, highly customizable, and efficient menu for the X Window System"
+HOMEPAGE="http://tools.suckless.org/dmenu/"
+SRC_URI="http://dl.suckless.org/tools/${P}.tar.gz"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64 ~hppa ~ppc ~ppc64 ~x86 ~x86-fbsd"
+IUSE="xft xinerama"
+
+RDEPEND="
+ x11-libs/libX11
+ xft? ( x11-libs/libXft )
+ xinerama? ( x11-libs/libXinerama )
+"
+DEPEND="${RDEPEND}
+ xft? ( virtual/pkgconfig )
+ xinerama? ( virtual/pkgconfig )
+"
+
+src_prepare() {
+ # Respect our flags
+ sed -i \
+ -e '/^CFLAGS/{s|=.*|+= -ansi -pedantic -Wall $(INCS) $(CPPFLAGS)|}' \
+ -e '/^LDFLAGS/s|= -s|+=|' \
+ config.mk || die
+ # Make make verbose
+ sed -i \
+ -e 's|^ @| |g' \
+ -e '/^ echo/d' \
+ Makefile || die
+ use xft && epatch "${FILESDIR}"/${PN}-4.5-xft-3.patch
+
+ epatch_user
+}
+
+src_compile() {
+ emake CC=$(tc-getCC) \
+ "XFTINC=$( $(tc-getPKG_CONFIG) --cflags xft 2>/dev/null )" \
+ "XFTLIBS=$( $(tc-getPKG_CONFIG) --libs xft 2>/dev/null )" \
+ "XINERAMAFLAGS=$(
+ usex xinerama "-DXINERAMA $(
+ $(tc-getPKG_CONFIG) --cflags xinerama 2>/dev/null
+ )" ''
+ )" \
+ "XINERAMALIBS=$(
+ usex xinerama "$( $(tc-getPKG_CONFIG) --libs xinerama 2>/dev/null)" ''
+ )"
+}
+
+src_install() {
+ emake DESTDIR="${D}" PREFIX="/usr" install
+}
diff --git a/x11-misc/dmenu/files/dmenu-4.5-xft-2.patch b/x11-misc/dmenu/files/dmenu-4.5-xft-2.patch
index 9dea981e4fe8..4e3f32c6aabb 100644
--- a/x11-misc/dmenu/files/dmenu-4.5-xft-2.patch
+++ b/x11-misc/dmenu/files/dmenu-4.5-xft-2.patch
@@ -1,6 +1,6 @@
---- a/dmenu-4.5/config.mk 2012-01-08 12:18:43.000000000 +0000
-+++ b/dmenu-4.5/config.mk 2013-05-17 10:47:11.964786792 +0100
-@@ -12,9 +12,13 @@ X11LIB = /usr/X11R6/lib
+--- a/config.mk
++++ b/config.mk
+@@ -12,9 +12,13 @@
XINERAMALIBS = -lXinerama
XINERAMAFLAGS = -DXINERAMA
@@ -16,9 +16,9 @@
# flags
CPPFLAGS = -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
---- a/dmenu-4.5/dmenu.1 2012-01-08 12:18:43.000000000 +0000
-+++ b/dmenu-4.5/dmenu.1 2013-05-17 10:47:11.964786792 +0100
-@@ -53,7 +53,7 @@ dmenu lists items vertically, with the g
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -53,7 +53,7 @@
defines the prompt to be displayed to the left of the input field.
.TP
.BI \-fn " font"
@@ -27,8 +27,8 @@
.TP
.BI \-nb " color"
defines the normal background color.
---- a/dmenu-4.5/dmenu.c 2012-01-08 12:18:43.000000000 +0000
-+++ b/dmenu-4.5/dmenu.c 2013-05-17 10:47:11.964786792 +0100
+--- a/dmenu.c
++++ b/dmenu.c
@@ -17,6 +17,7 @@
* MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
@@ -37,7 +37,7 @@
typedef struct Item Item;
struct Item {
-@@ -26,6 +27,7 @@ struct Item {
+@@ -26,6 +27,7 @@
static void appenditem(Item *item, Item **list, Item **last);
static void calcoffsets(void);
@@ -45,7 +45,7 @@
static char *cistrstr(const char *s, const char *sub);
static void drawmenu(void);
static void grabkeyboard(void);
-@@ -50,10 +52,12 @@ static const char *normfgcolor = "#bbbbb
+@@ -50,10 +52,12 @@
static const char *selbgcolor = "#005577";
static const char *selfgcolor = "#eeeeee";
static unsigned int lines = 0;
@@ -60,7 +60,7 @@
static DC *dc;
static Item *items = NULL;
static Item *matches, *matchend;
-@@ -104,7 +108,9 @@ main(int argc, char *argv[]) {
+@@ -104,7 +108,9 @@
usage();
dc = initdc();
@@ -71,7 +71,7 @@
if(fast) {
grabkeyboard();
-@@ -117,7 +123,8 @@ main(int argc, char *argv[]) {
+@@ -117,7 +123,8 @@
setup();
run();
@@ -81,7 +81,7 @@
}
void
-@@ -160,6 +167,15 @@ cistrstr(const char *s, const char *sub)
+@@ -160,6 +167,15 @@
}
void
@@ -97,7 +97,7 @@
drawmenu(void) {
int curpos;
Item *item;
-@@ -167,7 +183,7 @@ drawmenu(void) {
+@@ -167,7 +183,7 @@
dc->x = 0;
dc->y = 0;
dc->h = bh;
@@ -106,7 +106,7 @@
if(prompt) {
dc->w = promptw;
-@@ -178,7 +194,7 @@ drawmenu(void) {
+@@ -178,7 +194,7 @@
dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw;
drawtext(dc, text, normcol);
if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w)
@@ -115,7 +115,7 @@
if(lines > 0) {
/* draw vertical list */
-@@ -321,7 +337,8 @@ keypress(XKeyEvent *ev) {
+@@ -321,7 +337,8 @@
sel = matchend;
break;
case XK_Escape:
@@ -125,7 +125,7 @@
case XK_Home:
if(sel == matches) {
cursor = 0;
-@@ -359,7 +376,8 @@ keypress(XKeyEvent *ev) {
+@@ -359,7 +376,8 @@
case XK_Return:
case XK_KP_Enter:
puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
@@ -135,7 +135,7 @@
case XK_Right:
if(text[cursor] != '\0') {
cursor = nextrune(+1);
-@@ -490,7 +508,7 @@ void
+@@ -490,7 +508,7 @@
run(void) {
XEvent ev;
@@ -144,7 +144,7 @@
if(XFilterEvent(&ev, win))
continue;
switch(ev.type) {
-@@ -524,11 +542,6 @@ setup(void) {
+@@ -524,11 +542,6 @@
XineramaScreenInfo *info;
#endif
@@ -156,7 +156,7 @@
clip = XInternAtom(dc->dpy, "CLIPBOARD", False);
utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);
-@@ -582,7 +595,7 @@ setup(void) {
+@@ -582,7 +595,7 @@
/* create menu window */
swa.override_redirect = True;
@@ -165,8 +165,8 @@
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
win = XCreateWindow(dc->dpy, root, x, y, mw, mh, 0,
DefaultDepth(dc->dpy, screen), CopyFromParent,
---- a/dmenu-4.5/draw.c 2012-01-08 12:18:43.000000000 +0000
-+++ b/dmenu-4.5/draw.c 2013-05-17 10:47:54.491105887 +0100
+--- a/draw.c
++++ b/draw.c
@@ -9,9 +9,6 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b))
@@ -177,7 +177,7 @@
void
drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color) {
-@@ -23,7 +20,7 @@ drawrect(DC *dc, int x, int y, unsigned
+@@ -23,7 +20,7 @@
}
void
@@ -186,7 +186,7 @@
char buf[BUFSIZ];
size_t mn, n = strlen(text);
-@@ -35,19 +32,24 @@ drawtext(DC *dc, const char *text, unsig
+@@ -35,19 +32,24 @@
if(mn < n)
for(n = MAX(mn-3, 0); n < mn; buf[n++] = '.');
@@ -216,7 +216,7 @@
XSetFont(dc->dpy, dc->gc, dc->font.xfont->fid);
XDrawString(dc->dpy, dc->canvas, dc->gc, x, y, text, n);
}
-@@ -69,16 +71,33 @@ eprintf(const char *fmt, ...) {
+@@ -69,16 +71,33 @@
}
void
@@ -255,7 +255,7 @@
}
unsigned long
-@@ -91,6 +110,20 @@ getcolor(DC *dc, const char *colstr) {
+@@ -91,6 +110,20 @@
return color.pixel;
}
@@ -276,7 +276,7 @@
DC *
initdc(void) {
DC *dc;
-@@ -109,23 +142,11 @@ initdc(void) {
+@@ -109,23 +142,11 @@
void
initfont(DC *dc, const char *fontstr) {
@@ -301,7 +301,7 @@
if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) {
n = XFontsOfFontSet(dc->font.set, &xfonts, &names);
for(i = 0; i < n; i++) {
-@@ -133,15 +154,21 @@ loadfont(DC *dc, const char *fontstr) {
+@@ -133,15 +154,21 @@
dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent);
dc->font.width = MAX(dc->font.width, xfonts[i]->max_bounds.width);
}
@@ -327,7 +327,7 @@
}
void
-@@ -151,20 +178,29 @@ mapdc(DC *dc, Window win, unsigned int w
+@@ -151,20 +178,29 @@
void
resizedc(DC *dc, unsigned int w, unsigned int h) {
@@ -360,8 +360,8 @@
XmbTextExtents(dc->font.set, text, len, NULL, &r);
return r.width;
}
---- a/dmenu-4.5/draw.h 2012-01-08 12:18:43.000000000 +0000
-+++ b/dmenu-4.5/draw.h 2013-05-17 10:47:11.964786792 +0100
+--- a/draw.h
++++ b/draw.h
@@ -1,9 +1,6 @@
/* See LICENSE file for copyright and license details. */
@@ -373,7 +373,7 @@
typedef struct {
int x, y, w, h;
-@@ -11,6 +8,7 @@ typedef struct {
+@@ -11,6 +8,7 @@
Display *dpy;
GC gc;
Pixmap canvas;
@@ -381,7 +381,7 @@
struct {
int ascent;
int descent;
-@@ -18,15 +16,24 @@ typedef struct {
+@@ -18,15 +16,24 @@
int width;
XFontSet set;
XFontStruct *xfont;
diff --git a/x11-misc/dmenu/files/dmenu-4.5-xft-3.patch b/x11-misc/dmenu/files/dmenu-4.5-xft-3.patch
new file mode 100644
index 000000000000..e97629a69871
--- /dev/null
+++ b/x11-misc/dmenu/files/dmenu-4.5-xft-3.patch
@@ -0,0 +1,412 @@
+--- a/config.mk
++++ b/config.mk
+@@ -12,9 +12,13 @@
+ XINERAMALIBS = -lXinerama
+ XINERAMAFLAGS = -DXINERAMA
+
++# Xft, comment if you don't want it
++XFTINC = $(shell pkg-config --cflags xft)
++XFTLIBS = $(shell pkg-config --libs xft)
++
+ # includes and libs
+-INCS = -I${X11INC}
+-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS}
++INCS = -I${X11INC} ${XFTINC}
++LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${XFTLIBS}
+
+ # flags
+ CPPFLAGS = -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -53,7 +53,7 @@
+ defines the prompt to be displayed to the left of the input field.
+ .TP
+ .BI \-fn " font"
+-defines the font or font set used.
++defines the font or font set used. eg. "fixed" or "Monospace-12:normal" (an xft font)
+ .TP
+ .BI \-nb " color"
+ defines the normal background color.
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -17,6 +17,7 @@
+ * MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
+ #define MIN(a,b) ((a) < (b) ? (a) : (b))
+ #define MAX(a,b) ((a) > (b) ? (a) : (b))
++#define DEFFONT "fixed" /* xft example: "Monospace-11" */
+
+ typedef struct Item Item;
+ struct Item {
+@@ -26,6 +27,7 @@
+
+ static void appenditem(Item *item, Item **list, Item **last);
+ static void calcoffsets(void);
++static void cleanup(void);
+ static char *cistrstr(const char *s, const char *sub);
+ static void drawmenu(void);
+ static void grabkeyboard(void);
+@@ -50,10 +52,12 @@
+ static const char *selbgcolor = "#005577";
+ static const char *selfgcolor = "#eeeeee";
+ static unsigned int lines = 0;
+-static unsigned long normcol[ColLast];
+-static unsigned long selcol[ColLast];
++static ColorSet *normcol;
++static ColorSet *selcol;
+ static Atom clip, utf8;
+ static Bool topbar = True;
++static Bool running = True;
++static int ret = 0;
+ static DC *dc;
+ static Item *items = NULL;
+ static Item *matches, *matchend;
+@@ -104,7 +108,9 @@
+ usage();
+
+ dc = initdc();
+- initfont(dc, font);
++ initfont(dc, font ? font : DEFFONT);
++ normcol = initcolor(dc, normfgcolor, normbgcolor);
++ selcol = initcolor(dc, selfgcolor, selbgcolor);
+
+ if(fast) {
+ grabkeyboard();
+@@ -117,7 +123,8 @@
+ setup();
+ run();
+
+- return 1; /* unreachable */
++ cleanup();
++ return ret;
+ }
+
+ void
+@@ -160,6 +167,15 @@
+ }
+
+ void
++cleanup(void) {
++ freecol(dc, normcol);
++ freecol(dc, selcol);
++ XDestroyWindow(dc->dpy, win);
++ XUngrabKeyboard(dc->dpy, CurrentTime);
++ freedc(dc);
++}
++
++void
+ drawmenu(void) {
+ int curpos;
+ Item *item;
+@@ -167,7 +183,7 @@
+ dc->x = 0;
+ dc->y = 0;
+ dc->h = bh;
+- drawrect(dc, 0, 0, mw, mh, True, BG(dc, normcol));
++ drawrect(dc, 0, 0, mw, mh, True, normcol->BG);
+
+ if(prompt) {
+ dc->w = promptw;
+@@ -178,7 +194,7 @@
+ dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw;
+ drawtext(dc, text, normcol);
+ if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w)
+- drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol));
++ drawrect(dc, curpos, 2, 1, dc->h - 4, True, normcol->FG);
+
+ if(lines > 0) {
+ /* draw vertical list */
+@@ -321,7 +337,9 @@
+ sel = matchend;
+ break;
+ case XK_Escape:
+- exit(EXIT_FAILURE);
++ ret = EXIT_FAILURE;
++ running = False;
++ break;
+ case XK_Home:
+ if(sel == matches) {
+ cursor = 0;
+@@ -359,7 +377,9 @@
+ case XK_Return:
+ case XK_KP_Enter:
+ puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
+- exit(EXIT_SUCCESS);
++ ret = EXIT_SUCCESS;
++ running = False;
++ break;
+ case XK_Right:
+ if(text[cursor] != '\0') {
+ cursor = nextrune(+1);
+@@ -490,7 +510,7 @@
+ run(void) {
+ XEvent ev;
+
+- while(!XNextEvent(dc->dpy, &ev)) {
++ while(running && !XNextEvent(dc->dpy, &ev)) {
+ if(XFilterEvent(&ev, win))
+ continue;
+ switch(ev.type) {
+@@ -524,11 +544,6 @@
+ XineramaScreenInfo *info;
+ #endif
+
+- normcol[ColBG] = getcolor(dc, normbgcolor);
+- normcol[ColFG] = getcolor(dc, normfgcolor);
+- selcol[ColBG] = getcolor(dc, selbgcolor);
+- selcol[ColFG] = getcolor(dc, selfgcolor);
+-
+ clip = XInternAtom(dc->dpy, "CLIPBOARD", False);
+ utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);
+
+@@ -582,7 +597,7 @@
+
+ /* create menu window */
+ swa.override_redirect = True;
+- swa.background_pixel = normcol[ColBG];
++ swa.background_pixel = normcol->BG;
+ swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
+ win = XCreateWindow(dc->dpy, root, x, y, mw, mh, 0,
+ DefaultDepth(dc->dpy, screen), CopyFromParent,
+--- a/draw.c
++++ b/draw.c
+@@ -9,9 +9,6 @@
+
+ #define MAX(a, b) ((a) > (b) ? (a) : (b))
+ #define MIN(a, b) ((a) < (b) ? (a) : (b))
+-#define DEFAULTFN "fixed"
+-
+-static Bool loadfont(DC *dc, const char *fontstr);
+
+ void
+ drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color) {
+@@ -23,7 +20,7 @@
+ }
+
+ void
+-drawtext(DC *dc, const char *text, unsigned long col[ColLast]) {
++drawtext(DC *dc, const char *text, ColorSet *col) {
+ char buf[BUFSIZ];
+ size_t mn, n = strlen(text);
+
+@@ -35,19 +32,24 @@
+ if(mn < n)
+ for(n = MAX(mn-3, 0); n < mn; buf[n++] = '.');
+
+- drawrect(dc, 0, 0, dc->w, dc->h, True, BG(dc, col));
++ drawrect(dc, 0, 0, dc->w, dc->h, True, col->BG);
+ drawtextn(dc, buf, mn, col);
+ }
+
+ void
+-drawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]) {
++drawtextn(DC *dc, const char *text, size_t n, ColorSet *col) {
+ int x = dc->x + dc->font.height/2;
+ int y = dc->y + dc->font.ascent+1;
+
+- XSetForeground(dc->dpy, dc->gc, FG(dc, col));
+- if(dc->font.set)
++ XSetForeground(dc->dpy, dc->gc, col->FG);
++ if(dc->font.xft_font) {
++ if (!dc->xftdraw)
++ eprintf("error, xft drawable does not exist");
++ XftDrawStringUtf8(dc->xftdraw, &col->FG_xft,
++ dc->font.xft_font, x, y, (unsigned char*)text, n);
++ } else if(dc->font.set) {
+ XmbDrawString(dc->dpy, dc->canvas, dc->font.set, dc->gc, x, y, text, n);
+- else {
++ } else {
+ XSetFont(dc->dpy, dc->gc, dc->font.xfont->fid);
+ XDrawString(dc->dpy, dc->canvas, dc->gc, x, y, text, n);
+ }
+@@ -69,16 +71,33 @@
+ }
+
+ void
++freecol(DC *dc, ColorSet *col) {
++ if(col) {
++ if(&col->FG_xft)
++ XftColorFree(dc->dpy, DefaultVisual(dc->dpy, DefaultScreen(dc->dpy)),
++ DefaultColormap(dc->dpy, DefaultScreen(dc->dpy)), &col->FG_xft);
++ free(col);
++ }
++}
++
++void
+ freedc(DC *dc) {
++ if(dc->font.xft_font) {
++ XftFontClose(dc->dpy, dc->font.xft_font);
++ XftDrawDestroy(dc->xftdraw);
++ }
+ if(dc->font.set)
+ XFreeFontSet(dc->dpy, dc->font.set);
+- if(dc->font.xfont)
++ if(dc->font.xfont)
+ XFreeFont(dc->dpy, dc->font.xfont);
+- if(dc->canvas)
++ if(dc->canvas)
+ XFreePixmap(dc->dpy, dc->canvas);
+- XFreeGC(dc->dpy, dc->gc);
+- XCloseDisplay(dc->dpy);
+- free(dc);
++ if(dc->gc)
++ XFreeGC(dc->dpy, dc->gc);
++ if(dc->dpy)
++ XCloseDisplay(dc->dpy);
++ if(dc)
++ free(dc);
+ }
+
+ unsigned long
+@@ -91,6 +110,20 @@
+ return color.pixel;
+ }
+
++ColorSet *
++initcolor(DC *dc, const char * foreground, const char * background) {
++ ColorSet * col = (ColorSet *)malloc(sizeof(ColorSet));
++ if(!col)
++ eprintf("error, cannot allocate memory for color set");
++ col->BG = getcolor(dc, background);
++ col->FG = getcolor(dc, foreground);
++ if(dc->font.xft_font)
++ if(!XftColorAllocName(dc->dpy, DefaultVisual(dc->dpy, DefaultScreen(dc->dpy)),
++ DefaultColormap(dc->dpy, DefaultScreen(dc->dpy)), foreground, &col->FG_xft))
++ eprintf("error, cannot allocate xft font color '%s'\n", foreground);
++ return col;
++}
++
+ DC *
+ initdc(void) {
+ DC *dc;
+@@ -109,23 +142,11 @@
+
+ void
+ initfont(DC *dc, const char *fontstr) {
+- if(!loadfont(dc, fontstr ? fontstr : DEFAULTFN)) {
+- if(fontstr != NULL)
+- fprintf(stderr, "cannot load font '%s'\n", fontstr);
+- if(fontstr == NULL || !loadfont(dc, DEFAULTFN))
+- eprintf("cannot load font '%s'\n", DEFAULTFN);
+- }
+- dc->font.height = dc->font.ascent + dc->font.descent;
+-}
+-
+-Bool
+-loadfont(DC *dc, const char *fontstr) {
+ char *def, **missing, **names;
+ int i, n;
+ XFontStruct **xfonts;
+
+- if(!*fontstr)
+- return False;
++ missing = NULL;
+ if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) {
+ n = XFontsOfFontSet(dc->font.set, &xfonts, &names);
+ for(i = 0; i < n; i++) {
+@@ -133,15 +154,21 @@
+ dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent);
+ dc->font.width = MAX(dc->font.width, xfonts[i]->max_bounds.width);
+ }
+- }
+- else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) {
+- dc->font.ascent = dc->font.xfont->ascent;
++ } else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) {
++ dc->font.ascent = dc->font.xfont->ascent;
+ dc->font.descent = dc->font.xfont->descent;
+ dc->font.width = dc->font.xfont->max_bounds.width;
++ } else if((dc->font.xft_font = XftFontOpenName(dc->dpy, DefaultScreen(dc->dpy), fontstr))) {
++ dc->font.ascent = dc->font.xft_font->ascent;
++ dc->font.descent = dc->font.xft_font->descent;
++ dc->font.width = dc->font.xft_font->max_advance_width;
++ } else {
++ eprintf("cannot load font '%s'\n", fontstr);
+ }
+ if(missing)
+ XFreeStringList(missing);
+- return dc->font.set || dc->font.xfont;
++ dc->font.height = dc->font.ascent + dc->font.descent;
++ return;
+ }
+
+ void
+@@ -151,20 +178,29 @@
+
+ void
+ resizedc(DC *dc, unsigned int w, unsigned int h) {
++ int screen = DefaultScreen(dc->dpy);
+ if(dc->canvas)
+ XFreePixmap(dc->dpy, dc->canvas);
+
+ dc->w = w;
+ dc->h = h;
+ dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h,
+- DefaultDepth(dc->dpy, DefaultScreen(dc->dpy)));
++ DefaultDepth(dc->dpy, screen));
++ if(dc->font.xft_font && !(dc->xftdraw)) {
++ dc->xftdraw = XftDrawCreate(dc->dpy, dc->canvas, DefaultVisual(dc->dpy,screen), DefaultColormap(dc->dpy,screen));
++ if(!(dc->xftdraw))
++ eprintf("error, cannot create xft drawable\n");
++ }
+ }
+
+ int
+ textnw(DC *dc, const char *text, size_t len) {
+- if(dc->font.set) {
++ if(dc->font.xft_font) {
++ XGlyphInfo gi;
++ XftTextExtentsUtf8(dc->dpy, dc->font.xft_font, (const FcChar8*)text, len, &gi);
++ return gi.width;
++ } else if(dc->font.set) {
+ XRectangle r;
+-
+ XmbTextExtents(dc->font.set, text, len, NULL, &r);
+ return r.width;
+ }
+--- a/draw.h
++++ b/draw.h
+@@ -1,9 +1,6 @@
+ /* See LICENSE file for copyright and license details. */
+
+-#define FG(dc, col) ((col)[(dc)->invert ? ColBG : ColFG])
+-#define BG(dc, col) ((col)[(dc)->invert ? ColFG : ColBG])
+-
+-enum { ColBG, ColFG, ColBorder, ColLast };
++#include <X11/Xft/Xft.h>
+
+ typedef struct {
+ int x, y, w, h;
+@@ -11,6 +8,7 @@
+ Display *dpy;
+ GC gc;
+ Pixmap canvas;
++ XftDraw *xftdraw;
+ struct {
+ int ascent;
+ int descent;
+@@ -18,15 +16,24 @@
+ int width;
+ XFontSet set;
+ XFontStruct *xfont;
++ XftFont *xft_font;
+ } font;
+ } DC; /* draw context */
+
++typedef struct {
++ unsigned long FG;
++ XftColor FG_xft;
++ unsigned long BG;
++} ColorSet;
++
+ void drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color);
+-void drawtext(DC *dc, const char *text, unsigned long col[ColLast]);
+-void drawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]);
++void drawtext(DC *dc, const char *text, ColorSet *col);
++void drawtextn(DC *dc, const char *text, size_t n, ColorSet *col);
++void freecol(DC *dc, ColorSet *col);
+ void eprintf(const char *fmt, ...);
+ void freedc(DC *dc);
+ unsigned long getcolor(DC *dc, const char *colstr);
++ColorSet *initcolor(DC *dc, const char *foreground, const char *background);
+ DC *initdc(void);
+ void initfont(DC *dc, const char *fontstr);
+ void mapdc(DC *dc, Window win, unsigned int w, unsigned int h);