1 |
commit: 0e4d7e633f524fa24701b0cf89321f2d1ecb2a98 |
2 |
Author: Michael Weber <xmw <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jan 10 02:40:50 2012 +0000 |
4 |
Commit: Michael Weber <xmw <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jan 10 02:40:50 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/xmw.git;a=commit;h=0e4d7e63 |
7 |
|
8 |
x11-misc/xft: patched 4.4.1, version bump to 4.5 |
9 |
|
10 |
(Portage version: 2.1.10.41/git/Linux x86_64, signed Manifest commit with key 62EEF090) |
11 |
|
12 |
--- |
13 |
x11-misc/dmenu/ChangeLog | 9 +- |
14 |
x11-misc/dmenu/Manifest | 13 +- |
15 |
x11-misc/dmenu/dmenu-4.4.1-r2.ebuild | 48 ++++ |
16 |
x11-misc/dmenu/dmenu-4.5.ebuild | 45 +++ |
17 |
x11-misc/dmenu/files/dmenu-4.4.1-xft.patch | 405 ++++++++++++++++++++++++++++ |
18 |
5 files changed, 515 insertions(+), 5 deletions(-) |
19 |
|
20 |
diff --git a/x11-misc/dmenu/ChangeLog b/x11-misc/dmenu/ChangeLog |
21 |
index 3594f0a..17ca746 100644 |
22 |
--- a/x11-misc/dmenu/ChangeLog |
23 |
+++ b/x11-misc/dmenu/ChangeLog |
24 |
@@ -1,7 +1,14 @@ |
25 |
# ChangeLog for x11-misc/dmenu |
26 |
-# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2 |
27 |
+# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 |
28 |
# $Header: $ |
29 |
|
30 |
+*dmenu-4.5 (10 Jan 2012) |
31 |
+*dmenu-4.4.1-r2 (10 Jan 2012) |
32 |
+ |
33 |
+ 10 Jan 2012; Michael Weber <xmw@g.o> +dmenu-4.4.1-r2.ebuild, |
34 |
+ +files/dmenu-4.4.1-xft.patch, +dmenu-4.5.ebuild: |
35 |
+ xft patched 4.4.1, version bump to 4.5 |
36 |
+ |
37 |
*dmenu-4.3.1 (31 May 2011) |
38 |
|
39 |
31 May 2011; Michael Weber <xmw@g.o> +dmenu-4.3.1.ebuild, |
40 |
|
41 |
diff --git a/x11-misc/dmenu/Manifest b/x11-misc/dmenu/Manifest |
42 |
index b2f2437..9fbb9ed 100644 |
43 |
--- a/x11-misc/dmenu/Manifest |
44 |
+++ b/x11-misc/dmenu/Manifest |
45 |
@@ -2,14 +2,19 @@ |
46 |
Hash: SHA256 |
47 |
|
48 |
AUX dmenu-4.3.1-xft.patch 11711 RMD160 43c39e128d6fbe07e81945ef5567153d709fe2a4 SHA1 0f893f21406e4d292b0c1e9b96efe31957103bd6 SHA256 61ef78f8b6105828e4120cb3a15c994f92bbec8b909c7a34fa9fda24f7dd17e7 |
49 |
+AUX dmenu-4.4.1-xft.patch 12279 RMD160 d2b02e2f40ebdb00542dc2261f163f6ce731a1b5 SHA1 f5c9d9c956355379d225169c44fac81e8dc4c52f SHA256 6866e820481f1dc411f542f79240ea89e187f6e1394d62b69874fcc29f3ebe7f |
50 |
DIST dmenu-4.3.1.tar.gz 8905 RMD160 61675030c88c31bce88c6d2a2e408b28f622b68c SHA1 c22c468f9383ff485feacb9662571c4d1601aca3 SHA256 7da646228b52a2a5966b27190701e9514c08ee16ac538404b5dfa13b10b3c0ca |
51 |
+DIST dmenu-4.4.1.tar.gz 9318 RMD160 4a15486eaf19fdde93e763ec340001e5e74ac2a4 SHA1 42f8bb4b8bf72840cc343f0b3f31975a22350e5a SHA256 6d641645ab610d98d847b9a64500be7cc0e75bff5342534906936afa6ddb4550 |
52 |
+DIST dmenu-4.5.tar.gz 11543 RMD160 b771a84e0e9a8fbb29317c07fa77f92b64dcdc2f SHA1 70c1a13b950b7b0cb1bc35e30c6e861a78359953 SHA256 082cd698d82125ca0b3989006fb84ac4675c2a5585bf5bb8af0ea09cfb95a850 |
53 |
EBUILD dmenu-4.3.1.ebuild 1256 RMD160 9e1d2448873906c9ca449dff1443ffd8978235cd SHA1 7f20eea3ea0394cb26dd7fde942a31c32cbe6c65 SHA256 63e98a85ed550a57ca3216a969e209567b7dc53d445186a5338f217203ed723a |
54 |
-MISC ChangeLog 288 RMD160 e5d48ca2feecd9cfc201e090fec3821686dad480 SHA1 985d395d023bf3a8ebeaa9446e9a07936e5a2407 SHA256 96d1993dbba93014471ab60b0554446cb3c3023b63b4a21b0209f05c0e4e12b9 |
55 |
+EBUILD dmenu-4.4.1-r2.ebuild 1293 RMD160 6829e4ef5232a34a706b4abf0c1c42bfa0e6a9df SHA1 6c3cb743c4c9e7bd170d5f4e68765edcc239e485 SHA256 e53a101a670c9a99eed42f71db34f624f26bfac29e75b941bead00e7b83b9152 |
56 |
+EBUILD dmenu-4.5.ebuild 1150 RMD160 ba9ba9f5820dd59973b5dfcbbec297299ac9ceb7 SHA1 3d91b58bf8a1fd2f9586ee71b07c0a720084a5a4 SHA256 431a3a679873bc7da7bff660a1ec5ca0d6a70cdf5bf6bd06bab18c570d811198 |
57 |
+MISC ChangeLog 507 RMD160 b5142114c0ecfc63ef2e6764e28c0dbe09a1fd81 SHA1 1daea8c57b6b9001707791af630f8758573ec63a SHA256 d8488888731d361ef7135a1c2aa5ae5b1213b07ef8727ec1f16a706c075ea759 |
58 |
MISC metadata.xml 244 RMD160 ba31bc851ce5d8e007b223b4f799d84d4c6699d0 SHA1 2192e855054fb7016488afba3eda6d938fdf925d SHA256 1022f65be1952b5197408dfbf61543b61557601ce3a9f15acabeb3e9d84a0fbe |
59 |
-----BEGIN PGP SIGNATURE----- |
60 |
Version: GnuPG v2.0.17 (GNU/Linux) |
61 |
|
62 |
-iF4EAREIAAYFAk3kVXoACgkQknrdDGLu8JASHwD/VvMI0QKhOw5HwkJFGwZiPBb3 |
63 |
-GtKV7gP1zEwZ1vqAYjMA/2shEGPOyLqRNaTLsShI/gdfK9Xkun4LyQeDD3SClXyP |
64 |
-=rcB5 |
65 |
+iF4EAREIAAYFAk8LpTEACgkQknrdDGLu8JDxLwD/dkfEXcNzicvP64KmColPJZZm |
66 |
+TKplRSpeyEjSIUhfBsEA+wcr72OybJtgQwQ60EnhaDBpV2LaquZkBRSC9GA4BaT3 |
67 |
+=ydEL |
68 |
-----END PGP SIGNATURE----- |
69 |
|
70 |
diff --git a/x11-misc/dmenu/dmenu-4.4.1-r2.ebuild b/x11-misc/dmenu/dmenu-4.4.1-r2.ebuild |
71 |
new file mode 100644 |
72 |
index 0000000..d3e3aa2 |
73 |
--- /dev/null |
74 |
+++ b/x11-misc/dmenu/dmenu-4.4.1-r2.ebuild |
75 |
@@ -0,0 +1,48 @@ |
76 |
+# Copyright 1999-2012 Gentoo Foundation |
77 |
+# Distributed under the terms of the GNU General Public License v2 |
78 |
+# $Header: /var/cvsroot/gentoo-x86/x11-misc/dmenu/dmenu-4.4.1-r1.ebuild,v 1.2 2011/11/28 00:06:51 jer Exp $ |
79 |
+ |
80 |
+EAPI="4" |
81 |
+ |
82 |
+inherit eutils toolchain-funcs |
83 |
+ |
84 |
+DESCRIPTION="a generic, highly customizable, and efficient menu for the X Window System" |
85 |
+HOMEPAGE="http://www.suckless.org/programs/dmenu.html" |
86 |
+SRC_URI="http://dl.suckless.org/tools/${P}.tar.gz" |
87 |
+ |
88 |
+LICENSE="MIT" |
89 |
+SLOT="0" |
90 |
+KEYWORDS="~amd64 ~hppa ~ppc ~ppc64 ~x86 ~x86-fbsd" |
91 |
+IUSE="xft xinerama" |
92 |
+ |
93 |
+DEPEND="x11-libs/libX11 |
94 |
+ xinerama? ( x11-libs/libXinerama )" |
95 |
+RDEPEND="${DEPEND}" |
96 |
+ |
97 |
+src_prepare() { |
98 |
+ if use xft ; then |
99 |
+ epatch "${FILESDIR}/${P}-xft.patch" |
100 |
+ fi |
101 |
+ |
102 |
+ sed -i \ |
103 |
+ -e "s/CFLAGS = -ansi -pedantic -Wall -Os/CFLAGS += -ansi -pedantic -Wall/" \ |
104 |
+ -e "s/LDFLAGS = -s/LDFLAGS +=/" \ |
105 |
+ -e "s/XINERAMALIBS =/XINERAMALIBS ?=/" \ |
106 |
+ -e "s/XINERAMAFLAGS =/XINERAMAFLAGS ?=/" \ |
107 |
+ config.mk || die |
108 |
+ sed -i -e 's|lsx|dmenu_&|g' dmenu_run lsx.1 lsx.c || die |
109 |
+} |
110 |
+ |
111 |
+src_compile() { |
112 |
+ if use xinerama; then |
113 |
+ emake CC=$(tc-getCC) |
114 |
+ else |
115 |
+ emake CC=$(tc-getCC) XINERAMAFLAGS="" XINERAMALIBS="" |
116 |
+ fi |
117 |
+} |
118 |
+ |
119 |
+src_install() { |
120 |
+ emake DESTDIR="${D}" PREFIX="/usr" install |
121 |
+ mv "${D}"/usr/bin/{,dmenu_}lsx || die |
122 |
+ mv "${D}"/usr/share/man/man1/{,dmenu_}lsx.1 || die |
123 |
+} |
124 |
|
125 |
diff --git a/x11-misc/dmenu/dmenu-4.5.ebuild b/x11-misc/dmenu/dmenu-4.5.ebuild |
126 |
new file mode 100644 |
127 |
index 0000000..c59345e |
128 |
--- /dev/null |
129 |
+++ b/x11-misc/dmenu/dmenu-4.5.ebuild |
130 |
@@ -0,0 +1,45 @@ |
131 |
+# Copyright 1999-2012 Gentoo Foundation |
132 |
+# Distributed under the terms of the GNU General Public License v2 |
133 |
+# $Header: /var/cvsroot/gentoo-x86/x11-misc/dmenu/dmenu-4.4.1-r1.ebuild,v 1.2 2011/11/28 00:06:51 jer Exp $ |
134 |
+ |
135 |
+EAPI="4" |
136 |
+ |
137 |
+inherit eutils toolchain-funcs |
138 |
+ |
139 |
+DESCRIPTION="a generic, highly customizable, and efficient menu for the X Window System" |
140 |
+HOMEPAGE="http://www.suckless.org/programs/dmenu.html" |
141 |
+SRC_URI="http://dl.suckless.org/tools/${P}.tar.gz" |
142 |
+ |
143 |
+LICENSE="MIT" |
144 |
+SLOT="0" |
145 |
+KEYWORDS="~amd64 ~hppa ~ppc ~ppc64 ~x86 ~x86-fbsd" |
146 |
+IUSE="xinerama" |
147 |
+ |
148 |
+DEPEND="x11-libs/libX11 |
149 |
+ xinerama? ( x11-libs/libXinerama )" |
150 |
+RDEPEND="${DEPEND}" |
151 |
+ |
152 |
+src_prepare() { |
153 |
+ #if use xft ; then |
154 |
+ # epatch "${FILESDIR}/${PN}-4.4.1-xft.patch" |
155 |
+ #fi |
156 |
+ |
157 |
+ sed -i \ |
158 |
+ -e "s/CFLAGS = -ansi -pedantic -Wall -Os/CFLAGS += -ansi -pedantic -Wall/" \ |
159 |
+ -e "s/LDFLAGS = -s/LDFLAGS +=/" \ |
160 |
+ -e "s/XINERAMALIBS =/XINERAMALIBS ?=/" \ |
161 |
+ -e "s/XINERAMAFLAGS =/XINERAMAFLAGS ?=/" \ |
162 |
+ config.mk || die |
163 |
+} |
164 |
+ |
165 |
+src_compile() { |
166 |
+ if use xinerama; then |
167 |
+ emake CC=$(tc-getCC) |
168 |
+ else |
169 |
+ emake CC=$(tc-getCC) XINERAMAFLAGS="" XINERAMALIBS="" |
170 |
+ fi |
171 |
+} |
172 |
+ |
173 |
+src_install() { |
174 |
+ emake DESTDIR="${D}" PREFIX="/usr" install |
175 |
+} |
176 |
|
177 |
diff --git a/x11-misc/dmenu/files/dmenu-4.4.1-xft.patch b/x11-misc/dmenu/files/dmenu-4.4.1-xft.patch |
178 |
new file mode 100644 |
179 |
index 0000000..dc6f5c3 |
180 |
--- /dev/null |
181 |
+++ b/x11-misc/dmenu/files/dmenu-4.4.1-xft.patch |
182 |
@@ -0,0 +1,405 @@ |
183 |
+--- a/dmenu.c 2011-09-19 11:48:13.000000000 +0200 |
184 |
++++ b/dmenu.c 2011-12-31 00:48:16.000000000 +0200 |
185 |
+@@ -16,6 +16,7 @@ |
186 |
+ #define INRECT(x,y,rx,ry,rw,rh) ((x) >= (rx) && (x) < (rx)+(rw) && (y) >= (ry) && (y) < (ry)+(rh)) |
187 |
+ #define MIN(a,b) ((a) < (b) ? (a) : (b)) |
188 |
+ #define MAX(a,b) ((a) > (b) ? (a) : (b)) |
189 |
++#define DEFFONT "fixed" /* xft example: "Monospace-11" */ |
190 |
+ |
191 |
+ typedef struct Item Item; |
192 |
+ struct Item { |
193 |
+@@ -25,6 +26,7 @@ struct Item { |
194 |
+ |
195 |
+ static void appenditem(Item *item, Item **list, Item **last); |
196 |
+ static void calcoffsets(void); |
197 |
++static void cleanup(void); |
198 |
+ static char *cistrstr(const char *s, const char *sub); |
199 |
+ static void drawmenu(void); |
200 |
+ static void grabkeyboard(void); |
201 |
+@@ -49,10 +51,12 @@ static const char *normbgcolor = "#ccccc |
202 |
+ static const char *normfgcolor = "#000000"; |
203 |
+ static const char *selbgcolor = "#0066ff"; |
204 |
+ static const char *selfgcolor = "#ffffff"; |
205 |
+-static unsigned long normcol[ColLast]; |
206 |
+-static unsigned long selcol[ColLast]; |
207 |
++static ColorSet *normcol; |
208 |
++static ColorSet *selcol; |
209 |
+ static Atom utf8; |
210 |
+ static Bool topbar = True; |
211 |
++static Bool running = True; |
212 |
++static int ret = 0; |
213 |
+ static DC *dc; |
214 |
+ static Item *items = NULL; |
215 |
+ static Item *matches, *matchend; |
216 |
+@@ -102,7 +106,9 @@ main(int argc, char *argv[]) { |
217 |
+ usage(); |
218 |
+ |
219 |
+ dc = initdc(); |
220 |
+- initfont(dc, font); |
221 |
++ initfont(dc, font ? font : DEFFONT); |
222 |
++ normcol = initcolor(dc, normfgcolor, normbgcolor); |
223 |
++ selcol = initcolor(dc, selfgcolor, selbgcolor); |
224 |
+ |
225 |
+ if(fast) { |
226 |
+ grabkeyboard(); |
227 |
+@@ -115,7 +121,8 @@ main(int argc, char *argv[]) { |
228 |
+ setup(); |
229 |
+ run(); |
230 |
+ |
231 |
+- return EXIT_FAILURE; /* unreachable */ |
232 |
++ cleanup(); |
233 |
++ return ret; |
234 |
+ } |
235 |
+ |
236 |
+ void |
237 |
+@@ -158,6 +165,16 @@ cistrstr(const char *s, const char *sub) |
238 |
+ } |
239 |
+ |
240 |
+ void |
241 |
++cleanup(void) { |
242 |
++ Item *itm; |
243 |
++ freecol(dc, normcol); |
244 |
++ freecol(dc, selcol); |
245 |
++ XDestroyWindow(dc->dpy, win); |
246 |
++ XUngrabKeyboard(dc->dpy, CurrentTime); |
247 |
++ freedc(dc); |
248 |
++} |
249 |
++ |
250 |
++void |
251 |
+ drawmenu(void) { |
252 |
+ int curpos; |
253 |
+ Item *item; |
254 |
+@@ -165,7 +182,7 @@ drawmenu(void) { |
255 |
+ dc->x = 0; |
256 |
+ dc->y = 0; |
257 |
+ dc->h = bh; |
258 |
+- drawrect(dc, 0, 0, mw, mh, True, BG(dc, normcol)); |
259 |
++ drawrect(dc, 0, 0, mw, mh, True, normcol->BG); |
260 |
+ |
261 |
+ if(prompt) { |
262 |
+ dc->w = promptw; |
263 |
+@@ -175,7 +192,7 @@ drawmenu(void) { |
264 |
+ dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw; |
265 |
+ drawtext(dc, text, normcol); |
266 |
+ if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w) |
267 |
+- drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol)); |
268 |
++ drawrect(dc, curpos, 2, 1, dc->h - 4, True, normcol->FG); |
269 |
+ |
270 |
+ if(lines > 0) { |
271 |
+ dc->w = mw - dc->x; |
272 |
+@@ -301,7 +318,8 @@ keypress(XKeyEvent *ev) { |
273 |
+ sel = matchend; |
274 |
+ break; |
275 |
+ case XK_Escape: |
276 |
+- exit(EXIT_FAILURE); |
277 |
++ ret = EXIT_FAILURE; |
278 |
++ running = False; |
279 |
+ case XK_Home: |
280 |
+ if(sel == matches) { |
281 |
+ cursor = 0; |
282 |
+@@ -337,7 +355,8 @@ keypress(XKeyEvent *ev) { |
283 |
+ case XK_Return: |
284 |
+ case XK_KP_Enter: |
285 |
+ puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); |
286 |
+- exit(EXIT_SUCCESS); |
287 |
++ ret = EXIT_SUCCESS; |
288 |
++ running = False; |
289 |
+ case XK_Right: |
290 |
+ if(text[cursor] != '\0') { |
291 |
+ cursor = nextrune(+1); |
292 |
+@@ -449,7 +468,7 @@ void |
293 |
+ run(void) { |
294 |
+ XEvent ev; |
295 |
+ |
296 |
+- while(!XNextEvent(dc->dpy, &ev)) |
297 |
++ while(running && !XNextEvent(dc->dpy, &ev)) |
298 |
+ switch(ev.type) { |
299 |
+ case Expose: |
300 |
+ if(ev.xexpose.count == 0) |
301 |
+@@ -479,11 +498,6 @@ setup(void) { |
302 |
+ XineramaScreenInfo *info; |
303 |
+ #endif |
304 |
+ |
305 |
+- normcol[ColBG] = getcolor(dc, normbgcolor); |
306 |
+- normcol[ColFG] = getcolor(dc, normfgcolor); |
307 |
+- selcol[ColBG] = getcolor(dc, selbgcolor); |
308 |
+- selcol[ColFG] = getcolor(dc, selfgcolor); |
309 |
+- |
310 |
+ utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); |
311 |
+ |
312 |
+ /* menu geometry */ |
313 |
+--- a/draw.c 2011-09-19 11:48:13.000000000 +0200 |
314 |
++++ b/draw.c 2011-12-31 01:44:39.000000000 +0200 |
315 |
+@@ -9,9 +9,6 @@ |
316 |
+ |
317 |
+ #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
318 |
+ #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
319 |
+-#define DEFAULTFN "fixed" |
320 |
+- |
321 |
+-static Bool loadfont(DC *dc, const char *fontstr); |
322 |
+ |
323 |
+ void |
324 |
+ drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color) { |
325 |
+@@ -23,7 +20,7 @@ drawrect(DC *dc, int x, int y, unsigned |
326 |
+ } |
327 |
+ |
328 |
+ void |
329 |
+-drawtext(DC *dc, const char *text, unsigned long col[ColLast]) { |
330 |
++drawtext(DC *dc, const char *text, ColorSet *col) { |
331 |
+ char buf[BUFSIZ]; |
332 |
+ size_t mn, n = strlen(text); |
333 |
+ |
334 |
+@@ -35,19 +32,24 @@ drawtext(DC *dc, const char *text, unsig |
335 |
+ if(mn < n) |
336 |
+ for(n = MAX(mn-3, 0); n < mn; buf[n++] = '.'); |
337 |
+ |
338 |
+- drawrect(dc, 0, 0, dc->w, dc->h, True, BG(dc, col)); |
339 |
++ drawrect(dc, 0, 0, dc->w, dc->h, True, col->BG); |
340 |
+ drawtextn(dc, buf, mn, col); |
341 |
+ } |
342 |
+ |
343 |
+ void |
344 |
+-drawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]) { |
345 |
++drawtextn(DC *dc, const char *text, size_t n, ColorSet *col) { |
346 |
+ int x = dc->x + dc->font.height/2; |
347 |
+ int y = dc->y + dc->font.ascent+1; |
348 |
+ |
349 |
+- XSetForeground(dc->dpy, dc->gc, FG(dc, col)); |
350 |
+- if(dc->font.set) |
351 |
++ XSetForeground(dc->dpy, dc->gc, col->FG); |
352 |
++ if(dc->font.xft_font) { |
353 |
++ if (!dc->xftdraw) |
354 |
++ eprintf("error, xft drawable does not exist"); |
355 |
++ XftDrawStringUtf8(dc->xftdraw, &col->FG_xft, |
356 |
++ dc->font.xft_font, x, y, (unsigned char*)text, n); |
357 |
++ } else if(dc->font.set) { |
358 |
+ XmbDrawString(dc->dpy, dc->canvas, dc->font.set, dc->gc, x, y, text, n); |
359 |
+- else { |
360 |
++ } else { |
361 |
+ XSetFont(dc->dpy, dc->gc, dc->font.xfont->fid); |
362 |
+ XDrawString(dc->dpy, dc->canvas, dc->gc, x, y, text, n); |
363 |
+ } |
364 |
+@@ -69,16 +71,33 @@ eprintf(const char *fmt, ...) { |
365 |
+ } |
366 |
+ |
367 |
+ void |
368 |
++freecol(DC *dc, ColorSet *col) { |
369 |
++ if(col) { |
370 |
++ if(&col->FG_xft) |
371 |
++ XftColorFree(dc->dpy, DefaultVisual(dc->dpy, DefaultScreen(dc->dpy)), |
372 |
++ DefaultColormap(dc->dpy, DefaultScreen(dc->dpy)), &col->FG_xft); |
373 |
++ free(col); |
374 |
++ } |
375 |
++} |
376 |
++ |
377 |
++void |
378 |
+ freedc(DC *dc) { |
379 |
++ if(dc->font.xft_font) { |
380 |
++ XftFontClose(dc->dpy, dc->font.xft_font); |
381 |
++ XftDrawDestroy(dc->xftdraw); |
382 |
++ } |
383 |
+ if(dc->font.set) |
384 |
+ XFreeFontSet(dc->dpy, dc->font.set); |
385 |
+- if(dc->font.xfont) |
386 |
++ if(dc->font.xfont) |
387 |
+ XFreeFont(dc->dpy, dc->font.xfont); |
388 |
+- if(dc->canvas) |
389 |
++ if(dc->canvas) |
390 |
+ XFreePixmap(dc->dpy, dc->canvas); |
391 |
+- XFreeGC(dc->dpy, dc->gc); |
392 |
+- XCloseDisplay(dc->dpy); |
393 |
+- free(dc); |
394 |
++ if(dc->gc) |
395 |
++ XFreeGC(dc->dpy, dc->gc); |
396 |
++ if(dc->dpy) |
397 |
++ XCloseDisplay(dc->dpy); |
398 |
++ if(dc) |
399 |
++ free(dc); |
400 |
+ } |
401 |
+ |
402 |
+ unsigned long |
403 |
+@@ -91,6 +110,20 @@ getcolor(DC *dc, const char *colstr) { |
404 |
+ return color.pixel; |
405 |
+ } |
406 |
+ |
407 |
++ColorSet * |
408 |
++initcolor(DC *dc, const char * foreground, const char * background) { |
409 |
++ ColorSet * col = (ColorSet *)malloc(sizeof(ColorSet)); |
410 |
++ if(!col) |
411 |
++ eprintf("error, cannot allocate memory for color set"); |
412 |
++ col->BG = getcolor(dc, background); |
413 |
++ col->FG = getcolor(dc, foreground); |
414 |
++ if(dc->font.xft_font) |
415 |
++ if(!XftColorAllocName(dc->dpy, DefaultVisual(dc->dpy, DefaultScreen(dc->dpy)), |
416 |
++ DefaultColormap(dc->dpy, DefaultScreen(dc->dpy)), foreground, &col->FG_xft)) |
417 |
++ eprintf("error, cannot allocate xft font color '%s'\n", foreground); |
418 |
++ return col; |
419 |
++} |
420 |
++ |
421 |
+ DC * |
422 |
+ initdc(void) { |
423 |
+ DC *dc; |
424 |
+@@ -109,39 +142,33 @@ initdc(void) { |
425 |
+ |
426 |
+ void |
427 |
+ initfont(DC *dc, const char *fontstr) { |
428 |
+- if(!loadfont(dc, fontstr ? fontstr : DEFAULTFN)) { |
429 |
+- if(fontstr != NULL) |
430 |
+- fprintf(stderr, "cannot load font '%s'\n", fontstr); |
431 |
+- if(fontstr == NULL || !loadfont(dc, DEFAULTFN)) |
432 |
+- eprintf("cannot load font '%s'\n", DEFAULTFN); |
433 |
+- } |
434 |
+- dc->font.height = dc->font.ascent + dc->font.descent; |
435 |
+-} |
436 |
+- |
437 |
+-Bool |
438 |
+-loadfont(DC *dc, const char *fontstr) { |
439 |
+ char *def, **missing, **names; |
440 |
+ int i, n; |
441 |
+ XFontStruct **xfonts; |
442 |
+ |
443 |
+- if(!*fontstr) |
444 |
+- return False; |
445 |
+- if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) { |
446 |
++ missing = NULL; |
447 |
++ if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) { |
448 |
++ dc->font.ascent = dc->font.xfont->ascent; |
449 |
++ dc->font.descent = dc->font.xfont->descent; |
450 |
++ dc->font.width = dc->font.xfont->max_bounds.width; |
451 |
++ } else if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) { |
452 |
+ n = XFontsOfFontSet(dc->font.set, &xfonts, &names); |
453 |
+ for(i = 0; i < n; i++) { |
454 |
+ dc->font.ascent = MAX(dc->font.ascent, xfonts[i]->ascent); |
455 |
+ dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent); |
456 |
+ dc->font.width = MAX(dc->font.width, xfonts[i]->max_bounds.width); |
457 |
+ } |
458 |
+- } |
459 |
+- else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) { |
460 |
+- dc->font.ascent = dc->font.xfont->ascent; |
461 |
+- dc->font.descent = dc->font.xfont->descent; |
462 |
+- dc->font.width = dc->font.xfont->max_bounds.width; |
463 |
++ } else if((dc->font.xft_font = XftFontOpenName(dc->dpy, DefaultScreen(dc->dpy), fontstr))) { |
464 |
++ dc->font.ascent = dc->font.xft_font->ascent; |
465 |
++ dc->font.descent = dc->font.xft_font->descent; |
466 |
++ dc->font.width = dc->font.xft_font->max_advance_width; |
467 |
++ } else { |
468 |
++ eprintf("cannot load font '%s'\n", fontstr); |
469 |
+ } |
470 |
+ if(missing) |
471 |
+ XFreeStringList(missing); |
472 |
+- return dc->font.set || dc->font.xfont; |
473 |
++ dc->font.height = dc->font.ascent + dc->font.descent; |
474 |
++ return; |
475 |
+ } |
476 |
+ |
477 |
+ void |
478 |
+@@ -151,20 +178,29 @@ mapdc(DC *dc, Window win, unsigned int w |
479 |
+ |
480 |
+ void |
481 |
+ resizedc(DC *dc, unsigned int w, unsigned int h) { |
482 |
++ int screen = DefaultScreen(dc->dpy); |
483 |
+ if(dc->canvas) |
484 |
+ XFreePixmap(dc->dpy, dc->canvas); |
485 |
+ |
486 |
+ dc->w = w; |
487 |
+ dc->h = h; |
488 |
+ dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h, |
489 |
+- DefaultDepth(dc->dpy, DefaultScreen(dc->dpy))); |
490 |
++ DefaultDepth(dc->dpy, screen)); |
491 |
++ if(dc->font.xft_font && !(dc->xftdraw)) { |
492 |
++ dc->xftdraw = XftDrawCreate(dc->dpy, dc->canvas, DefaultVisual(dc->dpy,screen), DefaultColormap(dc->dpy,screen)); |
493 |
++ if(!(dc->xftdraw)) |
494 |
++ eprintf("error, cannot create xft drawable\n"); |
495 |
++ } |
496 |
+ } |
497 |
+ |
498 |
+ int |
499 |
+ textnw(DC *dc, const char *text, size_t len) { |
500 |
+- if(dc->font.set) { |
501 |
++ if(dc->font.xft_font) { |
502 |
++ XGlyphInfo gi; |
503 |
++ XftTextExtentsUtf8(dc->dpy, dc->font.xft_font, (const FcChar8*)text, len, &gi); |
504 |
++ return gi.width; |
505 |
++ } else if(dc->font.set) { |
506 |
+ XRectangle r; |
507 |
+- |
508 |
+ XmbTextExtents(dc->font.set, text, len, NULL, &r); |
509 |
+ return r.width; |
510 |
+ } |
511 |
+--- a/draw.h 2011-09-19 11:48:13.000000000 +0200 |
512 |
++++ b/draw.h 2011-12-31 00:28:01.000000000 +0200 |
513 |
+@@ -1,9 +1,6 @@ |
514 |
+ /* See LICENSE file for copyright and license details. */ |
515 |
+ |
516 |
+-#define FG(dc, col) ((col)[(dc)->invert ? ColBG : ColFG]) |
517 |
+-#define BG(dc, col) ((col)[(dc)->invert ? ColFG : ColBG]) |
518 |
+- |
519 |
+-enum { ColBG, ColFG, ColBorder, ColLast }; |
520 |
++#include <X11/Xft/Xft.h> |
521 |
+ |
522 |
+ typedef struct { |
523 |
+ int x, y, w, h; |
524 |
+@@ -11,6 +8,7 @@ typedef struct { |
525 |
+ Display *dpy; |
526 |
+ GC gc; |
527 |
+ Pixmap canvas; |
528 |
++ XftDraw *xftdraw; |
529 |
+ struct { |
530 |
+ int ascent; |
531 |
+ int descent; |
532 |
+@@ -18,15 +16,24 @@ typedef struct { |
533 |
+ int width; |
534 |
+ XFontSet set; |
535 |
+ XFontStruct *xfont; |
536 |
++ XftFont *xft_font; |
537 |
+ } font; |
538 |
+ } DC; /* draw context */ |
539 |
+ |
540 |
++typedef struct { |
541 |
++ unsigned long FG; |
542 |
++ XftColor FG_xft; |
543 |
++ unsigned long BG; |
544 |
++} ColorSet; |
545 |
++ |
546 |
+ void drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color); |
547 |
+-void drawtext(DC *dc, const char *text, unsigned long col[ColLast]); |
548 |
+-void drawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]); |
549 |
++void drawtext(DC *dc, const char *text, ColorSet *col); |
550 |
++void drawtextn(DC *dc, const char *text, size_t n, ColorSet *col); |
551 |
++void freecol(DC *dc, ColorSet *col); |
552 |
+ void eprintf(const char *fmt, ...); |
553 |
+ void freedc(DC *dc); |
554 |
+ unsigned long getcolor(DC *dc, const char *colstr); |
555 |
++ColorSet *initcolor(DC *dc, const char *foreground, const char *background); |
556 |
+ DC *initdc(void); |
557 |
+ void initfont(DC *dc, const char *fontstr); |
558 |
+ void mapdc(DC *dc, Window win, unsigned int w, unsigned int h); |
559 |
+--- a/dmenu.1 2011-09-19 11:48:13.000000000 +0200 |
560 |
++++ b/dmenu.1 2011-12-30 23:23:44.000000000 +0200 |
561 |
+@@ -55,7 +55,7 @@ |
562 |
+ defines the prompt to be displayed to the left of the input field. |
563 |
+ .TP |
564 |
+ .BI \-fn " font" |
565 |
+-defines the font or font set used. |
566 |
++defines the font or font set used. eg. "fixed" or "Monospace-12:normal" (an xft font) |
567 |
+ .TP |
568 |
+ .BI \-nb " color" |
569 |
+ defines the normal background color. |
570 |
+--- a/config.mk 2011-12-30 23:23:44.000000000 +0200 |
571 |
++++ b/config.mk 2011-12-30 23:23:44.000000000 +0200 |
572 |
+@@ -12,9 +12,13 @@ |
573 |
+ XINERAMALIBS = -lXinerama |
574 |
+ XINERAMAFLAGS = -DXINERAMA |
575 |
+ |
576 |
++# Xft, comment if you don't want it |
577 |
++XFTINC = -I/usr/include/freetype2 |
578 |
++XFTLIBS = -lXft -lXrender -lfreetype -lz -lfontconfig |
579 |
++ |
580 |
+ # includes and libs |
581 |
+-INCS = -I${X11INC} |
582 |
+-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} |
583 |
++INCS = -I${X11INC} ${XFTINC} |
584 |
++LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${XFTLIBS} |
585 |
+ |
586 |
+ # flags |
587 |
+ CPPFLAGS+= -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} |