I have tried to correct this patch. --- dwm.c 2008-09-10 04:46:17.000000000 +0900 +++ dwm.c 2008-10-22 11:41:23.998331637 +0900 @@ -117,6 +117,7 @@ } Key;
typedef struct { + const char *icon; const char *symbol; void (*arrange)(void); } Layout; @@ -146,6 +147,7 @@ static void detachstack(Client *c); static void die(const char *errstr, ...); static void drawbar(void); +static void drawicon(const char *file, unsigned long col[ColLast]); 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); @@ -208,6 +210,7 @@ static int screen; static int sx, sy, sw, sh; /* X display screen geometry x, y, width, height */ static int by, bh, blw; /* bar geometry y, height and layout symbol width */ +static int iy, ih, iw, ix; /* icon geometry*/ static int wx, wy, ww, wh; /* window area geometry x, y, width, height, bar excluded */ static unsigned int seltags = 0, sellt = 0; static int (*xerrorxlib)(Display *, XErrorEvent *); @@ -511,8 +514,14 @@ dc.x += dc.w; } if(blw > 0) { + if (useicons == False) { dc.w = blw; drawtext(lt[sellt]->symbol, dc.norm, False); + } + else { + dc.w = iw; + drawicon(lt[sellt]->icon, dc.sel); + } x = dc.x + dc.w; } else @@ -538,6 +547,21 @@ } void +drawicon(const char *file, unsigned long col[ColLast]) { + Pixmap icon; + unsigned int x, y, pw, ph; + icon = XCreatePixmap(dpy, dc.drawable, iw, ih, 1); + XReadBitmapFile(dpy, dc.drawable, file, &pw, &ph, &icon, &ix, &iy); + x = dc.x + (iw / 2) - (pw / 2) - 1 ; + y = dc.y + (ih / 2) - (ph / 2) - 1; + XSetForeground(dpy, dc.gc, col[ColBG]); + XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, 0, iw, ih); + XSetForeground(dpy, dc.gc, col[ColFG]); + XSetBackground(dpy, dc.gc, col[ColBG]); + XCopyPlane(dpy, icon, dc.drawable, dc.gc, ix, iy, iw, ih, x, y, 1); +} + +void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) { int x; XGCValues gcv; @@ -1307,7 +1331,7 @@ sy = 0; sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); - bh = dc.h = dc.font.height + 2; + iw = ih = bh = dc.h = dc.font.height + 2; lt[0] = &layouts[0]; lt[1] = &layouts[1 % LENGTH(layouts)]; updategeom(); --- config.def.h 2008-09-10 04:46:17.000000000 +0900 +++ config.def.h 2008-10-22 11:42:21.201603243 +0900 @@ -1,7 +1,7 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ -static const char font[] = "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*"; +static const char font[] = "-*-terminus-medium-r-normal-*-10-*-*-*-*-*-*-*"; static const char normbordercolor[] = "#cccccc"; static const char normbgcolor[] = "#cccccc"; static const char normfgcolor[] = "#000000"; @@ -13,6 +13,8 @@ static Bool showbar = True; /* False means no bar */ static Bool topbar = True; /* False means bottom bar */ static Bool readin = True; /* False means do not read stdin */ +static Bool useicons = True; /* User icons for Layout True or False */ + /* tagging */ static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; @@ -29,10 +31,10 @@ static Bool resizehints = True; /* False means respect size hints in tiled resizals */ static Layout layouts[] = { - /* symbol arrange function */ - { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ - { "[M]", monocle }, + /* icon symbol arrange function */ + { "{yuor path to icon}.xbm", "[]=", tile }, /* first entry is default */ + { "{yuor path to icon}.xbm", "><>", NULL }, /* no layout function means floating behavior */ + { "{yuor path to icon}.xbm", "[M]", monocle }, }; /* key definitions */ Its work =. But, i dont have ideas as it make batter x = dc.x + (iw / 2) - (pw / 2) - 1 ; y = dc.y + (ih / 2) - (ph / 2) - 1; 2008/10/22 Alexandr Gubanoff <[EMAIL PROTECTED]> > Ooops =) I have forgott. > > Write thes line "static int iy, ix, ih = 14, iw = 14;" in variables. > > At me it is a line number 213. > > > 2008/10/22 Henry <[EMAIL PROTECTED]> > >> Hi, >> >> i like the idea but i cant try it cause i cant figure out where i{x,y,w,h} >> should come from. >> i guess they should describe the icons positon and size but patched >> against a clean tarball or hg clone it dosnt work. >> could you clearify this? id really like to try it out :) >> >> >> kind regards, >> >> Henry >> >> CC dwm.c >> dwm.c: In function 'drawbar': >> dwm.c:522: error: 'iw' undeclared (first use in this function) >> dwm.c:522: error: (Each undeclared identifier is reported only once >> dwm.c:522: error: for each function it appears in.) >> dwm.c: In function 'drawicon': >> dwm.c:555: error: 'ix' undeclared (first use in this function) >> dwm.c:555: error: 'iy' undeclared (first use in this function) >> dwm.c:558: error: 'iw' undeclared (first use in this function) >> dwm.c:558: error: 'ih' undeclared (first use in this function) >> make: *** [dwm.o] Error 1 >> >> >