aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2015-03-27 15:46:11 -0300
committerEduardo Pedroni <e.pedroni91@gmail.com>2015-03-27 15:46:11 -0300
commit97d06c59c907377e9d8b66e225581e9d08e2d2c8 (patch)
treed9474360a1da056c8d8216176bc2d2843a88066d
parenta43fadeeb0710a17f22744ae50ca6cd0c5b305da (diff)
About to start patching
-rw-r--r--config.h22
-rwxr-xr-xdwmbin39024 -> 39024 bytes
-rw-r--r--dwm-5.9-statuscolors.diff236
-rw-r--r--dwm-6.0-pango.diff294
-rw-r--r--dwm-6.0-pertag-tab-v2a.diff897
-rw-r--r--dwm-6.0-xft.diff229
-rw-r--r--dwm.obin57672 -> 57672 bytes
7 files changed, 1671 insertions, 7 deletions
diff --git a/config.h b/config.h
index d5b6062..63256c3 100644
--- a/config.h
+++ b/config.h
@@ -31,7 +31,7 @@ static int def_layouts[1 + LENGTH(tags)] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* rules */
static const Rule rules[] = {
/* class instance title tags mask isfloating monitor */
- { NULL, NULL, NULL, 0, True, -1 },
+ { NULL, NULL, NULL, 0, False, -1 },
};
/* layout(s) */
@@ -60,15 +60,23 @@ static const Layout layouts[] = {
/* commands */
static const char *dmenucmd[] = { "dmenu_recent_aliases", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[] = { "xterm", NULL };
+static const char *browsercmd[] = { "chromium", NULL };
+static const char *playercmd[] = { "deadbeef", NULL };
+static const char *wincmd[] = { "vboxsdl", "--startvm", "win7", NULL };
+static const char *editorcmd[] = { "gedit", NULL };
-static const char *lowervolume[] = { "amixer", "-q", "set", "Master", "2dB-", NULL };
-static const char *raisevolume[] = { "amixer", "-q", "set", "Master", "2dB+", NULL };
-static const char *mutevolume[] = { "amixer", "-q", "set", "Master", "toggle", NULL };
+static const char *lowervolumecmd[] = { "amixer", "-q", "set", "Master", "2dB-", NULL };
+static const char *raisevolumecmd[] = { "amixer", "-q", "set", "Master", "2dB+", NULL };
+static const char *mutevolumecmd[] = { "amixer", "-q", "set", "Master", "toggle", NULL };
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_d, spawn, {.v = dmenucmd } },
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
+ { MODKEY|ShiftMask, XK_n, spawn, {.v = browsercmd } },
+ { MODKEY|ShiftMask, XK_m, spawn, {.v = playercmd } },
+ { MODKEY|ShiftMask, XK_b, spawn, {.v = wincmd } },
+ { MODKEY|ShiftMask, XK_v, spawn, {.v = editorcmd } },
{ MODKEY, XK_b, togglebar, {0} },
@@ -105,9 +113,9 @@ static Key keys[] = {
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
- { 0, XF86XK_AudioRaiseVolume, spawn, {.v = raisevolume } },
- { 0, XF86XK_AudioLowerVolume, spawn, {.v = lowervolume } },
- { 0, XF86XK_AudioMute, spawn, {.v = mutevolume } },
+ { 0, XF86XK_AudioRaiseVolume, spawn, {.v = raisevolumecmd } },
+ { 0, XF86XK_AudioLowerVolume, spawn, {.v = lowervolumecmd } },
+ { 0, XF86XK_AudioMute, spawn, {.v = mutevolumecmd } },
{ MODKEY|ShiftMask, XK_q, killclient, {0} },
{ MODKEY|ShiftMask, XK_e, quit, {0} },
diff --git a/dwm b/dwm
index 9d70def..0d3553f 100755
--- a/dwm
+++ b/dwm
Binary files differ
diff --git a/dwm-5.9-statuscolors.diff b/dwm-5.9-statuscolors.diff
new file mode 100644
index 0000000..1c2c3b4
--- /dev/null
+++ b/dwm-5.9-statuscolors.diff
@@ -0,0 +1,236 @@
+diff -up dwm-5.9/config.def.h dwm-5.9-colors/config.def.h
+--- dwm-5.9/config.def.h 2011-07-10 16:24:25.000000000 -0400
++++ dwm-5.9-colors/config.def.h 2011-08-18 02:02:47.033830823 -0400
+@@ -1,13 +1,16 @@
+ /* See LICENSE file for copyright and license details. */
+
+ /* appearance */
++#define NUMCOLORS 4 // need at least 3
++static const char colors[NUMCOLORS][ColLast][8] = {
++ // border foreground background
++ { "#cccccc", "#000000", "#cccccc" }, // 0 = normal
++ { "#0066ff", "#ffffff", "#0066ff" }, // 1 = selected
++ { "#0066ff", "#0066ff", "#ffffff" }, // 2 = urgent/warning
++ { "#ff0000", "#ffffff", "#ff0000" }, // 3 = error
++ // add more here
++};
+ static const char font[] = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
+-static const char normbordercolor[] = "#cccccc";
+-static const char normbgcolor[] = "#cccccc";
+-static const char normfgcolor[] = "#000000";
+-static const char selbordercolor[] = "#0066ff";
+-static const char selbgcolor[] = "#0066ff";
+-static const char selfgcolor[] = "#ffffff";
+ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const unsigned int snap = 32; /* snap pixel */
+ static const Bool showbar = True; /* False means no bar */
+@@ -45,7 +48,7 @@ static const Layout layouts[] = {
+ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
+
+ /* commands */
+-static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
++static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", colors[0][ColBG], "-nf", colors[0][ColFG],"-sb", colors[1][ColBG], "-sf", colors[1][ColFG], NULL };
+ static const char *termcmd[] = { "uxterm", NULL };
+
+ static Key keys[] = {
+Only in dwm-5.9: config.h
+Only in dwm-5.9: dwm
+diff -up dwm-5.9/dwm.c dwm-5.9-colors/dwm.c
+--- dwm-5.9/dwm.c 2011-07-10 16:24:25.000000000 -0400
++++ dwm-5.9-colors/dwm.c 2011-08-18 02:07:20.788935100 -0400
+@@ -48,6 +48,7 @@
+ #define LENGTH(X) (sizeof X / sizeof X[0])
+ #define MAX(A, B) ((A) > (B) ? (A) : (B))
+ #define MIN(A, B) ((A) < (B) ? (A) : (B))
++#define MAXCOLORS 8
+ #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
+ #define WIDTH(X) ((X)->w + 2 * (X)->bw)
+ #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
+@@ -97,9 +98,8 @@ struct Client {
+
+ typedef struct {
+ int x, y, w, h;
+- unsigned long norm[ColLast];
+- unsigned long sel[ColLast];
+- Drawable drawable;
++ unsigned long colors[MAXCOLORS][ColLast];
++ Drawable drawable;
+ GC gc;
+ struct {
+ int ascent;
+@@ -175,8 +175,9 @@ static void die(const char *errstr, ...)
+ static Monitor *dirtomon(int dir);
+ static void drawbar(Monitor *m);
+ static void drawbars(void);
+-static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
+-static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
++static void drawcoloredtext(char *text);
++static void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
++static void drawtext(const char *text, unsigned long col[ColLast], Bool pad);
+ static void enternotify(XEvent *e);
+ static void expose(XEvent *e);
+ static void focus(Client *c);
+@@ -736,14 +737,13 @@ drawbar(Monitor *m) {
+ dc.x = 0;
+ for(i = 0; i < LENGTH(tags); i++) {
+ dc.w = TEXTW(tags[i]);
+- col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
+- drawtext(tags[i], col, urg & 1 << i);
+- drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+- occ & 1 << i, urg & 1 << i, col);
++ col = dc.colors[ (m->tagset[m->seltags] & 1 << i ? 1:(urg & 1 << i ? 2:0))];
++ drawtext(tags[i], col, True);
++ drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i, occ & 1 << i, col);
+ dc.x += dc.w;
+ }
+ dc.w = blw = TEXTW(m->ltsymbol);
+- drawtext(m->ltsymbol, dc.norm, False);
++ drawtext(m->ltsymbol, dc.colors[0], True);
+ dc.x += dc.w;
+ x = dc.x;
+ if(m == selmon) { /* status is only drawn on selected monitor */
+@@ -753,19 +753,19 @@ drawbar(Monitor *m) {
+ dc.x = x;
+ dc.w = m->ww - x;
+ }
+- drawtext(stext, dc.norm, False);
++ drawcoloredtext(stext);
+ }
+ else
+ dc.x = m->ww;
+ if((dc.w = dc.x - x) > bh) {
+ dc.x = x;
+ if(m->sel) {
+- col = m == selmon ? dc.sel : dc.norm;
+- drawtext(m->sel->name, col, False);
+- drawsquare(m->sel->isfixed, m->sel->isfloating, False, col);
++ col = m == selmon ? dc.colors[1] : dc.colors[0];
++ drawtext(m->sel->name, col, True);
++ drawsquare(m->sel->isfixed, m->sel->isfloating, col);
+ }
+ else
+- drawtext(NULL, dc.norm, False);
++ drawtext(NULL, dc.colors[0], False);
+ }
+ XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
+ XSync(dpy, False);
+@@ -780,10 +780,39 @@ drawbars(void) {
+ }
+
+ void
+-drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
+- int x;
++drawcoloredtext(char *text) {
++ Bool first=True;
++ char *buf = text, *ptr = buf, c = 1;
++ unsigned long *col = dc.colors[0];
++ int i, ox = dc.x;
++
++ while( *ptr ) {
++ for( i = 0; *ptr < 0 || *ptr > NUMCOLORS; i++, ptr++);
++ if( !*ptr ) break;
++ c=*ptr;
++ *ptr=0;
++ if( i ) {
++ dc.w = selmon->ww - dc.x;
++ drawtext(buf, col, first);
++ dc.x += textnw(buf, i) + textnw(&c,1);
++ if( first ) dc.x += ( dc.font.ascent + dc.font.descent ) / 2;
++ first = False;
++ } else if( first ) {
++ ox = dc.x += textnw(&c,1);
++ }
++ *ptr = c;
++ col = dc.colors[ c-1 ];
++ buf = ++ptr;
++ }
++ if( !first ) dc.x-=(dc.font.ascent+dc.font.descent)/2;
++ drawtext(buf, col, True);
++ dc.x = ox;
++}
+
+- XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
++void
++drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) {
++ int x;
++ XSetForeground(dpy, dc.gc, col[ ColFG ]);
+ 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);
+@@ -792,17 +821,17 @@ drawsquare(Bool filled, Bool empty, Bool
+ }
+
+ void
+-drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
++drawtext(const char *text, unsigned long col[ColLast], Bool pad) {
+ char buf[256];
+ int i, x, y, h, len, olen;
+
+- XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
++ XSetForeground(dpy, dc.gc, col[ ColBG ]);
+ XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
+ if(!text)
+ return;
+ olen = strlen(text);
+- h = dc.font.ascent + dc.font.descent;
+- y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
++ h = pad ? (dc.font.ascent + dc.font.descent) : 0;
++ y = dc.y + ((dc.h + dc.font.ascent - dc.font.descent) / 2);
+ x = dc.x + (h / 2);
+ /* shorten text if necessary */
+ for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
+@@ -811,7 +840,7 @@ drawtext(const char *text, unsigned long
+ memcpy(buf, text, len);
+ if(len < olen)
+ for(i = len; i && i > len - 3; buf[--i] = '.');
+- XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
++ XSetForeground(dpy, dc.gc, col[ ColFG ]);
+ if(dc.font.set)
+ XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
+ else
+@@ -861,7 +890,7 @@ focus(Client *c) {
+ detachstack(c);
+ attachstack(c);
+ grabbuttons(c, True);
+- XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
++ XSetWindowBorder(dpy, c->win, dc.colors[1][ColBorder]);
+ setfocus(c);
+ }
+ else
+@@ -1137,7 +1166,7 @@ manage(Window w, XWindowAttributes *wa)
+ }
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+- XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
++ XSetWindowBorder(dpy, w, dc.colors[0][ColBorder]);
+ configure(c); /* propagates border_width, if size doesn't change */
+ updatesizehints(c);
+ updatewmhints(c);
+@@ -1550,12 +1579,11 @@ setup(void) {
+ cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
+ cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
+ /* init appearance */
+- dc.norm[ColBorder] = getcolor(normbordercolor);
+- dc.norm[ColBG] = getcolor(normbgcolor);
+- dc.norm[ColFG] = getcolor(normfgcolor);
+- dc.sel[ColBorder] = getcolor(selbordercolor);
+- dc.sel[ColBG] = getcolor(selbgcolor);
+- dc.sel[ColFG] = getcolor(selfgcolor);
++ for(int i=0; i<NUMCOLORS; i++) {
++ 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.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
+ dc.gc = XCreateGC(dpy, root, 0, NULL);
+ XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
+@@ -1716,7 +1744,7 @@ unfocus(Client *c, Bool setfocus) {
+ if(!c)
+ return;
+ grabbuttons(c, False);
+- XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
++ XSetWindowBorder(dpy, c->win, dc.colors[0][ColBorder]);
+ if(setfocus)
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ }
+Only in dwm-5.9: dwm.o
diff --git a/dwm-6.0-pango.diff b/dwm-6.0-pango.diff
new file mode 100644
index 0000000..e463f7b
--- /dev/null
+++ b/dwm-6.0-pango.diff
@@ -0,0 +1,294 @@
+diff --git a/config.def.h b/config.def.h
+index 77ff358..3bee2e7 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -1,7 +1,7 @@
+ /* See LICENSE file for copyright and license details. */
+
+ /* appearance */
+-static const char font[] = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
++static const char font[] = "Sans 8";
+ static const char normbordercolor[] = "#444444";
+ static const char normbgcolor[] = "#222222";
+ static const char normfgcolor[] = "#bbbbbb";
+@@ -12,6 +12,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const unsigned int snap = 32; /* snap pixel */
+ static const Bool showbar = True; /* False means no bar */
+ static const Bool topbar = True; /* False means bottom bar */
++static const Bool statusmarkup = True; /* True means use pango markup in status message */
+
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+diff --git a/config.mk b/config.mk
+index 484554a..cdfb642 100644
+--- a/config.mk
++++ b/config.mk
+@@ -15,8 +15,8 @@ XINERAMALIBS = -L${X11LIB} -lXinerama
+ XINERAMAFLAGS = -DXINERAMA
+
+ # includes and libs
+-INCS = -I. -I/usr/include -I${X11INC}
+-LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
++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`
+
+ # flags
+ CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+diff --git a/dwm.c b/dwm.c
+index 1d78655..8fae3ba 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -36,6 +36,9 @@
+ #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>
+ #ifdef XINERAMA
+ #include <X11/extensions/Xinerama.h>
+ #endif /* XINERAMA */
+@@ -47,8 +50,12 @@
+ * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
+ #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+ #define LENGTH(X) (sizeof X / sizeof X[0])
++#ifndef MAX
+ #define MAX(A, B) ((A) > (B) ? (A) : (B))
++#endif
++#ifndef MIN
+ #define MIN(A, B) ((A) < (B) ? (A) : (B))
++#endif
+ #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
+ #define WIDTH(X) ((X)->w + 2 * (X)->bw)
+ #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
+@@ -104,11 +111,15 @@ typedef struct {
+ Drawable drawable;
+ GC gc;
+ struct {
++ XftColor norm[ColLast];
++ XftColor sel[ColLast];
++ XftDraw *drawable;
++ } xft;
++ struct {
+ int ascent;
+ int descent;
+ int height;
+- XFontSet set;
+- XFontStruct *xfont;
++ PangoLayout *layout;
+ } font;
+ } DC; /* draw context */
+
+@@ -186,7 +197,7 @@ static void focus(Client *c);
+ 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 unsigned long getcolor(const char *colstr, XftColor *color);
+ static Bool getrootptr(int *x, int *y);
+ static long getstate(Window w);
+ static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
+@@ -254,7 +265,7 @@ static void zoom(const Arg *arg);
+
+ /* variables */
+ static const char broken[] = "broken";
+-static char stext[256];
++static char stext[512];
+ static int screen;
+ static int sw, sh; /* X display screen geometry width, height */
+ static int bh, blw = 0; /* bar geometry */
+@@ -479,18 +490,21 @@ cleanup(void) {
+ Arg a = {.ui = ~0};
+ Layout foo = { "", NULL };
+ Monitor *m;
++ int i;
+
+ view(&a);
+ selmon->lt[selmon->sellt] = &foo;
+ for(m = mons; m; m = m->next)
+ while(m->stack)
+ unmanage(m->stack, False);
+- if(dc.font.set)
+- XFreeFontSet(dpy, dc.font.set);
+- else
+- XFreeFont(dpy, dc.font.xfont);
+ XUngrabKey(dpy, AnyKey, AnyModifier, root);
+ XFreePixmap(dpy, dc.drawable);
++ for(i = ColBorder; i < ColLast; i++) {
++ XftColorFree(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), dc.xft.norm + i);
++ XftColorFree(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), dc.xft.sel + i);
++ }
++ XftDrawDestroy(dc.xft.drawable);
++ g_object_unref(dc.font.layout);
+ XFreeGC(dpy, dc.gc);
+ XFreeCursor(dpy, cursor[CurNormal]);
+ XFreeCursor(dpy, cursor[CurResize]);
+@@ -581,6 +595,7 @@ configurenotify(XEvent *e) {
+ if(dc.drawable != 0)
+ XFreePixmap(dpy, dc.drawable);
+ dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
++ XftDrawChange(dc.xft.drawable, dc.drawable);
+ updatebars();
+ for(m = mons; m; m = m->next)
+ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
+@@ -787,7 +802,7 @@ drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
+
+ void
+ drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
+- char buf[256];
++ char buf[512];
+ int i, x, y, h, len, olen;
+
+ XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
+@@ -796,20 +811,25 @@ drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
+ return;
+ olen = strlen(text);
+ h = dc.font.ascent + dc.font.descent;
+- y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
++ y = dc.y + (dc.h / 2) - (h / 2);
+ x = dc.x + (h / 2);
+- /* shorten text if necessary */
++ /* shorten text if necessary (this could wreak havoc with pango markup but fortunately
++ dc.w is adjusted to the width of the status text and not the other way around) */
+ for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
+ if(!len)
+ return;
+ memcpy(buf, text, len);
+ if(len < olen)
+ for(i = len; i && i > len - 3; buf[--i] = '.');
+- XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
+- if(dc.font.set)
+- XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
++ if(text == stext && statusmarkup)
++ pango_layout_set_markup(dc.font.layout, buf, len);
+ else
+- XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
++ pango_layout_set_text(dc.font.layout, buf, len);
++ pango_xft_render_layout(dc.xft.drawable,
++ (col == dc.norm ? dc.xft.norm : dc.xft.sel) + (invert ? ColBG : ColFG),
++ dc.font.layout, x * PANGO_SCALE, y * PANGO_SCALE);
++ if(text == stext && statusmarkup) /* clear markup attributes */
++ pango_layout_set_attributes(dc.font.layout, NULL);
+ }
+
+ void
+@@ -927,13 +947,13 @@ getatomprop(Client *c, Atom prop) {
+ }
+
+ unsigned long
+-getcolor(const char *colstr) {
++getcolor(const char *colstr, XftColor *color) {
+ Colormap cmap = DefaultColormap(dpy, screen);
+- XColor color;
++ Visual *vis = DefaultVisual(dpy, screen);
+
+- if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
++ if(!XftColorAllocName(dpy, vis, cmap, colstr, color))
+ die("error, cannot allocate color '%s'\n", colstr);
+- return color.pixel;
++ return color->pixel;
+ }
+
+ Bool
+@@ -1034,36 +1054,24 @@ incnmaster(const Arg *arg) {
+
+ void
+ initfont(const char *fontstr) {
+- char *def, **missing;
+- int n;
+-
+- 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;
+- }
++ PangoFontMap *fontmap;
++ PangoContext *context;
++ PangoFontDescription *desc;
++ PangoFontMetrics *metrics;
++
++ fontmap = pango_xft_get_font_map(dpy, screen);
++ context = pango_font_map_create_context(fontmap);
++ desc = pango_font_description_from_string(fontstr);
++ dc.font.layout = pango_layout_new(context);
++ pango_layout_set_font_description(dc.font.layout, desc);
++
++ metrics = pango_context_get_metrics(context, desc, NULL);
++ dc.font.ascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE;
++ dc.font.descent = pango_font_metrics_get_descent(metrics) / PANGO_SCALE;
+ dc.font.height = dc.font.ascent + dc.font.descent;
++
++ pango_font_metrics_unref(metrics);
++ g_object_unref(context);
+ }
+
+ #ifdef XINERAMA
+@@ -1612,17 +1620,16 @@ setup(void) {
+ cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
+ cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
+ /* init appearance */
+- dc.norm[ColBorder] = getcolor(normbordercolor);
+- dc.norm[ColBG] = getcolor(normbgcolor);
+- dc.norm[ColFG] = getcolor(normfgcolor);
+- dc.sel[ColBorder] = getcolor(selbordercolor);
+- dc.sel[ColBG] = getcolor(selbgcolor);
+- dc.sel[ColFG] = getcolor(selfgcolor);
++ dc.norm[ColBorder] = getcolor(normbordercolor, dc.xft.norm + ColBorder);
++ dc.norm[ColBG] = getcolor(normbgcolor, dc.xft.norm + ColBG);
++ dc.norm[ColFG] = getcolor(normfgcolor, dc.xft.norm + ColFG);
++ dc.sel[ColBorder] = getcolor(selbordercolor, dc.xft.sel + ColBorder);
++ dc.sel[ColBG] = getcolor(selbgcolor, dc.xft.sel + ColBG);
++ dc.sel[ColFG] = getcolor(selfgcolor, dc.xft.sel + ColFG);
+ dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
++ dc.xft.drawable = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(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();
+@@ -1692,13 +1699,15 @@ 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);
++ PangoRectangle r;
++ if(text == stext && statusmarkup)
++ pango_layout_set_markup(dc.font.layout, text, len);
++ else
++ pango_layout_set_text(dc.font.layout, text, len);
++ pango_layout_get_extents(dc.font.layout, 0, &r);
++ if(text == stext && statusmarkup) /* clear markup attributes */
++ pango_layout_set_attributes(dc.font.layout, NULL);
++ return r.width / PANGO_SCALE;
+ }
+
+ void
diff --git a/dwm-6.0-pertag-tab-v2a.diff b/dwm-6.0-pertag-tab-v2a.diff
new file mode 100644
index 0000000..b47c4b3
--- /dev/null
+++ b/dwm-6.0-pertag-tab-v2a.diff
@@ -0,0 +1,897 @@
+diff --git a/config.def.h b/config.def.h
+index 77ff358..9ca435c 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -12,10 +12,22 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const unsigned int snap = 32; /* snap pixel */
+ static const Bool showbar = True; /* False means no bar */
+ static const Bool topbar = True; /* False means bottom bar */
++/* Display modes of the tab bar: never shown, always shown, shown only in */
++/* monocle mode in presence of several windows. */
++/* Modes after showtab_nmodes are disabled */
++enum showtab_modes { showtab_never, showtab_auto, showtab_nmodes, showtab_always};
++static const int showtab = showtab_auto; /* Default tab bar show mode */
++static const Bool toptab = False; /* False means bottom tab bar */
++
+
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+
++/* default layout per tags */
++/* The first element is for all-tag view, following i-th element corresponds to */
++/* tags[i]. Layout is referred using the layouts array index.*/
++static int def_layouts[1 + LENGTH(tags)] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
++
+ static const Rule rules[] = {
+ /* class instance title tags mask isfloating monitor */
+ { "Gimp", NULL, NULL, 0, True, -1 },
+@@ -25,7 +37,7 @@ static const Rule rules[] = {
+ /* layout(s) */
+ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
+ static const int nmaster = 1; /* number of clients in master area */
+-static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
++static const Bool resizehints = False; /* True means respect size hints in tiled resizals */
+
+ static const Layout layouts[] = {
+ /* symbol arrange function */
+@@ -54,6 +66,7 @@ static Key keys[] = {
+ { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+ { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
+ { MODKEY, XK_b, togglebar, {0} },
++ { MODKEY, XK_w, tabmode, {-1} },
+ { MODKEY, XK_j, focusstack, {.i = +1 } },
+ { MODKEY, XK_k, focusstack, {.i = -1 } },
+ { MODKEY, XK_i, incnmaster, {.i = +1 } },
+@@ -101,5 +114,6 @@ static Button buttons[] = {
+ { ClkTagBar, 0, Button3, toggleview, {0} },
+ { ClkTagBar, MODKEY, Button1, tag, {0} },
+ { ClkTagBar, MODKEY, Button3, toggletag, {0} },
++ { ClkTabBar, 0, Button1, focuswin, {0} },
+ };
+
+diff --git a/dwm.1 b/dwm.1
+index 5268a06..19b4f1d 100644
+--- a/dwm.1
++++ b/dwm.1
+@@ -19,14 +19,22 @@ layout applied.
+ Windows are grouped by tags. Each window can be tagged with one or multiple
+ tags. Selecting certain tags displays all windows with these tags.
+ .P
+-Each screen contains a small status bar which displays all available tags, the
+-layout, the title of the focused window, and the text read from the root window
+-name property, if the screen is focused. A floating window is indicated with an
+-empty square and a maximised floating window is indicated with a filled square
+-before the windows title. The selected tags are indicated with a different
+-color. The tags of the focused window are indicated with a filled square in the
+-top left corner. The tags which are applied to one or more windows are
+-indicated with an empty square in the top left corner.
++Each screen contains two small status bars.
++.P
++One bar displays all available tags, the layout, the title of the focused
++window, and the text read from the root window name property, if the screen is
++focused. A floating window is indicated with an empty square and a maximised
++floating window is indicated with a filled square before the windows title. The
++selected tags are indicated with a different color. The tags of the focused
++window are indicated with a filled square in the top left corner. The tags
++which are applied to one or more windows are indicated with an empty square in
++the top left corner.
++.P
++Another bar contains a tab for each window of the current view and allows
++navigation between windows, especially in the monocle mode. The different
++display modes of this bar are described under the Mod1\-w Keybord command
++section. When a single tag is selected, that tag is indicated in the left corner
++of the tab bar.
+ .P
+ dwm draws a small border around windows to indicate the focus state.
+ .SH OPTIONS
+@@ -43,7 +51,8 @@ command.
+ .TP
+ .B Button1
+ click on a tag label to display all windows with that tag, click on the layout
+-label toggles between tiled and floating layout.
++label toggles between tiled and floating layout, click on a window name in the
++tab bar brings focus to that window.
+ .TP
+ .B Button3
+ click on a tag label adds/removes all windows with that tag to/from the view.
+@@ -104,6 +113,12 @@ Increase master area size.
+ .B Mod1\-h
+ Decrease master area size.
+ .TP
++.B Mod1\-w
++Cycle over the tab bar display modes: never displayed, always displayed,
++displayed only in monocle mode when the view contains than one window (auto
++mode). Some display modes can be disabled in the configuration, config.h. In
++the default configuration only "never" and "auto" display modes are enabled.
++.TP
+ .B Mod1\-Return
+ Zooms/cycles focused window to/from master area (tiled layouts only).
+ .TP
+diff --git a/dwm.c b/dwm.c
+index 1d78655..6c9bc16 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -44,7 +44,7 @@
+ #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
+ #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
+ #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
+- * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
++ * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
+ #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+ #define LENGTH(X) (sizeof X / sizeof X[0])
+ #define MAX(A, B) ((A) > (B) ? (A) : (B))
+@@ -62,7 +62,7 @@ enum { NetSupported, NetWMName, NetWMState,
+ NetWMFullscreen, NetActiveWindow, NetWMWindowType,
+ NetWMWindowTypeDialog, NetLast }; /* EWMH atoms */
+ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
+-enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
++enum { ClkTagBar, ClkTabBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
+ ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
+
+ typedef union {
+@@ -102,6 +102,7 @@ typedef struct {
+ unsigned long norm[ColLast];
+ unsigned long sel[ColLast];
+ Drawable drawable;
++ Drawable tabdrawable;
+ GC gc;
+ struct {
+ int ascent;
+@@ -124,25 +125,36 @@ typedef struct {
+ void (*arrange)(Monitor *);
+ } Layout;
+
++typedef struct Pertag Pertag;
++
++#define MAXTABS 50
++
+ struct Monitor {
+ char ltsymbol[16];
+ float mfact;
+ int nmaster;
+ int num;
+ int by; /* bar geometry */
++ int ty; /* tab bar geometry */
+ int mx, my, mw, mh; /* screen size */
+ int wx, wy, ww, wh; /* window area */
+ unsigned int seltags;
+ unsigned int sellt;
+ unsigned int tagset[2];
+ Bool showbar;
++ Bool showtab;
+ Bool topbar;
++ Bool toptab;
+ Client *clients;
+ Client *sel;
+ Client *stack;
+ Monitor *next;
+ Window barwin;
++ Window tabwin;
++ int ntabs;
++ int tab_widths[MAXTABS];
+ const Layout *lt[2];
++ Pertag *pertag;
+ };
+
+ typedef struct {
+@@ -178,11 +190,15 @@ static void die(const char *errstr, ...);
+ static Monitor *dirtomon(int dir);
+ static void drawbar(Monitor *m);
+ static void drawbars(void);
++static void drawtab(Monitor *m);
++static void drawtabs(void);
+ static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
+-static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
++static void drawtext(Drawable drawable, const char *text, unsigned long col[ColLast], Bool invert);
++//static void drawtabtext(const char *text, unsigned long col[ColLast], Bool invert);
+ static void enternotify(XEvent *e);
+ static void expose(XEvent *e);
+ static void focus(Client *c);
++static void focuswin(const Arg* arg);
+ static void focusin(XEvent *e);
+ static void focusmon(const Arg *arg);
+ static void focusstack(const Arg *arg);
+@@ -229,6 +245,7 @@ static void tagmon(const Arg *arg);
+ static int textnw(const char *text, unsigned int len);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
++static void tabmode(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+@@ -258,6 +275,7 @@ static char stext[256];
+ static int screen;
+ static int sw, sh; /* X display screen geometry width, height */
+ static int bh, blw = 0; /* bar geometry */
++static int th = 0; /* tab bar geometry */
+ static int (*xerrorxlib)(Display *, XErrorEvent *);
+ static unsigned int numlockmask = 0;
+ static void (*handler[LASTEvent]) (XEvent *) = {
+@@ -287,6 +305,16 @@ static Window root;
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+
++struct Pertag {
++ unsigned int curtag, prevtag; /* current and previous tag */
++ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
++ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
++ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
++ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
++ Bool showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
++ Bool showtabs[LENGTH(tags) + 1]; /* display tab bar for the current tag */
++};
++
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+@@ -405,6 +433,10 @@ arrange(Monitor *m) {
+
+ void
+ arrangemon(Monitor *m) {
++ /* Following two lines needed for the auto mode of the tab bar */
++ updatebarpos(m);
++ XMoveResizeWindow(dpy, m->tabwin, m->wx, m->ty, m->ww, th);
++
+ strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
+ if(m->lt[m->sellt]->arrange)
+ m->lt[m->sellt]->arrange(m);
+@@ -454,14 +486,32 @@ buttonpress(XEvent *e) {
+ else
+ click = ClkWinTitle;
+ }
++ if(ev->window == selmon->tabwin) {
++ i = 0; x = 0;
++ for(c = selmon->clients; c; c = c->next){
++ if(!ISVISIBLE(c)) continue;
++ x += selmon->tab_widths[i];
++ if (ev->x > x)
++ ++i;
++ else
++ break;
++ if(i >= m->ntabs) break;
++ }
++ if(c) {
++ click = ClkTabBar;
++ arg.ui = i;
++ }
++ }
+ else if((c = wintoclient(ev->window))) {
+ focus(c);
+ click = ClkClientWin;
+ }
+ for(i = 0; i < LENGTH(buttons); i++)
+ if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
+- && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
+- buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
++ && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)){
++ buttons[i].func(((click == ClkTagBar || click == ClkTabBar)
++ && buttons[i].arg.i == 0) ? &arg : &buttons[i].arg);
++ }
+ }
+
+ void
+@@ -491,6 +541,7 @@ cleanup(void) {
+ XFreeFont(dpy, dc.font.xfont);
+ XUngrabKey(dpy, AnyKey, AnyModifier, root);
+ XFreePixmap(dpy, dc.drawable);
++ XFreePixmap(dpy, dc.tabdrawable);
+ XFreeGC(dpy, dc.gc);
+ XFreeCursor(dpy, cursor[CurNormal]);
+ XFreeCursor(dpy, cursor[CurResize]);
+@@ -513,6 +564,8 @@ cleanupmon(Monitor *mon) {
+ }
+ XUnmapWindow(dpy, mon->barwin);
+ XDestroyWindow(dpy, mon->barwin);
++ XUnmapWindow(dpy, mon->tabwin);
++ XDestroyWindow(dpy, mon->tabwin);
+ free(mon);
+ }
+
+@@ -538,7 +591,7 @@ clientmessage(XEvent *e) {
+ if(cme->message_type == netatom[NetWMState]) {
+ if(cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen])
+ setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
+- || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
++ || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
+ }
+ else if(cme->message_type == netatom[NetActiveWindow]) {
+ if(!ISVISIBLE(c)) {
+@@ -581,9 +634,13 @@ configurenotify(XEvent *e) {
+ if(dc.drawable != 0)
+ XFreePixmap(dpy, dc.drawable);
+ dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
++ if(dc.tabdrawable != 0)
++ XFreePixmap(dpy, dc.tabdrawable);
++ dc.tabdrawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen));
+ updatebars();
+- for(m = mons; m; m = m->next)
++ for(m = mons; m; m = m->next){
+ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
++ }
+ focus(NULL);
+ arrange(NULL);
+ }
+@@ -646,6 +703,7 @@ configurerequest(XEvent *e) {
+ Monitor *
+ createmon(void) {
+ Monitor *m;
++ int i;
+
+ if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
+ die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
+@@ -653,10 +711,34 @@ createmon(void) {
+ m->mfact = mfact;
+ m->nmaster = nmaster;
+ m->showbar = showbar;
++ m->showtab = showtab;
+ m->topbar = topbar;
+- m->lt[0] = &layouts[0];
++ m->ntabs = 0;
++ m->sellt = 0;
++ m->lt[0] = &layouts[def_layouts[1] % LENGTH(layouts)];
+ m->lt[1] = &layouts[1 % LENGTH(layouts)];
+ strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
++ if(!(m->pertag = (Pertag *)calloc(1, sizeof(Pertag))))
++ die("fatal: could not malloc() %u bytes\n", sizeof(Pertag));
++ m->pertag->curtag = m->pertag->prevtag = 1;
++ for(i=0; i <= LENGTH(tags); i++) {
++ /* init nmaster */
++ m->pertag->nmasters[i] = m->nmaster;
++
++ /* init mfacts */
++ m->pertag->mfacts[i] = m->mfact;
++
++ /* init layouts */
++ m->pertag->ltidxs[i][0] = m->lt[0];
++ m->pertag->ltidxs[i][1] = m->lt[1];
++ m->pertag->sellts[i] = m->sellt;
++
++ /* init showbar */
++ m->pertag->showbars[i] = m->showbar;
++
++ /* init showtab */
++ m->pertag->showtabs[i] = m->showtab;
++ }
+ return m;
+ }
+
+@@ -731,13 +813,13 @@ drawbar(Monitor *m) {
+ for(i = 0; i < LENGTH(tags); i++) {
+ dc.w = TEXTW(tags[i]);
+ col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
+- drawtext(tags[i], col, urg & 1 << i);
++ drawtext(dc.drawable, tags[i], col, urg & 1 << i);
+ drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+- occ & 1 << i, urg & 1 << i, col);
++ occ & 1 << i, urg & 1 << i, col);
+ dc.x += dc.w;
+ }
+ dc.w = blw = TEXTW(m->ltsymbol);
+- drawtext(m->ltsymbol, dc.norm, False);
++ drawtext(dc.drawable, m->ltsymbol, dc.norm, False);
+ dc.x += dc.w;
+ x = dc.x;
+ if(m == selmon) { /* status is only drawn on selected monitor */
+@@ -747,19 +829,20 @@ drawbar(Monitor *m) {
+ dc.x = x;
+ dc.w = m->ww - x;
+ }
+- drawtext(stext, dc.norm, False);
++ drawtext(dc.drawable, stext, dc.norm, False);
+ }
+ else
+ dc.x = m->ww;
+ if((dc.w = dc.x - x) > bh) {
+ dc.x = x;
+ if(m->sel) {
+- col = m == selmon ? dc.sel : dc.norm;
+- drawtext(m->sel->name, col, False);
++ // col = m == selmon ? dc.sel : dc.norm;
++ // drawtext(dc.drawable, m->sel->name, col, False);
++ drawtext(dc.drawable, m->sel->name, dc.norm, False);
+ drawsquare(m->sel->isfixed, m->sel->isfloating, False, col);
+ }
+ else
+- drawtext(NULL, dc.norm, False);
++ drawtext(dc.drawable, NULL, dc.norm, False);
+ }
+ XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
+ XSync(dpy, False);
+@@ -774,6 +857,104 @@ drawbars(void) {
+ }
+
+ void
++drawtabs(void) {
++ Monitor *m;
++
++ for(m = mons; m; m = m->next)
++ drawtab(m);
++}
++
++static int
++cmpint(const void *p1, const void *p2) {
++ /* The actual arguments to this function are "pointers to
++ pointers to char", but strcmp(3) arguments are "pointers
++ to char", hence the following cast plus dereference */
++ return *((int*) p1) > * (int*) p2;
++}
++
++
++void
++drawtab(Monitor *m) {
++ unsigned long *col;
++ Client *c;
++ int i;
++ int itag = -1;
++ char view_info[50];
++ int view_info_w = 0;
++ int sorted_label_widths[MAXTABS];
++ int tot_width;
++ int maxsize = bh;
++ dc.x = 0;
++
++ //view_info: indicate the tag which is displayed in the view
++ for(i = 0; i < LENGTH(tags); ++i){
++ if((selmon->tagset[selmon->seltags] >> i) & 1) {
++ if(itag >=0){ //more than one tag selected
++ itag = -1;
++ break;
++ }
++ itag = i;
++ }
++ }
++ if(0 <= itag && itag < LENGTH(tags)){
++ snprintf(view_info, sizeof view_info, "[%s]", tags[itag]);
++ } else {
++ strncpy(view_info, "[...]", sizeof view_info);
++ }
++ view_info[sizeof(view_info) - 1 ] = 0;
++ view_info_w = TEXTW(view_info);
++ tot_width = view_info_w;
++
++ /* Calculates number of labels and their width */
++ m->ntabs = 0;
++ for(c = m->clients; c; c = c->next){
++ if(!ISVISIBLE(c)) continue;
++ m->tab_widths[m->ntabs] = TEXTW(c->name);
++ tot_width += m->tab_widths[m->ntabs];
++ ++m->ntabs;
++ if(m->ntabs >= MAXTABS) break;
++ }
++
++ if(tot_width > m->ww){ //not enough space to display the labels, they need to be truncated
++ memcpy(sorted_label_widths, m->tab_widths, sizeof(int) * m->ntabs);
++ qsort(sorted_label_widths, m->ntabs, sizeof(int), cmpint);
++ tot_width = view_info_w;
++ for(i = 0; i < m->ntabs; ++i){
++ if(tot_width + (m->ntabs - i) * sorted_label_widths[i] > m->ww)
++ break;
++ tot_width += sorted_label_widths[i];
++ }
++ maxsize = (m->ww - tot_width) / (m->ntabs - i);
++ } else{
++ maxsize = m->ww;
++ }
++ i = 0;
++ for(c = m->clients; c; c = c->next){
++ if(!ISVISIBLE(c)) continue;
++ if(i >= m->ntabs) break;
++ if(m->tab_widths[i] > maxsize) m->tab_widths[i] = maxsize;
++ dc.w = m->tab_widths[i];
++ col = (c == m->sel) ? dc.sel : dc.norm;
++ drawtext(dc.tabdrawable, c->name, col, 0);
++ dc.x += dc.w;
++ ++i;
++ }
++
++ /* cleans interspace between window names and current viewed tag label */
++ dc.w = m->ww - view_info_w - dc.x;
++ drawtext(dc.tabdrawable, NULL, dc.norm, 0);
++
++ /* view info */
++ dc.x += dc.w;
++ dc.w = view_info_w;
++ drawtext(dc.tabdrawable, view_info, dc.norm, 0);
++
++ XCopyArea(dpy, dc.tabdrawable, m->tabwin, dc.gc, 0, 0, m->ww, th, 0, 0);
++ XSync(dpy, False);
++}
++
++
++void
+ drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
+ int x;
+
+@@ -785,13 +966,14 @@ drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
+ XDrawRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x, x);
+ }
+
++
+ void
+-drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
++drawtext(Drawable drawable, const char *text, unsigned long col[ColLast], Bool invert) {
+ char buf[256];
+ int i, x, y, h, len, olen;
+
+ XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
+- XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
++ XFillRectangle(dpy, drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
+ if(!text)
+ return;
+ olen = strlen(text);
+@@ -807,11 +989,12 @@ drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
+ for(i = len; i && i > len - 3; buf[--i] = '.');
+ XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
+ if(dc.font.set)
+- XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
++ XmbDrawString(dpy, drawable, dc.font.set, dc.gc, x, y, buf, len);
+ else
+- XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
++ XDrawString(dpy, drawable, dc.gc, x, y, buf, len);
+ }
+
++
+ void
+ enternotify(XEvent *e) {
+ Client *c;
+@@ -836,8 +1019,10 @@ expose(XEvent *e) {
+ Monitor *m;
+ XExposeEvent *ev = &e->xexpose;
+
+- if(ev->count == 0 && (m = wintomon(ev->window)))
++ if(ev->count == 0 && (m = wintomon(ev->window))){
+ drawbar(m);
++ drawtab(m);
++ }
+ }
+
+ void
+@@ -862,6 +1047,7 @@ focus(Client *c) {
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ selmon->sel = c;
+ drawbars();
++ drawtabs();
+ }
+
+ void
+@@ -911,6 +1097,19 @@ focusstack(const Arg *arg) {
+ }
+ }
+
++void
++focuswin(const Arg* arg){
++ int iwin = arg->i;
++ Client* c = NULL;
++ for(c = selmon->clients; c && (iwin || !ISVISIBLE(c)) ; c = c->next){
++ if(ISVISIBLE(c)) --iwin;
++ };
++ if(c) {
++ focus(c);
++ restack(selmon);
++ }
++}
++
+ Atom
+ getatomprop(Client *c, Atom prop) {
+ int di;
+@@ -919,7 +1118,7 @@ getatomprop(Client *c, Atom prop) {
+ Atom da, atom = None;
+
+ if(XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
+- &da, &di, &dl, &dl, &p) == Success && p) {
++ &da, &di, &dl, &dl, &p) == Success && p) {
+ atom = *(Atom *)p;
+ XFree(p);
+ }
+@@ -954,7 +1153,7 @@ getstate(Window w) {
+ Atom real;
+
+ if(XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
+- &real, &format, &n, &extra, (unsigned char **)&p) != Success)
++ &real, &format, &n, &extra, (unsigned char **)&p) != Success)
+ return -1;
+ if(n != 0)
+ result = *p;
+@@ -999,13 +1198,13 @@ grabbuttons(Client *c, Bool focused) {
+ if(buttons[i].click == ClkClientWin)
+ for(j = 0; j < LENGTH(modifiers); j++)
+ XGrabButton(dpy, buttons[i].button,
+- buttons[i].mask | modifiers[j],
+- c->win, False, BUTTONMASK,
+- GrabModeAsync, GrabModeSync, None, None);
++ buttons[i].mask | modifiers[j],
++ c->win, False, BUTTONMASK,
++ GrabModeAsync, GrabModeSync, None, None);
+ }
+ else
+ XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
+- BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
++ BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
+ }
+ }
+
+@@ -1028,7 +1227,7 @@ grabkeys(void) {
+
+ void
+ incnmaster(const Arg *arg) {
+- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
+ arrange(selmon);
+ }
+
+@@ -1139,7 +1338,7 @@ manage(Window w, XWindowAttributes *wa) {
+ c->x = MAX(c->x, c->mon->mx);
+ /* only fix client y-offset, if the client center might cover the bar */
+ c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx)
+- && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
++ && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
+ c->bw = borderpx;
+
+ wc.border_width = c->bw;
+@@ -1311,12 +1510,14 @@ propertynotify(XEvent *e) {
+ case XA_WM_HINTS:
+ updatewmhints(c);
+ drawbars();
++ drawtabs();
+ break;
+ }
+ if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
+ updatetitle(c);
+ if(c == c->mon->sel)
+ drawbar(c->mon);
++ drawtab(c->mon);
+ }
+ if(ev->atom == netatom[NetWMWindowType])
+ updatewindowtype(c);
+@@ -1375,7 +1576,7 @@ resizemouse(const Arg *arg) {
+ ocx = c->x;
+ ocy = c->y;
+ if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
+- None, cursor[CurResize], CurrentTime) != GrabSuccess)
++ None, cursor[CurResize], CurrentTime) != GrabSuccess)
+ return;
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
+ do {
+@@ -1418,6 +1619,7 @@ restack(Monitor *m) {
+ XWindowChanges wc;
+
+ drawbar(m);
++ drawtab(m);
+ if(!m->sel)
+ return;
+ if(m->sel->isfloating || !m->lt[m->sellt]->arrange)
+@@ -1529,7 +1731,7 @@ void
+ setfullscreen(Client *c, Bool fullscreen) {
+ if(fullscreen) {
+ XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
+- PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
++ PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
+ c->isfullscreen = True;
+ c->oldstate = c->isfloating;
+ c->oldbw = c->bw;
+@@ -1540,7 +1742,7 @@ setfullscreen(Client *c, Bool fullscreen) {
+ }
+ else {
+ XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
+- PropModeReplace, (unsigned char*)0, 0);
++ PropModeReplace, (unsigned char*)0, 0);
+ c->isfullscreen = False;
+ c->isfloating = c->oldstate;
+ c->bw = c->oldbw;
+@@ -1555,10 +1757,13 @@ setfullscreen(Client *c, Bool fullscreen) {
+
+ void
+ setlayout(const Arg *arg) {
+- if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
+- selmon->sellt ^= 1;
++ if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) {
++ selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
++ }
+ if(arg && arg->v)
+- selmon->lt[selmon->sellt] = (Layout *)arg->v;
++ selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
+ strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
+ if(selmon->sel)
+ arrange(selmon);
+@@ -1576,7 +1781,7 @@ setmfact(const Arg *arg) {
+ f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
+ if(f < 0.1 || f > 0.9)
+ return;
+- selmon->mfact = f;
++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
+ arrange(selmon);
+ }
+
+@@ -1594,6 +1799,7 @@ setup(void) {
+ sw = DisplayWidth(dpy, screen);
+ sh = DisplayHeight(dpy, screen);
+ bh = dc.h = dc.font.height + 2;
++ th = bh;
+ updategeom();
+ /* init atoms */
+ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
+@@ -1619,6 +1825,7 @@ setup(void) {
+ dc.sel[ColBG] = getcolor(selbgcolor);
+ dc.sel[ColFG] = getcolor(selfgcolor);
+ 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)
+@@ -1632,7 +1839,7 @@ setup(void) {
+ /* select for events */
+ wa.cursor = cursor[CurNormal];
+ wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask
+- |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask;
++ |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask;
+ XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
+ XSelectInput(dpy, root, wa.event_mask);
+ grabkeys();
+@@ -1729,13 +1936,24 @@ tile(Monitor *m) {
+
+ void
+ togglebar(const Arg *arg) {
+- selmon->showbar = !selmon->showbar;
++ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
+ updatebarpos(selmon);
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
+ arrange(selmon);
+ }
+
+ void
++tabmode(const Arg *arg) {
++ if(arg && arg->i >= 0)
++ selmon->showtab = arg->ui % showtab_nmodes;
++ else
++ selmon->showtab = (selmon->showtab + 1 ) % showtab_nmodes;
++ selmon->pertag->showtabs[selmon->pertag->curtag] = selmon->showtab;
++ arrange(selmon);
++}
++
++
++void
+ togglefloating(const Arg *arg) {
+ if(!selmon->sel)
+ return;
+@@ -1763,9 +1981,31 @@ toggletag(const Arg *arg) {
+ void
+ toggleview(const Arg *arg) {
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
++ int i;
+
+ if(newtagset) {
++ if(newtagset == ~0) {
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++ selmon->pertag->curtag = 0;
++ }
++ /* test if the user did not select the same tag */
++ if(!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++ for (i=0; !(newtagset & 1 << i); i++) ;
++ selmon->pertag->curtag = i + 1;
++ }
+ selmon->tagset[selmon->seltags] = newtagset;
++
++ /* apply settings for this view */
++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
++ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
++ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
++ togglebar(NULL);
++ if (selmon->showtab != selmon->pertag->showtabs[selmon->pertag->curtag])
++ tabmode(NULL);
+ focus(NULL);
+ arrange(selmon);
+ }
+@@ -1828,24 +2068,47 @@ updatebars(void) {
+ };
+ for(m = mons; m; m = m->next) {
+ m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
+- CopyFromParent, DefaultVisual(dpy, screen),
+- CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
++ CopyFromParent, DefaultVisual(dpy, screen),
++ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+ XDefineCursor(dpy, m->barwin, cursor[CurNormal]);
+ XMapRaised(dpy, m->barwin);
++ m->tabwin = XCreateWindow(dpy, root, m->wx, m->ty, m->ww, th, 0, DefaultDepth(dpy, screen),
++ CopyFromParent, DefaultVisual(dpy, screen),
++ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
++ XDefineCursor(dpy, m->tabwin, cursor[CurNormal]);
++ XMapRaised(dpy, m->tabwin);
+ }
+ }
+
+ void
+ updatebarpos(Monitor *m) {
++ Client *c;
++ int nvis = 0;
++
+ m->wy = m->my;
+ m->wh = m->mh;
+ if(m->showbar) {
+ m->wh -= bh;
+ m->by = m->topbar ? m->wy : m->wy + m->wh;
+- m->wy = m->topbar ? m->wy + bh : m->wy;
+- }
+- else
++ if ( m->topbar )
++ m->wy += bh;
++ } else {
+ m->by = -bh;
++ }
++
++ for(c = m->clients; c; c = c->next){
++ if(ISVISIBLE(c)) ++nvis;
++ }
++
++ if(m->showtab == showtab_always
++ || ((m->showtab == showtab_auto) && (nvis > 1) && (m->lt[m->sellt]->arrange == monocle))){
++ m->wh -= th;
++ m->ty = m->toptab ? m->wy : m->wy + m->wh;
++ if ( m->toptab )
++ m->wy += th;
++ } else {
++ m->ty = -th;
++ }
+ }
+
+ Bool
+@@ -1992,7 +2255,7 @@ updatesizehints(Client *c) {
+ else
+ c->maxa = c->mina = 0.0;
+ c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
+- && c->maxw == c->minw && c->maxh == c->minh);
++ && c->maxw == c->minw && c->maxh == c->minh);
+ }
+
+ void
+@@ -2043,11 +2306,35 @@ updatewmhints(Client *c) {
+
+ void
+ view(const Arg *arg) {
++ int i;
++ unsigned int tmptag;
++
+ if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
+ return;
+ selmon->seltags ^= 1; /* toggle sel tagset */
+- if(arg->ui & TAGMASK)
++ if(arg->ui & TAGMASK) {
++ selmon->pertag->prevtag = selmon->pertag->curtag;
+ selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
++ if(arg->ui == ~0)
++ selmon->pertag->curtag = 0;
++ else {
++ for (i=0; !(arg->ui & 1 << i); i++) ;
++ selmon->pertag->curtag = i + 1;
++ }
++ } else {
++ tmptag = selmon->pertag->prevtag;
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++ selmon->pertag->curtag = tmptag;
++ }
++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
++ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
++ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
++ togglebar(NULL);
++ if (selmon->showtab != selmon->pertag->showtabs[selmon->pertag->curtag])
++ tabmode(NULL);
+ focus(NULL);
+ arrange(selmon);
+ }
+@@ -2073,7 +2360,7 @@ wintomon(Window w) {
+ if(w == root && getrootptr(&x, &y))
+ return recttomon(x, y, 1, 1);
+ for(m = mons; m; m = m->next)
+- if(w == m->barwin)
++ if(w == m->barwin || w == m->tabwin)
+ return m;
+ if((c = wintoclient(w)))
+ return c->mon;
diff --git a/dwm-6.0-xft.diff b/dwm-6.0-xft.diff
new file mode 100644
index 0000000..cae66bd
--- /dev/null
+++ b/dwm-6.0-xft.diff
@@ -0,0 +1,229 @@
+--- ../dwm-o/dwm-6.0/dwm.c 2011-12-19 10:02:46.000000000 -0500
++++ dwm.c 2012-05-16 22:33:00.043394484 -0400
+@@ -39,6 +39,7 @@
+ #ifdef XINERAMA
+ #include <X11/extensions/Xinerama.h>
+ #endif /* XINERAMA */
++#include <X11/Xft/Xft.h>
+
+ /* macros */
+ #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
+@@ -99,16 +100,15 @@
+
+ typedef struct {
+ int x, y, w, h;
+- unsigned long norm[ColLast];
+- unsigned long sel[ColLast];
++ XftColor norm[ColLast];
++ XftColor sel[ColLast];
+ Drawable drawable;
+ GC gc;
+ struct {
+ int ascent;
+ int descent;
+ int height;
+- XFontSet set;
+- XFontStruct *xfont;
++ XftFont *xfont;
+ } font;
+ } DC; /* draw context */
+
+@@ -178,15 +178,15 @@
+ static Monitor *dirtomon(int dir);
+ static void drawbar(Monitor *m);
+ static void drawbars(void);
+-static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
+-static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
++static void drawsquare(Bool filled, Bool empty, Bool invert, XftColor col[ColLast]);
++static void drawtext(const char *text, XftColor col[ColLast], Bool invert);
+ static void enternotify(XEvent *e);
+ static void expose(XEvent *e);
+ static void focus(Client *c);
+ 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 getcolor(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);
+@@ -485,10 +485,6 @@
+ for(m = mons; m; m = m->next)
+ while(m->stack)
+ unmanage(m->stack, False);
+- if(dc.font.set)
+- XFreeFontSet(dpy, dc.font.set);
+- else
+- XFreeFont(dpy, dc.font.xfont);
+ XUngrabKey(dpy, AnyKey, AnyModifier, root);
+ XFreePixmap(dpy, dc.drawable);
+ XFreeGC(dpy, dc.gc);
+@@ -719,7 +715,7 @@
+ drawbar(Monitor *m) {
+ int x;
+ unsigned int i, occ = 0, urg = 0;
+- unsigned long *col;
++ XftColor *col;
+ Client *c;
+
+ for(c = m->clients; c; c = c->next) {
+@@ -774,10 +770,10 @@
+ }
+
+ void
+-drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
++drawsquare(Bool filled, Bool empty, Bool invert, XftColor col[ColLast]) {
+ int x;
+
+- XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
++ XSetForeground(dpy, dc.gc, col[invert ? ColBG : 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);
+@@ -786,11 +782,12 @@
+ }
+
+ void
+-drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
++drawtext(const char *text, XftColor col[ColLast], Bool invert) {
+ char buf[256];
+ int i, x, y, h, len, olen;
++ XftDraw *d;
+
+- XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
++ XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG].pixel);
+ XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
+ if(!text)
+ return;
+@@ -805,11 +802,11 @@
+ memcpy(buf, text, len);
+ if(len < olen)
+ for(i = len; i && i > len - 3; buf[--i] = '.');
+- XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
+- if(dc.font.set)
+- XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
+- else
+- XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
++
++ d = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy,screen));
++
++ XftDrawStringUtf8(d, &col[invert ? ColBG : ColFG], dc.font.xfont, x, y, (XftChar8 *) buf, len);
++ XftDrawDestroy(d);
+ }
+
+ void
+@@ -855,7 +852,7 @@
+ detachstack(c);
+ attachstack(c);
+ grabbuttons(c, True);
+- XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
++ XSetWindowBorder(dpy, c->win, dc.sel[ColBorder].pixel);
+ setfocus(c);
+ }
+ else
+@@ -926,14 +923,14 @@
+ return atom;
+ }
+
+-unsigned long
++XftColor
+ getcolor(const char *colstr) {
+- Colormap cmap = DefaultColormap(dpy, screen);
+- XColor color;
++ XftColor color;
+
+- if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
++ if(!XftColorAllocName(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), colstr, &color))
+ die("error, cannot allocate color '%s'\n", colstr);
+- return color.pixel;
++
++ return color;
+ }
+
+ Bool
+@@ -1034,35 +1031,13 @@
+
+ void
+ initfont(const char *fontstr) {
+- char *def, **missing;
+- int n;
+
+- 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;
+- }
++ 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.ascent = dc.font.xfont->ascent;
++ dc.font.descent = dc.font.xfont->descent;
+ dc.font.height = dc.font.ascent + dc.font.descent;
+ }
+
+@@ -1144,7 +1119,7 @@
+
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+- XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
++ XSetWindowBorder(dpy, w, dc.norm[ColBorder].pixel);
+ configure(c); /* propagates border_width, if size doesn't change */
+ updatewindowtype(c);
+ updatesizehints(c);
+@@ -1621,8 +1596,6 @@
+ dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, 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();
+@@ -1692,13 +1665,9 @@
+
+ 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
+@@ -1776,7 +1745,7 @@
+ if(!c)
+ return;
+ grabbuttons(c, False);
+- XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
++ XSetWindowBorder(dpy, c->win, dc.norm[ColBorder].pixel);
+ if(setfocus)
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ }
diff --git a/dwm.o b/dwm.o
index 3fb3947..313bb81 100644
--- a/dwm.o
+++ b/dwm.o
Binary files differ