diff options
| author | Anselm R. Garbe <arg@10kloc.org> | 2006-08-25 12:59:45 +0200 | 
|---|---|---|
| committer | Anselm R. Garbe <arg@10kloc.org> | 2006-08-25 12:59:45 +0200 | 
| commit | b55bd709ee6d0b09c141bf5ffe0647866e0374ef (patch) | |
| tree | 50bb320829520b71e8280a298af162b0ba1508a2 | |
| parent | 9833610356f7ce033589680fddf87000e5788774 (diff) | |
new color stuff/new rendering stuff
| -rw-r--r-- | config.arg.h | 39 | ||||
| -rw-r--r-- | config.default.h | 11 | ||||
| -rw-r--r-- | draw.c | 49 | ||||
| -rw-r--r-- | dwm.h | 11 | ||||
| -rw-r--r-- | event.c | 4 | ||||
| -rw-r--r-- | main.c | 14 | 
6 files changed, 70 insertions, 58 deletions
| diff --git a/config.arg.h b/config.arg.h index 170c91c..7716916 100644 --- a/config.arg.h +++ b/config.arg.h @@ -4,50 +4,59 @@   */  #define TAGS \ -const char *tags[] = { "work", "net", "fnord", NULL }; +const char *tags[] = { "1", "2", "3", "4", "5", NULL };  #define DEFMODE			dotile /* dofloat */ -#define FONT			"-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*" -#define BGCOLOR			"#666699" -#define FGCOLOR			"#eeeeee" -#define BORDERCOLOR		"#9999CC" + +#define FONT			"fixed" +#define SELBGCOLOR		"#666699" +#define SELFGCOLOR		"#eeeeee" +#define NORMBGCOLOR		"#333366" +#define NORMFGCOLOR		"#cccccc" +#define STATUSBGCOLOR		"#dddddd" +#define STATUSFGCOLOR		"#222222" +  #define MODKEY			Mod1Mask  #define MASTERW			60 /* percent */  #define KEYS \  static Key key[] = { \  	/* modifier			key		function	arguments */ \ -	{ MODKEY|ShiftMask,		XK_Return,	spawn, \ -		{ .cmd = "exec uxterm -bg '#e0e0e0' -fg '#000000' -cr '#000000' +sb -fn '"FONT"'" } }, \ -	{ MODKEY,			XK_p,		spawn, \ -		{ .cmd = "exec `ls -lL /usr/bin /usr/X11R6/bin /usr/local/bin 2>/dev/null | " \ -			"awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort -u | dmenu`" } }, \ -	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \ -	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \ +	{ MODKEY|ShiftMask,		XK_Return,	spawn,		{ .cmd = "exec xterm" } }, \ +	{ MODKEY,			XK_Tab,		focusnext,	{ 0 } }, \ +	{ MODKEY|ShiftMask,		XK_Tab,		focusprev,	{ 0 } }, \  	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \  	{ MODKEY,			XK_m,		togglemax,	{ 0 } }, \  	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \  	{ MODKEY|ShiftMask,		XK_2,		tag,		{ .i = 1 } }, \  	{ MODKEY|ShiftMask,		XK_3,		tag,		{ .i = 2 } }, \ +	{ MODKEY|ShiftMask,		XK_4,		tag,		{ .i = 3 } }, \ +	{ MODKEY|ShiftMask,		XK_5,		tag,		{ .i = 4 } }, \  	{ MODKEY|ControlMask|ShiftMask,	XK_1,		toggletag,	{ .i = 0 } }, \  	{ MODKEY|ControlMask|ShiftMask,	XK_2,		toggletag,	{ .i = 1 } }, \  	{ MODKEY|ControlMask|ShiftMask,	XK_3,		toggletag,	{ .i = 2 } }, \ +	{ MODKEY|ControlMask|ShiftMask,	XK_4,		toggletag,	{ .i = 3 } }, \ +	{ MODKEY|ControlMask|ShiftMask,	XK_5,		toggletag,	{ .i = 4 } }, \  	{ MODKEY|ShiftMask,		XK_c,		killclient,	{ 0 } }, \  	{ MODKEY,			XK_space,	togglemode,	{ 0 } }, \  	{ MODKEY,			XK_1,		view,		{ .i = 0 } }, \  	{ MODKEY,			XK_2,		view,		{ .i = 1 } }, \  	{ MODKEY,			XK_3,		view,		{ .i = 2 } }, \ +	{ MODKEY,			XK_4,		view,		{ .i = 3 } }, \ +	{ MODKEY,			XK_5,		view,		{ .i = 4 } }, \  	{ MODKEY|ControlMask,		XK_1,		toggleview,	{ .i = 0 } }, \  	{ MODKEY|ControlMask,		XK_2,		toggleview,	{ .i = 1 } }, \  	{ MODKEY|ControlMask,		XK_3,		toggleview,	{ .i = 2 } }, \ +	{ MODKEY|ControlMask,		XK_4,		toggleview,	{ .i = 3 } }, \ +	{ MODKEY|ControlMask,		XK_5,		toggleview,	{ .i = 4 } }, \  	{ MODKEY|ShiftMask,		XK_q,		quit,		{ 0 } }, \  }; +/* Query class:instance:title for regex matching info with following command: + * xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/{ printf("%s\n",$2) }' */  #define RULES \  static Rule rule[] = { \  	/* class:instance:title regex	tags regex	isfloat */ \ -	{ "Firefox.*",			"net",		False }, \ +	{ "Firefox.*",			"2",		False }, \  	{ "Gimp.*",			NULL,		True}, \ -	{ "MPlayer.*",			NULL,		True}, \ -	{ "Acroread.*",			NULL,		True}, \  }; diff --git a/config.default.h b/config.default.h index c0102b0..7716916 100644 --- a/config.default.h +++ b/config.default.h @@ -7,10 +7,15 @@  const char *tags[] = { "1", "2", "3", "4", "5", NULL };  #define DEFMODE			dotile /* dofloat */ +  #define FONT			"fixed" -#define BGCOLOR			"#666699" -#define FGCOLOR			"#eeeeee" -#define BORDERCOLOR		"#9999CC" +#define SELBGCOLOR		"#666699" +#define SELFGCOLOR		"#eeeeee" +#define NORMBGCOLOR		"#333366" +#define NORMFGCOLOR		"#cccccc" +#define STATUSBGCOLOR		"#dddddd" +#define STATUSFGCOLOR		"#222222" +  #define MODKEY			Mod1Mask  #define MASTERW			60 /* percent */ @@ -22,29 +22,16 @@ textnw(const char *text, unsigned int len)  }  static void -drawtext(const char *text, Bool invert, Bool highlight) +drawtext(const char *text, unsigned long col[ColLast], Bool highlight)  {  	int x, y, w, h;  	static char buf[256];  	unsigned int len, olen;  	XGCValues gcv; -	XPoint points[5];  	XRectangle r = { dc.x, dc.y, dc.w, dc.h }; -	XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg); +	XSetForeground(dpy, dc.gc, col[ColBG]);  	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); -	points[0].x = dc.x; -	points[0].y = dc.y; -	points[1].x = dc.w - 1; -	points[1].y = 0; -	points[2].x = 0; -	points[2].y = dc.h - 1; -	points[3].x = -(dc.w - 1); -	points[3].y = 0; -	points[4].x = 0; -	points[4].y = -(dc.h - 1); -	XSetForeground(dpy, dc.gc, dc.border); -	XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);  	if(!text)  		return; @@ -74,15 +61,14 @@ drawtext(const char *text, Bool invert, Bool highlight)  	if(w > dc.w)  		return; /* too long */ -	gcv.foreground = invert ? dc.bg : dc.fg; -	gcv.background = invert ? dc.fg : dc.bg; +	gcv.foreground = col[ColFG];  	if(dc.font.set) { -		XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv); +		XChangeGC(dpy, dc.gc, GCForeground, &gcv);  		XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);  	}  	else {  		gcv.font = dc.font.xfont->fid; -		XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv); +		XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);  		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);  	}  	if(highlight) { @@ -108,21 +94,25 @@ drawall()  void  drawstatus()  { +	static const char *mode[] = { "~", "=" };  	int i, x; -	Bool istile = arrange == dotile;  	dc.x = dc.y = 0;  	dc.w = bw; -	drawtext(NULL, !istile, False); + +	if(!modew) +		modew = textw(mode[0]) > textw(mode[1]) ? textw(mode[0]) : textw(mode[1]); +	drawtext(mode[arrange == dotile ? 1 : 0], dc.status, False);  	dc.w = 0; +	dc.x = modew;  	for(i = 0; i < ntags; i++) {  		dc.x += dc.w;  		dc.w = textw(tags[i]); -		if(istile) -			drawtext(tags[i], seltag[i], sel && sel->tags[i]); +		if(seltag[i]) +			drawtext(tags[i], dc.sel, sel && sel->tags[i]);  		else -			drawtext(tags[i], !seltag[i], sel && sel->tags[i]); +			drawtext(tags[i], dc.norm, sel && sel->tags[i]);  	}  	x = dc.x + dc.w;  	dc.w = textw(stext); @@ -131,11 +121,11 @@ drawstatus()  		dc.x = x;  		dc.w = bw - x;  	} -	drawtext(stext, !istile, False); +	drawtext(stext, dc.status, False);  	if(sel && ((dc.w = dc.x - x) > bh)) {  		dc.x = x; -		drawtext(sel->name, istile, False); +		drawtext(sel->name, dc.sel, False);  	}  	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);  	XSync(dpy, False); @@ -145,20 +135,19 @@ void  drawtitle(Client *c)  {  	int i; -	Bool istile = arrange == dotile;  	if(c == sel && issel) {  		drawstatus();  		XUnmapWindow(dpy, c->twin); -		XSetWindowBorder(dpy, c->win, dc.fg); +		XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);  		return;  	} -	XSetWindowBorder(dpy, c->win, dc.bg); +	XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);  	XMapWindow(dpy, c->twin);  	dc.x = dc.y = 0;  	dc.w = c->tw; -	drawtext(c->name, !istile, False); +	drawtext(c->name, dc.norm, False);  	XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);  	XSync(dpy, False);  } @@ -23,6 +23,9 @@ enum { WMProtocols, WMDelete, WMLast };  /* cursor */  enum { CurNormal, CurResize, CurMove, CurLast }; +/* color */ +enum { ColFG, ColBG, ColLast }; +  /* window corners */  typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner; @@ -36,9 +39,9 @@ typedef struct {  typedef struct { /* draw context */  	int x, y, w, h; -	unsigned long bg; -	unsigned long fg; -	unsigned long border; +	unsigned long norm[ColLast]; +	unsigned long sel[ColLast]; +	unsigned long status[ColLast];  	Drawable drawable;  	Fnt font;  	GC gc; @@ -66,7 +69,7 @@ struct Client {  extern const char *tags[];  extern char stext[1024];  extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; -extern unsigned int ntags, numlockmask; +extern unsigned int ntags, numlockmask, modew;  extern void (*handler[LASTEvent])(XEvent *);  extern void (*arrange)(Arg *);  extern Atom wmatom[WMLast], netatom[NetLast]; @@ -105,7 +105,9 @@ buttonpress(XEvent *e)  	XButtonPressedEvent *ev = &e->xbutton;  	if(barwin == ev->window) { -		x = 0; +		if(ev->x < modew) +			return; +		x = modew;  		for(a.i = 0; a.i < ntags; a.i++) {  			x += textw(tags[a.i]);  			if(ev->x < x) { @@ -20,7 +20,7 @@  char stext[1024];  Bool *seltag;  int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; -unsigned int ntags, numlockmask; +unsigned int ntags, numlockmask, modew;  Atom wmatom[WMLast], netatom[NetLast];  Bool running = True;  Bool issel = True; @@ -121,11 +121,15 @@ setup()  	seltag[0] = True;  	/* style */ -	dc.bg = getcolor(BGCOLOR); -	dc.fg = getcolor(FGCOLOR); -	dc.border = getcolor(BORDERCOLOR); +	dc.norm[ColBG] = getcolor(NORMBGCOLOR); +	dc.norm[ColFG] = getcolor(NORMFGCOLOR); +	dc.sel[ColBG] = getcolor(SELBGCOLOR); +	dc.sel[ColFG] = getcolor(SELFGCOLOR); +	dc.status[ColBG] = getcolor(STATUSBGCOLOR); +	dc.status[ColFG] = getcolor(STATUSFGCOLOR);  	setfont(FONT); +	modew = 0;  	sx = sy = 0;  	sw = DisplayWidth(dpy, screen);  	sh = DisplayHeight(dpy, screen); @@ -133,7 +137,7 @@ setup()  	bx = by = 0;  	bw = sw; -	dc.h = bh = dc.font.height + 4; +	dc.h = bh = dc.font.height + 2;  	wa.override_redirect = 1;  	wa.background_pixmap = ParentRelative;  	wa.event_mask = ButtonPressMask | ExposureMask; | 
