diff -Naurp dwm-5.1-old/config.def.h dwm-5.1/config.def.h --- dwm-5.1-old/config.def.h 2008-07-29 13:18:32.000000000 -0500 +++ dwm-5.1/config.def.h 2008-08-16 16:03:29.000000000 -0500 @@ -26,11 +26,15 @@ static Rule rules[] = { static float mfact = 0.55; static Bool resizehints = True; /* False means respect size hints in tiled resizals */ +#include "tile.xpm" +#include "floating.xpm" +#include "monocle.xpm" + static Layout layouts[] = { /* symbol arrange function */ - { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ - { "[M]", monocle }, + { tile_xpm, tile }, /* first entry is default */ + { floating_xpm, NULL }, /* no layout function means floating behavior */ + { monocole_xpm, monocle }, }; /* key definitions */ diff -Naurp dwm-5.1-old/config.mk dwm-5.1/config.mk --- dwm-5.1-old/config.mk 2008-07-29 13:18:32.000000000 -0500 +++ dwm-5.1/config.mk 2008-08-16 16:04:21.000000000 -0500 @@ -16,7 +16,7 @@ XINERAMAFLAGS = -DXINERAMA # includes and libs INCS = -I. -I/usr/include -I${X11INC} -LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} +LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} -lXpm -lXext # flags CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff -Naurp dwm-5.1-old/dwm.c dwm-5.1/dwm.c --- dwm-5.1-old/dwm.c 2008-07-29 13:18:32.000000000 -0500 +++ dwm-5.1/dwm.c 2008-08-16 16:02:25.000000000 -0500 @@ -34,7 +34,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -116,7 +118,7 @@ typedef struct { } Key; typedef struct { - const char *symbol; + char **symbol; void (*arrange)(void); } Layout; @@ -145,6 +147,7 @@ static void detach(Client *c); static void detachstack(Client *c); static void die(const char *errstr, ...); static void drawbar(void); +static void drawpixmap(char **data, unsigned long col[ColLast], Bool invert); 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 enternotify(XEvent *e); @@ -350,7 +353,7 @@ checkotherwm(void) { void cleanup(void) { Arg a = {.i = ~0}; - Layout foo = { "", NULL }; + Layout foo = { NULL, NULL }; close(STDIN_FILENO); view(&a); @@ -517,7 +520,7 @@ drawbar(void) { } if(blw > 0) { dc.w = blw; - drawtext(lt[sellt]->symbol, dc.norm, False); + drawpixmap(lt[sellt]->symbol, dc.norm, False); x = dc.x + dc.w; } else @@ -543,6 +546,24 @@ drawbar(void) { } void +drawpixmap(char **data, unsigned long col[ColLast], Bool invert) { + Pixmap src, mask; + XpmAttributes xa; + XGCValues gcv; + XRectangle r = { dc.x, dc.y, dc.w, dc.h }; + + gcv.foreground = col[invert ? ColBG : ColFG]; + XChangeGC(dpy, dc.gc, GCForeground, &gcv); + XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); + xa.valuemask = (XpmReturnPixels | XpmReturnExtensions); + XpmCreatePixmapFromData(dpy, dc.drawable, data, &src, &mask, &xa); + XCopyArea(dpy, src, dc.drawable, dc.gc, 0, 0, dc.w, dc.h, dc.x, dc.y); + XShapeCombineMask(dpy, dc.drawable, ShapeBounding, 0, 0, mask, ShapeSet); + XFreePixmap(dpy, src); + XFreePixmap(dpy, mask); +} + +void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) { int x; XGCValues gcv; @@ -1330,8 +1351,7 @@ setmfact(const Arg *arg) { void setup(void) { - unsigned int i; - int w; + unsigned int i, w, h, x, y; XSetWindowAttributes wa; /* init screen */ @@ -1345,7 +1365,6 @@ setup(void) { bh = dc.h = dc.font.height + 2; lt[0] = &layouts[0]; lt[1] = &layouts[1 % LENGTH(layouts)]; - updategeom(); /* init atoms */ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); @@ -1374,10 +1393,14 @@ setup(void) { XSetFont(dpy, dc.gc, dc.font.xfont->fid); /* init bar */ - for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) { - w = TEXTW(layouts[i].symbol); + for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts) - 1; i++) { + if (sscanf(lt[i]->symbol[0], "%u %u %u %u", &w, &h, &x, &y) != 4) + die("failed to read xpm dimensions\n"); blw = MAX(blw, w); + bh = dc.h = MAX(bh, h); } + updategeom(); + updatebar(); wa.override_redirect = 1; wa.background_pixmap = ParentRelative; diff -Naurp dwm-5.1-old/floating.xpm dwm-5.1/floating.xpm --- dwm-5.1-old/floating.xpm 1969-12-31 18:00:00.000000000 -0600 +++ dwm-5.1/floating.xpm 2008-08-16 15:37:52.000000000 -0500 @@ -0,0 +1,37 @@ +/* XPM */ +static char * floating_xpm[] = { +"32 32 2 1", +" c None", +". c #FF0000", +".............. ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +". . ", +".............. ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff -Naurp dwm-5.1-old/monocle.xpm dwm-5.1/monocle.xpm --- dwm-5.1-old/monocle.xpm 1969-12-31 18:00:00.000000000 -0600 +++ dwm-5.1/monocle.xpm 2008-08-16 16:03:06.000000000 -0500 @@ -0,0 +1,37 @@ +/* XPM */ +static char * monocole_xpm[] = { +"32 32 2 1", +" c None", +". c #FF0000", +"................................", +".. ..", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". .. .", +". .. .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +".. ..", +"................................"}; diff -Naurp dwm-5.1-old/tile.xpm dwm-5.1/tile.xpm --- dwm-5.1-old/tile.xpm 1969-12-31 18:00:00.000000000 -0600 +++ dwm-5.1/tile.xpm 2008-08-16 15:37:52.000000000 -0500 @@ -0,0 +1,37 @@ +/* XPM */ +static char * tile_xpm[] = { +"32 32 2 1", +" c None", +". c #FF0000", +"................................", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". ................", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". ................", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +"................................"};