1 |
commit: 6d24833ef40e86559961355d215b610a11457742 |
2 |
Author: Michael Weber <xmw <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue May 31 02:42:03 2011 +0000 |
4 |
Commit: Michael Weber <xmw <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue May 31 02:42:03 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/xmw.git;a=commit;h=6d24833e |
7 |
|
8 |
x11-misc/dmenu: Initial import w/ xft patch |
9 |
|
10 |
(Portage version: 2.1.9.42/git/Linux x86_64, signed Manifest commit with key 62EEF090) |
11 |
|
12 |
--- |
13 |
x11-misc/dmenu/ChangeLog | 10 + |
14 |
x11-misc/dmenu/Manifest | 15 + |
15 |
x11-misc/dmenu/dmenu-4.3.1.ebuild | 48 ++++ |
16 |
x11-misc/dmenu/files/dmenu-4.3.1-xft.patch | 381 ++++++++++++++++++++++++++++ |
17 |
x11-misc/dmenu/metadata.xml | 9 + |
18 |
5 files changed, 463 insertions(+), 0 deletions(-) |
19 |
|
20 |
diff --git a/x11-misc/dmenu/ChangeLog b/x11-misc/dmenu/ChangeLog |
21 |
new file mode 100644 |
22 |
index 0000000..3594f0a |
23 |
--- /dev/null |
24 |
+++ b/x11-misc/dmenu/ChangeLog |
25 |
@@ -0,0 +1,10 @@ |
26 |
+# ChangeLog for x11-misc/dmenu |
27 |
+# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2 |
28 |
+# $Header: $ |
29 |
+ |
30 |
+*dmenu-4.3.1 (31 May 2011) |
31 |
+ |
32 |
+ 31 May 2011; Michael Weber <xmw@g.o> +dmenu-4.3.1.ebuild, |
33 |
+ +files/dmenu-4.3.1-xft.patch, +metadata.xml: |
34 |
+ Initial import w/ xft patch |
35 |
+ |
36 |
|
37 |
diff --git a/x11-misc/dmenu/Manifest b/x11-misc/dmenu/Manifest |
38 |
new file mode 100644 |
39 |
index 0000000..b2f2437 |
40 |
--- /dev/null |
41 |
+++ b/x11-misc/dmenu/Manifest |
42 |
@@ -0,0 +1,15 @@ |
43 |
+-----BEGIN PGP SIGNED MESSAGE----- |
44 |
+Hash: SHA256 |
45 |
+ |
46 |
+AUX dmenu-4.3.1-xft.patch 11711 RMD160 43c39e128d6fbe07e81945ef5567153d709fe2a4 SHA1 0f893f21406e4d292b0c1e9b96efe31957103bd6 SHA256 61ef78f8b6105828e4120cb3a15c994f92bbec8b909c7a34fa9fda24f7dd17e7 |
47 |
+DIST dmenu-4.3.1.tar.gz 8905 RMD160 61675030c88c31bce88c6d2a2e408b28f622b68c SHA1 c22c468f9383ff485feacb9662571c4d1601aca3 SHA256 7da646228b52a2a5966b27190701e9514c08ee16ac538404b5dfa13b10b3c0ca |
48 |
+EBUILD dmenu-4.3.1.ebuild 1256 RMD160 9e1d2448873906c9ca449dff1443ffd8978235cd SHA1 7f20eea3ea0394cb26dd7fde942a31c32cbe6c65 SHA256 63e98a85ed550a57ca3216a969e209567b7dc53d445186a5338f217203ed723a |
49 |
+MISC ChangeLog 288 RMD160 e5d48ca2feecd9cfc201e090fec3821686dad480 SHA1 985d395d023bf3a8ebeaa9446e9a07936e5a2407 SHA256 96d1993dbba93014471ab60b0554446cb3c3023b63b4a21b0209f05c0e4e12b9 |
50 |
+MISC metadata.xml 244 RMD160 ba31bc851ce5d8e007b223b4f799d84d4c6699d0 SHA1 2192e855054fb7016488afba3eda6d938fdf925d SHA256 1022f65be1952b5197408dfbf61543b61557601ce3a9f15acabeb3e9d84a0fbe |
51 |
+-----BEGIN PGP SIGNATURE----- |
52 |
+Version: GnuPG v2.0.17 (GNU/Linux) |
53 |
+ |
54 |
+iF4EAREIAAYFAk3kVXoACgkQknrdDGLu8JASHwD/VvMI0QKhOw5HwkJFGwZiPBb3 |
55 |
+GtKV7gP1zEwZ1vqAYjMA/2shEGPOyLqRNaTLsShI/gdfK9Xkun4LyQeDD3SClXyP |
56 |
+=rcB5 |
57 |
+-----END PGP SIGNATURE----- |
58 |
|
59 |
diff --git a/x11-misc/dmenu/dmenu-4.3.1.ebuild b/x11-misc/dmenu/dmenu-4.3.1.ebuild |
60 |
new file mode 100644 |
61 |
index 0000000..aa06b5e |
62 |
--- /dev/null |
63 |
+++ b/x11-misc/dmenu/dmenu-4.3.1.ebuild |
64 |
@@ -0,0 +1,48 @@ |
65 |
+# Copyright 1999-2011 Gentoo Foundation |
66 |
+# Distributed under the terms of the GNU General Public License v2 |
67 |
+# $Header: /var/cvsroot/gentoo-x86/x11-misc/dmenu/dmenu-4.2.1.ebuild,v 1.5 2011/03/16 21:17:05 xarthisius Exp $ |
68 |
+ |
69 |
+EAPI="2" |
70 |
+ |
71 |
+inherit eutils toolchain-funcs |
72 |
+ |
73 |
+DESCRIPTION="a generic, highly customizable, and efficient menu for the X Window System" |
74 |
+HOMEPAGE="http://www.suckless.org/programs/dmenu.html" |
75 |
+SRC_URI="http://dl.suckless.org/tools/${P}.tar.gz" |
76 |
+ |
77 |
+LICENSE="MIT" |
78 |
+SLOT="0" |
79 |
+KEYWORDS="~amd64 ~hppa ~ppc ~ppc64 ~x86 ~x86-fbsd" |
80 |
+IUSE="xft xinerama" |
81 |
+ |
82 |
+DEPEND="x11-libs/libX11 |
83 |
+ xinerama? ( x11-libs/libXinerama )" |
84 |
+RDEPEND=${DEPEND} |
85 |
+ |
86 |
+src_prepare() { |
87 |
+ if use xft ; then |
88 |
+ epatch "${FILESDIR}/${P}-xft.patch" |
89 |
+ fi |
90 |
+ |
91 |
+ sed -i \ |
92 |
+ -e "s/CFLAGS = -ansi -pedantic -Wall -Os/CFLAGS += -ansi -pedantic -Wall/" \ |
93 |
+ -e "s/LDFLAGS = -s/LDFLAGS += -g/" \ |
94 |
+ -e "s/XINERAMALIBS =/XINERAMALIBS ?=/" \ |
95 |
+ -e "s/XINERAMAFLAGS =/XINERAMAFLAGS ?=/" \ |
96 |
+ config.mk || die "sed failed" |
97 |
+} |
98 |
+ |
99 |
+src_compile() { |
100 |
+ if use xinerama; then |
101 |
+ emake CC=$(tc-getCC) || die "emake failed" |
102 |
+ else |
103 |
+ emake CC=$(tc-getCC) XINERAMAFLAGS="" XINERAMALIBS="" \ |
104 |
+ || die "emake failed" |
105 |
+ fi |
106 |
+} |
107 |
+ |
108 |
+src_install() { |
109 |
+ emake DESTDIR="${D}" PREFIX="/usr" install || die "emake install failed" |
110 |
+ |
111 |
+ dodoc README |
112 |
+} |
113 |
|
114 |
diff --git a/x11-misc/dmenu/files/dmenu-4.3.1-xft.patch b/x11-misc/dmenu/files/dmenu-4.3.1-xft.patch |
115 |
new file mode 100644 |
116 |
index 0000000..0a2d7fb |
117 |
--- /dev/null |
118 |
+++ b/x11-misc/dmenu/files/dmenu-4.3.1-xft.patch |
119 |
@@ -0,0 +1,381 @@ |
120 |
+diff -rup dmenu-4.3.1/config.mk dmenu-xft/config.mk |
121 |
+--- dmenu-4.3.1/config.mk 2011-05-18 21:32:16.000000000 +0530 |
122 |
++++ dmenu-xft/config.mk 2011-05-20 03:14:15.000000000 +0530 |
123 |
+@@ -2,19 +2,24 @@ |
124 |
+ VERSION = 4.3.1 |
125 |
+ |
126 |
+ # paths |
127 |
+-PREFIX = /usr/local |
128 |
+-MANPREFIX = ${PREFIX}/share/man |
129 |
++PREFIX = /usr |
130 |
++MANPREFIX = ${PREFIX}/share |
131 |
+ |
132 |
+ X11INC = /usr/X11R6/include |
133 |
+ X11LIB = /usr/X11R6/lib |
134 |
+ |
135 |
++# Xft, comment if you don't want it |
136 |
++XFTINC = /usr/include/freetype2 |
137 |
++XFTLIBS = -lXft -lXrender -lfreetype -lz -lfontconfig |
138 |
++ |
139 |
++ |
140 |
+ # Xinerama, comment if you don't want it |
141 |
+ XINERAMALIBS = -lXinerama |
142 |
+ XINERAMAFLAGS = -DXINERAMA |
143 |
+ |
144 |
+ # includes and libs |
145 |
+-INCS = -I${X11INC} |
146 |
+-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} |
147 |
++INCS = -I${X11INC} -I${XFTINC} |
148 |
++LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${XFTLIBS} |
149 |
+ |
150 |
+ # flags |
151 |
+ CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} |
152 |
+diff -rup dmenu-4.3.1/dmenu.c dmenu-xft/dmenu.c |
153 |
+--- dmenu-4.3.1/dmenu.c 2011-05-18 21:32:16.000000000 +0530 |
154 |
++++ dmenu-xft/dmenu.c 2011-05-20 03:12:16.000000000 +0530 |
155 |
+@@ -16,6 +16,8 @@ |
156 |
+ #define INRECT(x,y,rx,ry,rw,rh) ((x) >= (rx) && (x) < (rx)+(rw) && (y) >= (ry) && (y) < (ry)+(rh)) |
157 |
+ #define MIN(a,b) ((a) < (b) ? (a) : (b)) |
158 |
+ #define MAX(a,b) ((a) > (b) ? (a) : (b)) |
159 |
++#define DEFFONT "fixed" /* xft example: "Monospace-11" */ |
160 |
++ |
161 |
+ |
162 |
+ typedef struct Item Item; |
163 |
+ struct Item { |
164 |
+@@ -49,8 +51,8 @@ static const char *normbgcolor = "#ccccc |
165 |
+ static const char *normfgcolor = "#000000"; |
166 |
+ static const char *selbgcolor = "#0066ff"; |
167 |
+ static const char *selfgcolor = "#ffffff"; |
168 |
+-static unsigned long normcol[ColLast]; |
169 |
+-static unsigned long selcol[ColLast]; |
170 |
++static ColorSet *normcol; |
171 |
++static ColorSet *selcol; |
172 |
+ static Atom utf8; |
173 |
+ static Bool topbar = True; |
174 |
+ static DC *dc; |
175 |
+@@ -99,7 +101,9 @@ main(int argc, char *argv[]) { |
176 |
+ usage(); |
177 |
+ |
178 |
+ dc = initdc(); |
179 |
+- initfont(dc, font); |
180 |
++ initfont(dc, font ? font : DEFFONT); |
181 |
++ normcol = initcolor(dc, normfgcolor, normbgcolor); |
182 |
++ selcol = initcolor(dc, selfgcolor, selbgcolor); |
183 |
+ |
184 |
+ if(fast) { |
185 |
+ grabkeyboard(); |
186 |
+@@ -151,7 +155,8 @@ drawmenu(void) { |
187 |
+ dc->x = 0; |
188 |
+ dc->y = 0; |
189 |
+ dc->h = bh; |
190 |
+- drawrect(dc, 0, 0, mw, mh, True, BG(dc, normcol)); |
191 |
++ drawrect(dc, 0, 0, mw, mh, True, normcol->BG); |
192 |
++ |
193 |
+ |
194 |
+ if(prompt) { |
195 |
+ dc->w = promptw; |
196 |
+@@ -161,7 +166,7 @@ drawmenu(void) { |
197 |
+ dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw; |
198 |
+ drawtext(dc, text, normcol); |
199 |
+ if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w) |
200 |
+- drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol)); |
201 |
++ drawrect(dc, curpos, 2, 1, dc->h - 4, True, normcol->FG); |
202 |
+ |
203 |
+ if(lines > 0) { |
204 |
+ dc->w = mw - dc->x; |
205 |
+@@ -495,11 +500,12 @@ setup(void) { |
206 |
+ XineramaScreenInfo *info; |
207 |
+ #endif |
208 |
+ |
209 |
++ /* |
210 |
+ normcol[ColBG] = getcolor(dc, normbgcolor); |
211 |
+ normcol[ColFG] = getcolor(dc, normfgcolor); |
212 |
+ selcol[ColBG] = getcolor(dc, selbgcolor); |
213 |
+ selcol[ColFG] = getcolor(dc, selfgcolor); |
214 |
+- |
215 |
++*/ |
216 |
+ utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); |
217 |
+ |
218 |
+ /* menu geometry */ |
219 |
+Only in dmenu-4.3.1: dmenu_path |
220 |
+Only in dmenu-4.3.1: dmenu_run |
221 |
+diff -rup dmenu-4.3.1/draw.c dmenu-xft/draw.c |
222 |
+--- dmenu-4.3.1/draw.c 2011-05-18 21:32:16.000000000 +0530 |
223 |
++++ dmenu-xft/draw.c 2011-05-20 03:16:36.000000000 +0530 |
224 |
+@@ -5,13 +5,11 @@ |
225 |
+ #include <stdlib.h> |
226 |
+ #include <string.h> |
227 |
+ #include <X11/Xlib.h> |
228 |
++#include <X11/Xft/Xft.h> |
229 |
+ #include "draw.h" |
230 |
+ |
231 |
+ #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
232 |
+ #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
233 |
+-#define DEFAULTFN "fixed" |
234 |
+- |
235 |
+-static Bool loadfont(DC *dc, const char *fontstr); |
236 |
+ |
237 |
+ void |
238 |
+ drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color) { |
239 |
+@@ -23,7 +21,7 @@ drawrect(DC *dc, int x, int y, unsigned |
240 |
+ } |
241 |
+ |
242 |
+ void |
243 |
+-drawtext(DC *dc, const char *text, unsigned long col[ColLast]) { |
244 |
++drawtext(DC *dc, const char *text, ColorSet *col) { |
245 |
+ char buf[BUFSIZ]; |
246 |
+ size_t mn, n = strlen(text); |
247 |
+ |
248 |
+@@ -35,19 +33,25 @@ drawtext(DC *dc, const char *text, unsig |
249 |
+ if(mn < n) |
250 |
+ for(n = MAX(mn-3, 0); n < mn; buf[n++] = '.'); |
251 |
+ |
252 |
+- drawrect(dc, 0, 0, dc->w, dc->h, True, BG(dc, col)); |
253 |
++drawrect(dc, 0, 0, dc->w, dc->h, True, col->BG); |
254 |
++ |
255 |
+ drawtextn(dc, buf, mn, col); |
256 |
+ } |
257 |
+ |
258 |
+ void |
259 |
+-drawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]) { |
260 |
++drawtextn(DC *dc, const char *text, size_t n, ColorSet *col) { |
261 |
+ int x = dc->x + dc->font.height/2; |
262 |
+ int y = dc->y + dc->font.ascent+1; |
263 |
+ |
264 |
+- XSetForeground(dc->dpy, dc->gc, FG(dc, col)); |
265 |
+- if(dc->font.set) |
266 |
+- XmbDrawString(dc->dpy, dc->canvas, dc->font.set, dc->gc, x, y, text, n); |
267 |
+- else { |
268 |
++ XSetForeground(dc->dpy, dc->gc, col->FG); |
269 |
++ if(dc->font.xft_font) { |
270 |
++ if (!dc->xftdraw) |
271 |
++ eprintf("error, xft drawable does not exist"); |
272 |
++ XftDrawStringUtf8(dc->xftdraw, &col->FG_xft, |
273 |
++ dc->font.xft_font, x, y, (unsigned char*)text, n); |
274 |
++ } else if(dc->font.set) { |
275 |
++ XmbDrawString(dc->dpy, dc->canvas, dc->font.set, dc->gc, x, y, text, n); |
276 |
++ } else { |
277 |
+ XSetFont(dc->dpy, dc->gc, dc->font.xfont->fid); |
278 |
+ XDrawString(dc->dpy, dc->canvas, dc->gc, x, y, text, n); |
279 |
+ } |
280 |
+@@ -68,19 +72,53 @@ eprintf(const char *fmt, ...) { |
281 |
+ exit(EXIT_FAILURE); |
282 |
+ } |
283 |
+ |
284 |
++ void |
285 |
++freecol(DC *dc, ColorSet *col) { |
286 |
++ if(col) { |
287 |
++ if(&col->FG_xft) |
288 |
++ XftColorFree(dc->dpy, DefaultVisual(dc->dpy, DefaultScreen(dc->dpy)), |
289 |
++ DefaultColormap(dc->dpy, DefaultScreen(dc->dpy)), &col->FG_xft); |
290 |
++ free(col); |
291 |
++ } |
292 |
++} |
293 |
++ |
294 |
++ |
295 |
+ void |
296 |
+ freedc(DC *dc) { |
297 |
++ if(dc->font.xft_font) { |
298 |
++ XftFontClose(dc->dpy, dc->font.xft_font); |
299 |
++ XftDrawDestroy(dc->xftdraw); |
300 |
++ } |
301 |
+ if(dc->font.set) |
302 |
+ XFreeFontSet(dc->dpy, dc->font.set); |
303 |
+ if(dc->font.xfont) |
304 |
+ XFreeFont(dc->dpy, dc->font.xfont); |
305 |
+ if(dc->canvas) |
306 |
+ XFreePixmap(dc->dpy, dc->canvas); |
307 |
+- XFreeGC(dc->dpy, dc->gc); |
308 |
+- XCloseDisplay(dc->dpy); |
309 |
+- free(dc); |
310 |
++ if(dc->gc) |
311 |
++ XFreeGC(dc->dpy, dc->gc); |
312 |
++ if(dc->dpy) |
313 |
++ XCloseDisplay(dc->dpy); |
314 |
++ if(dc) |
315 |
++ free(dc); |
316 |
++ |
317 |
+ } |
318 |
+ |
319 |
++ColorSet * |
320 |
++initcolor(DC *dc, const char * foreground, const char * background) { |
321 |
++ ColorSet * col = (ColorSet *)malloc(sizeof(ColorSet)); |
322 |
++ if(!col) |
323 |
++ eprintf("error, cannot allocate memory for color set"); |
324 |
++ col->BG = getcolor(dc, background); |
325 |
++ col->FG = getcolor(dc, foreground); |
326 |
++ if(dc->font.xft_font) |
327 |
++ if(!XftColorAllocName(dc->dpy, DefaultVisual(dc->dpy, DefaultScreen(dc->dpy)), |
328 |
++ DefaultColormap(dc->dpy, DefaultScreen(dc->dpy)), foreground, &col->FG_xft)) |
329 |
++ eprintf("error, cannot allocate xft font color '%s'\n", foreground); |
330 |
++ return col; |
331 |
++} |
332 |
++ |
333 |
++ |
334 |
+ unsigned long |
335 |
+ getcolor(DC *dc, const char *colstr) { |
336 |
+ Colormap cmap = DefaultColormap(dc->dpy, DefaultScreen(dc->dpy)); |
337 |
+@@ -95,12 +133,16 @@ DC * |
338 |
+ initdc(void) { |
339 |
+ DC *dc; |
340 |
+ |
341 |
+- if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) |
342 |
++ if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) |
343 |
+ fprintf(stderr, "no locale support\n"); |
344 |
+ if(!(dc = calloc(1, sizeof *dc))) |
345 |
+ eprintf("cannot malloc %u bytes:", sizeof *dc); |
346 |
+ if(!(dc->dpy = XOpenDisplay(NULL))) |
347 |
+ eprintf("cannot open display\n"); |
348 |
++ dc->font.xft_font = NULL; |
349 |
++ dc->xftdraw = NULL; |
350 |
++ |
351 |
++ |
352 |
+ |
353 |
+ dc->gc = XCreateGC(dc->dpy, DefaultRootWindow(dc->dpy), 0, NULL); |
354 |
+ XSetLineAttributes(dc->dpy, dc->gc, 1, LineSolid, CapButt, JoinMiter); |
355 |
+@@ -109,23 +151,13 @@ initdc(void) { |
356 |
+ |
357 |
+ void |
358 |
+ initfont(DC *dc, const char *fontstr) { |
359 |
+- if(!loadfont(dc, fontstr ? fontstr : DEFAULTFN)) { |
360 |
+- if(fontstr != NULL) |
361 |
+- fprintf(stderr, "cannot load font '%s'\n", fontstr); |
362 |
+- if(fontstr == NULL || !loadfont(dc, DEFAULTFN)) |
363 |
+- eprintf("cannot load font '%s'\n", DEFAULTFN); |
364 |
+- } |
365 |
+- dc->font.height = dc->font.ascent + dc->font.descent; |
366 |
+-} |
367 |
+- |
368 |
+-Bool |
369 |
+-loadfont(DC *dc, const char *fontstr) { |
370 |
+- char *def, **missing; |
371 |
++ char *def, **missing=NULL; |
372 |
+ int i, n; |
373 |
+ |
374 |
+- if(!*fontstr) |
375 |
+- return False; |
376 |
+- if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) { |
377 |
++ if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) { |
378 |
++ dc->font.ascent = dc->font.xfont->ascent; |
379 |
++ dc->font.descent = dc->font.xfont->descent; |
380 |
++ } else if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) { |
381 |
+ char **names; |
382 |
+ XFontStruct **xfonts; |
383 |
+ |
384 |
+@@ -134,14 +166,16 @@ loadfont(DC *dc, const char *fontstr) { |
385 |
+ dc->font.ascent = MAX(dc->font.ascent, xfonts[i]->ascent); |
386 |
+ dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent); |
387 |
+ } |
388 |
+- } |
389 |
+- else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) { |
390 |
+- dc->font.ascent = dc->font.xfont->ascent; |
391 |
+- dc->font.descent = dc->font.xfont->descent; |
392 |
+- } |
393 |
++ } else if((dc->font.xft_font = XftFontOpenName(dc->dpy, |
394 |
++ DefaultScreen(dc->dpy), fontstr))) { |
395 |
++ dc->font.ascent = dc->font.xft_font->ascent; |
396 |
++ dc->font.descent = dc->font.xft_font->descent; |
397 |
++ } else { |
398 |
++ eprintf("cannot load font '%s'\n", fontstr); |
399 |
++ } |
400 |
+ if(missing) |
401 |
+ XFreeStringList(missing); |
402 |
+- return (dc->font.set || dc->font.xfont); |
403 |
++ dc->font.height = dc->font.ascent + dc->font.descent; |
404 |
+ } |
405 |
+ |
406 |
+ void |
407 |
+@@ -151,6 +185,7 @@ mapdc(DC *dc, Window win, unsigned int w |
408 |
+ |
409 |
+ void |
410 |
+ resizedc(DC *dc, unsigned int w, unsigned int h) { |
411 |
++ int screen = DefaultScreen(dc->dpy); |
412 |
+ if(dc->canvas) |
413 |
+ XFreePixmap(dc->dpy, dc->canvas); |
414 |
+ |
415 |
+@@ -158,18 +193,30 @@ resizedc(DC *dc, unsigned int w, unsigne |
416 |
+ DefaultDepth(dc->dpy, DefaultScreen(dc->dpy))); |
417 |
+ dc->w = w; |
418 |
+ dc->h = h; |
419 |
++ if(dc->font.xft_font && !(dc->xftdraw)) { |
420 |
++ dc->xftdraw = XftDrawCreate(dc->dpy, dc->canvas, DefaultVisual(dc->dpy,screen), DefaultColormap(dc->dpy,screen)); |
421 |
++ if(!(dc->xftdraw)) |
422 |
++ eprintf("error, cannot create xft drawable\n"); |
423 |
++ } |
424 |
++ |
425 |
+ } |
426 |
+ |
427 |
+ int |
428 |
+ textnw(DC *dc, const char *text, size_t len) { |
429 |
+- if(dc->font.set) { |
430 |
++ if(dc->font.xft_font) { |
431 |
++ XGlyphInfo gi; |
432 |
++ XftTextExtentsUtf8(dc->dpy, dc->font.xft_font, (const FcChar8*)text, len, &gi); |
433 |
++ return gi.width; |
434 |
++ } else if(dc->font.set) { |
435 |
+ XRectangle r; |
436 |
+ |
437 |
+ XmbTextExtents(dc->font.set, text, len, NULL, &r); |
438 |
+ return r.width; |
439 |
+- } |
440 |
+- return XTextWidth(dc->font.xfont, text, len); |
441 |
+-} |
442 |
++ } else { |
443 |
++ return XTextWidth(dc->font.xfont, text, len); |
444 |
++ } |
445 |
++ |
446 |
++ } |
447 |
+ |
448 |
+ int |
449 |
+ textw(DC *dc, const char *text) { |
450 |
+diff -rup dmenu-4.3.1/draw.h dmenu-xft/draw.h |
451 |
+--- dmenu-4.3.1/draw.h 2011-05-18 21:32:16.000000000 +0530 |
452 |
++++ dmenu-xft/draw.h 2011-05-20 03:01:58.000000000 +0530 |
453 |
+@@ -1,28 +1,34 @@ |
454 |
+ /* See LICENSE file for copyright and license details. */ |
455 |
+ |
456 |
+-#define FG(dc, col) ((col)[(dc)->invert ? ColBG : ColFG]) |
457 |
+-#define BG(dc, col) ((col)[(dc)->invert ? ColFG : ColBG]) |
458 |
+- |
459 |
+-enum { ColBG, ColFG, ColBorder, ColLast }; |
460 |
++#include <X11/Xft/Xft.h> |
461 |
+ |
462 |
+ typedef struct { |
463 |
+ int x, y, w, h; |
464 |
+- Bool invert; |
465 |
+ Display *dpy; |
466 |
+ GC gc; |
467 |
+ Pixmap canvas; |
468 |
++ XftDraw *xftdraw; |
469 |
+ struct { |
470 |
+ int ascent; |
471 |
+ int descent; |
472 |
+ int height; |
473 |
+ XFontSet set; |
474 |
+ XFontStruct *xfont; |
475 |
++ XftFont *xft_font; |
476 |
+ } font; |
477 |
+ } DC; /* draw context */ |
478 |
+ |
479 |
++typedef struct { |
480 |
++ unsigned long FG; |
481 |
++ XftColor FG_xft; |
482 |
++ unsigned long BG; |
483 |
++} ColorSet; |
484 |
++ |
485 |
++ |
486 |
+ void drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color); |
487 |
+-void drawtext(DC *dc, const char *text, unsigned long col[ColLast]); |
488 |
+-void drawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]); |
489 |
++void drawtext(DC *dc, const char *text, ColorSet *col); |
490 |
++void drawtextn(DC *dc, const char *text, size_t n, ColorSet *col); |
491 |
++void freecol(DC *dc, ColorSet *col); |
492 |
+ void eprintf(const char *fmt, ...); |
493 |
+ void freedc(DC *dc); |
494 |
+ unsigned long getcolor(DC *dc, const char *colstr); |
495 |
+@@ -32,3 +38,5 @@ void mapdc(DC *dc, Window win, unsigned |
496 |
+ void resizedc(DC *dc, unsigned int w, unsigned int h); |
497 |
+ int textnw(DC *dc, const char *text, size_t len); |
498 |
+ int textw(DC *dc, const char *text); |
499 |
++ColorSet *initcolor(DC *dc, const char *foreground, const char *background); |
500 |
++ |
501 |
|
502 |
diff --git a/x11-misc/dmenu/metadata.xml b/x11-misc/dmenu/metadata.xml |
503 |
new file mode 100644 |
504 |
index 0000000..32c2cb5 |
505 |
--- /dev/null |
506 |
+++ b/x11-misc/dmenu/metadata.xml |
507 |
@@ -0,0 +1,9 @@ |
508 |
+<?xml version="1.0" encoding="UTF-8"?> |
509 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
510 |
+<pkgmetadata> |
511 |
+<herd>no-herd</herd> |
512 |
+<maintainer> |
513 |
+<email>xmw@g.o</email> |
514 |
+<name>Michael Weber</name> |
515 |
+</maintainer> |
516 |
+</pkgmetadata> |