diff options
-rw-r--r-- | config.h | 4 | ||||
-rw-r--r-- | config.mk | 4 | ||||
-rwxr-xr-x | dwm | bin | 43568 -> 41392 bytes | |||
-rw-r--r-- | dwm.c | 95 | ||||
-rw-r--r-- | dwm.o | bin | 63152 -> 62184 bytes |
5 files changed, 45 insertions, 58 deletions
@@ -1,8 +1,8 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ -static const char font[] = "-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*"; -//static const char font[] = "Sans 8"; +//static const char font[] = "-*-terminus-medium-r-*-*-10-*-*-*-*-*-*-*"; +static const char font[] = "DejaVu Sans:size=8"; #define NUMCOLORS 4 // need at least 3 static const char colors[NUMCOLORS][ColLast][8] = { @@ -15,8 +15,8 @@ XINERAMALIBS = -L${X11LIB} -lXinerama XINERAMAFLAGS = -DXINERAMA # includes and libs -INCS = -I. -I/usr/include -I${X11INC} #`pkg-config --cflags xft pango pangoxft` -LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} #`pkg-config --libs xft pango pangoxft` +INCS = -I. -I/usr/include -I${X11INC} -I/usr/include/freetype2 +LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} -lXft -lfontconfig # flags CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} Binary files differ@@ -37,9 +37,7 @@ #include <X11/Xlib.h> #include <X11/Xproto.h> #include <X11/Xutil.h> -//#include <X11/Xft/Xft.h> -//#include <pango/pango.h> -//#include <pango/pangoxft.h> +#include <X11/Xft/Xft.h> #ifdef XINERAMA #include <X11/extensions/Xinerama.h> #endif /* XINERAMA */ @@ -109,6 +107,7 @@ struct Client { typedef struct { int x, y, w, h; unsigned long colors[MAXCOLORS][ColLast]; + XftColor xftcolors[MAXCOLORS][ColLast]; Drawable drawable; Drawable tabdrawable; GC gc; @@ -116,8 +115,7 @@ typedef struct { int ascent; int descent; int height; - XFontSet set; - XFontStruct *xfont; + XftFont *xfont; } font; } DC; /* draw context */ @@ -212,6 +210,7 @@ static void focusin(XEvent *e); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); static unsigned long getcolor(const char *colstr); +static XftColor getcolorxft(const char *colstr); static Bool getrootptr(int *x, int *y); static long getstate(Window w); static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); @@ -544,10 +543,10 @@ cleanup(void) { for(m = mons; m; m = m->next) while(m->stack) unmanage(m->stack, False); - if(dc.font.set) + /*if(dc.font.set) XFreeFontSet(dpy, dc.font.set); else - XFreeFont(dpy, dc.font.xfont); + XFreeFont(dpy, dc.font.xfont);*/ XUngrabKey(dpy, AnyKey, AnyModifier, root); XFreePixmap(dpy, dc.drawable); XFreePixmap(dpy, dc.tabdrawable); @@ -994,7 +993,7 @@ drawcoloredtext(char *text) { void drawsquare(Bool filled, Bool empty, int col) { int x; - XSetForeground(dpy, dc.gc, dc.colors[col][ ColFG ]); + XSetForeground(dpy, dc.gc, dc.xftcolors[col][ ColFG ].pixel); x = (dc.font.ascent + dc.font.descent + 2) / 4; if(filled) XFillRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x+1, x+1); @@ -1004,12 +1003,12 @@ drawsquare(Bool filled, Bool empty, int col) { void -//drawtext(Drawable drawable, const char *text, unsigned long col[ColLast], Bool pad) { drawtext(Drawable drawable, const char *text, int col, Bool pad) { char buf[256]; int i, x, y, h, len, olen; + XftDraw *d; - XSetForeground(dpy, dc.gc, dc.colors[col][ColBG]); + XSetForeground(dpy, dc.gc, dc.xftcolors[col][ColBG].pixel); XFillRectangle(dpy, drawable, dc.gc, dc.x, dc.y, dc.w, dc.h); if(!text) return; @@ -1025,11 +1024,15 @@ drawtext(Drawable drawable, const char *text, int col, Bool pad) { memcpy(buf, text, len); if(len < olen) for(i = len; i && i > len - 3; buf[--i] = '.'); - XSetForeground(dpy, dc.gc, col[ColFG]); patched! + /*XSetForeground(dpy, dc.gc, dc.colors[col][ColFG]); if(dc.font.set) XmbDrawString(dpy, drawable, dc.font.set, dc.gc, x, y, buf, len); else - XDrawString(dpy, drawable, dc.gc, x, y, buf, len); + XDrawString(dpy, drawable, dc.gc, x, y, buf, len);*/ + d = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy,screen)); + + XftDrawStringUtf8(d, &dc.xftcolors[col][ColFG], dc.font.xfont, x, y, (XftChar8 *) buf, len); + XftDrawDestroy(d); } @@ -1078,7 +1081,7 @@ focus(Client *c) { detachstack(c); attachstack(c); grabbuttons(c, True); - XSetWindowBorder(dpy, c->win, dc.colors[1][ColBorder]); + XSetWindowBorder(dpy, c->win, dc.xftcolors[1][ColBorder].pixel); setfocus(c); } else @@ -1167,11 +1170,21 @@ unsigned long getcolor(const char *colstr) { Colormap cmap = DefaultColormap(dpy, screen); XColor color; - if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) - die("error, cannot allocate color '%s'\n", colstr); + + if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) + die("error, cannot allocate color '%s'\n", colstr); return color.pixel; } +XftColor +getcolorxft(const char *colstr) { + XftColor color; + + if(!XftColorAllocName(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), colstr, &color)) + die("error, cannot allocate color '%s'\n", colstr); + return color; +} + Bool getrootptr(int *x, int *y) { int di; @@ -1270,35 +1283,12 @@ incnmaster(const Arg *arg) { void initfont(const char *fontstr) { - char *def, **missing; - int n; + if(!(dc.font.xfont = XftFontOpenName(dpy, screen, fontstr)) + && !(dc.font.xfont = XftFontOpenName(dpy, screen, "fixed"))) + die("error, cannot load font: '%s'\n", fontstr); - dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); - if(missing) { - while(n--) - fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]); - XFreeStringList(missing); - } - if(dc.font.set) { - XFontStruct **xfonts; - char **font_names; - - dc.font.ascent = dc.font.descent = 0; - XExtentsOfFontSet(dc.font.set); - n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names); - while(n--) { - dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent); - dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent); - xfonts++; - } - } - else { - if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) - && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed"))) - die("error, cannot load font: '%s'\n", fontstr); - dc.font.ascent = dc.font.xfont->ascent; - dc.font.descent = dc.font.xfont->descent; - } + dc.font.ascent = dc.font.xfont->ascent; + dc.font.descent = dc.font.xfont->descent; dc.font.height = dc.font.ascent + dc.font.descent; } @@ -1380,7 +1370,7 @@ manage(Window w, XWindowAttributes *wa) { wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); - XSetWindowBorder(dpy, w, dc.colors[0][ColBorder]); + XSetWindowBorder(dpy, w, dc.xftcolors[0][ColBorder].pixel); configure(c); /* propagates border_width, if size doesn't change */ updatewindowtype(c); updatesizehints(c); @@ -1859,13 +1849,14 @@ setup(void) { dc.colors[i][ColBorder] = getcolor( colors[i][ColBorder] ); dc.colors[i][ColFG] = getcolor( colors[i][ColFG] ); dc.colors[i][ColBG] = getcolor( colors[i][ColBG] ); + dc.xftcolors[i][ColBorder] = getcolorxft( colors[i][ColBorder] ); + dc.xftcolors[i][ColFG] = getcolorxft( colors[i][ColFG] ); + dc.xftcolors[i][ColBG] = getcolorxft( colors[i][ColBG] ); } dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen)); dc.tabdrawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), th, DefaultDepth(dpy, screen)); dc.gc = XCreateGC(dpy, root, 0, NULL); XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); - if(!dc.font.set) - XSetFont(dpy, dc.gc, dc.font.xfont->fid); /* init bars */ updatebars(); updatestatus(); @@ -1935,13 +1926,9 @@ tagmon(const Arg *arg) { int textnw(const char *text, unsigned int len) { - XRectangle r; - - if(dc.font.set) { - XmbTextExtents(dc.font.set, text, len, NULL, &r); - return r.width; - } - return XTextWidth(dc.font.xfont, text, len); + XGlyphInfo ext; + XftTextExtentsUtf8(dpy, dc.font.xfont, (XftChar8 *) text, len, &ext); + return ext.xOff; } void @@ -2052,7 +2039,7 @@ unfocus(Client *c, Bool setfocus) { if(!c) return; grabbuttons(c, False); - XSetWindowBorder(dpy, c->win, dc.colors[0][ColBorder]); + XSetWindowBorder(dpy, c->win, dc.xftcolors[0][ColBorder].pixel); if(setfocus) XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); } Binary files differ |