Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-6.0-xft.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-6.0-xft.diff (8146B)
---
1 diff --git a/config.def.h b/config.def.h
2 index 77ff358..a355bf0 100644
3 --- a/config.def.h
4 +++ b/config.def.h
5 @@ -1,7 +1,7 @@
6 /* See LICENSE file for copyright and license details. */
7
8 /* appearance */
9 -static const char font[] = "-*-terminus-medium-r-*-*-16-*-*-…
10 +static const char font[] = "monospace-9";
11 static const char normbordercolor[] = "#444444";
12 static const char normbgcolor[] = "#222222";
13 static const char normfgcolor[] = "#bbbbbb";
14 diff --git a/config.mk b/config.mk
15 index 484554a..a09be79 100644
16 --- a/config.mk
17 +++ b/config.mk
18 @@ -15,8 +15,8 @@ XINERAMALIBS = -L${X11LIB} -lXinerama
19 XINERAMAFLAGS = -DXINERAMA
20
21 # includes and libs
22 -INCS = -I. -I/usr/include -I${X11INC}
23 -LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
24 +INCS = -I. -I/usr/include -I${X11INC} -I/usr/include/freetype2
25 +LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} -lfontconfig -l…
26
27 # flags
28 CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
29 diff --git a/dwm.c b/dwm.c
30 index 1d78655..9587e77 100644
31 --- a/dwm.c
32 +++ b/dwm.c
33 @@ -39,6 +39,7 @@
34 #ifdef XINERAMA
35 #include <X11/extensions/Xinerama.h>
36 #endif /* XINERAMA */
37 +#include <X11/Xft/Xft.h>
38
39 /* macros */
40 #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
41 @@ -99,16 +100,15 @@ struct Client {
42
43 typedef struct {
44 int x, y, w, h;
45 - unsigned long norm[ColLast];
46 - unsigned long sel[ColLast];
47 + XftColor norm[ColLast];
48 + XftColor sel[ColLast];
49 Drawable drawable;
50 GC gc;
51 struct {
52 int ascent;
53 int descent;
54 int height;
55 - XFontSet set;
56 - XFontStruct *xfont;
57 + XftFont *xfont;
58 } font;
59 } DC; /* draw context */
60
61 @@ -178,15 +178,15 @@ static void die(const char *errstr, ...);
62 static Monitor *dirtomon(int dir);
63 static void drawbar(Monitor *m);
64 static void drawbars(void);
65 -static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned l…
66 -static void drawtext(const char *text, unsigned long col[ColLast], Bool…
67 +static void drawsquare(Bool filled, Bool empty, Bool invert, XftColor c…
68 +static void drawtext(const char *text, XftColor col[ColLast], Bool inve…
69 static void enternotify(XEvent *e);
70 static void expose(XEvent *e);
71 static void focus(Client *c);
72 static void focusin(XEvent *e);
73 static void focusmon(const Arg *arg);
74 static void focusstack(const Arg *arg);
75 -static unsigned long getcolor(const char *colstr);
76 +static XftColor getcolor(const char *colstr);
77 static Bool getrootptr(int *x, int *y);
78 static long getstate(Window w);
79 static Bool gettextprop(Window w, Atom atom, char *text, unsigned int s…
80 @@ -485,10 +485,6 @@ cleanup(void) {
81 for(m = mons; m; m = m->next)
82 while(m->stack)
83 unmanage(m->stack, False);
84 - if(dc.font.set)
85 - XFreeFontSet(dpy, dc.font.set);
86 - else
87 - XFreeFont(dpy, dc.font.xfont);
88 XUngrabKey(dpy, AnyKey, AnyModifier, root);
89 XFreePixmap(dpy, dc.drawable);
90 XFreeGC(dpy, dc.gc);
91 @@ -719,7 +715,7 @@ void
92 drawbar(Monitor *m) {
93 int x;
94 unsigned int i, occ = 0, urg = 0;
95 - unsigned long *col;
96 + XftColor *col;
97 Client *c;
98
99 for(c = m->clients; c; c = c->next) {
100 @@ -774,10 +770,10 @@ drawbars(void) {
101 }
102
103 void
104 -drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColL…
105 +drawsquare(Bool filled, Bool empty, Bool invert, XftColor col[ColLast])…
106 int x;
107
108 - XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
109 + XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG].pixel);
110 x = (dc.font.ascent + dc.font.descent + 2) / 4;
111 if(filled)
112 XFillRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1,…
113 @@ -786,11 +782,12 @@ drawsquare(Bool filled, Bool empty, Bool invert, u…
114 }
115
116 void
117 -drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
118 +drawtext(const char *text, XftColor col[ColLast], Bool invert) {
119 char buf[256];
120 int i, x, y, h, len, olen;
121 + XftDraw *d;
122
123 - XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
124 + XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG].pixel);
125 XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
126 if(!text)
127 return;
128 @@ -805,11 +802,11 @@ drawtext(const char *text, unsigned long col[ColLa…
129 memcpy(buf, text, len);
130 if(len < olen)
131 for(i = len; i && i > len - 3; buf[--i] = '.');
132 - XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
133 - if(dc.font.set)
134 - XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, …
135 - else
136 - XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
137 +
138 + d = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen),…
139 +
140 + XftDrawStringUtf8(d, &col[invert ? ColBG : ColFG], dc.font.xfon…
141 + XftDrawDestroy(d);
142 }
143
144 void
145 @@ -855,7 +852,7 @@ focus(Client *c) {
146 detachstack(c);
147 attachstack(c);
148 grabbuttons(c, True);
149 - XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
150 + XSetWindowBorder(dpy, c->win, dc.sel[ColBorder].pixel);
151 setfocus(c);
152 }
153 else
154 @@ -926,14 +923,14 @@ getatomprop(Client *c, Atom prop) {
155 return atom;
156 }
157
158 -unsigned long
159 +XftColor
160 getcolor(const char *colstr) {
161 - Colormap cmap = DefaultColormap(dpy, screen);
162 - XColor color;
163 + XftColor color;
164
165 - if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
166 + if(!XftColorAllocName(dpy, DefaultVisual(dpy, screen), DefaultC…
167 die("error, cannot allocate color '%s'\n", colstr);
168 - return color.pixel;
169 +
170 + return color;
171 }
172
173 Bool
174 @@ -1034,35 +1031,13 @@ incnmaster(const Arg *arg) {
175
176 void
177 initfont(const char *fontstr) {
178 - char *def, **missing;
179 - int n;
180
181 - dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
182 - if(missing) {
183 - while(n--)
184 - fprintf(stderr, "dwm: missing fontset: %s\n", m…
185 - XFreeStringList(missing);
186 - }
187 - if(dc.font.set) {
188 - XFontStruct **xfonts;
189 - char **font_names;
190 -
191 - dc.font.ascent = dc.font.descent = 0;
192 - XExtentsOfFontSet(dc.font.set);
193 - n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
194 - while(n--) {
195 - dc.font.ascent = MAX(dc.font.ascent, (*xfonts)-…
196 - dc.font.descent = MAX(dc.font.descent,(*xfonts)…
197 - xfonts++;
198 - }
199 - }
200 - else {
201 - if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
202 - && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
203 - die("error, cannot load font: '%s'\n", fontstr);
204 - dc.font.ascent = dc.font.xfont->ascent;
205 - dc.font.descent = dc.font.xfont->descent;
206 - }
207 + if(!(dc.font.xfont = XftFontOpenName(dpy,screen,fontstr))
208 + && !(dc.font.xfont = XftFontOpenName(dpy,screen,"fixed")))
209 + die("error, cannot load font: '%s'\n", fontstr);
210 +
211 + dc.font.ascent = dc.font.xfont->ascent;
212 + dc.font.descent = dc.font.xfont->descent;
213 dc.font.height = dc.font.ascent + dc.font.descent;
214 }
215
216 @@ -1144,7 +1119,7 @@ manage(Window w, XWindowAttributes *wa) {
217
218 wc.border_width = c->bw;
219 XConfigureWindow(dpy, w, CWBorderWidth, &wc);
220 - XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
221 + XSetWindowBorder(dpy, w, dc.norm[ColBorder].pixel);
222 configure(c); /* propagates border_width, if size doesn't chang…
223 updatewindowtype(c);
224 updatesizehints(c);
225 @@ -1621,8 +1596,6 @@ setup(void) {
226 dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen…
227 dc.gc = XCreateGC(dpy, root, 0, NULL);
228 XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter…
229 - if(!dc.font.set)
230 - XSetFont(dpy, dc.gc, dc.font.xfont->fid);
231 /* init bars */
232 updatebars();
233 updatestatus();
234 @@ -1692,13 +1665,9 @@ tagmon(const Arg *arg) {
235
236 int
237 textnw(const char *text, unsigned int len) {
238 - XRectangle r;
239 -
240 - if(dc.font.set) {
241 - XmbTextExtents(dc.font.set, text, len, NULL, &r);
242 - return r.width;
243 - }
244 - return XTextWidth(dc.font.xfont, text, len);
245 + XGlyphInfo ext;
246 + XftTextExtentsUtf8(dpy, dc.font.xfont, (XftChar8 *) text, len, …
247 + return ext.xOff;
248 }
249
250 void
251 @@ -1776,7 +1745,7 @@ unfocus(Client *c, Bool setfocus) {
252 if(!c)
253 return;
254 grabbuttons(c, False);
255 - XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
256 + XSetWindowBorder(dpy, c->win, dc.norm[ColBorder].pixel);
257 if(setfocus)
258 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentT…
259 }
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.