dwm-meillo

changeset 353:8a06efe5b563

new color stuff/new rendering stuff
author Anselm R. Garbe <arg@10kloc.org>
date Fri, 25 Aug 2006 12:59:45 +0200
parents 5a8bdc3b37cb
children bb780add36c6
files config.arg.h config.default.h draw.c dwm.h event.c main.c
diffstat 6 files changed, 70 insertions(+), 58 deletions(-) [+]
line diff
     1.1 --- a/config.arg.h	Fri Aug 25 07:54:49 2006 +0200
     1.2 +++ b/config.arg.h	Fri Aug 25 12:59:45 2006 +0200
     1.3 @@ -4,50 +4,59 @@
     1.4   */
     1.5  
     1.6  #define TAGS \
     1.7 -const char *tags[] = { "work", "net", "fnord", NULL };
     1.8 +const char *tags[] = { "1", "2", "3", "4", "5", NULL };
     1.9  
    1.10  #define DEFMODE			dotile /* dofloat */
    1.11 -#define FONT			"-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
    1.12 -#define BGCOLOR			"#666699"
    1.13 -#define FGCOLOR			"#eeeeee"
    1.14 -#define BORDERCOLOR		"#9999CC"
    1.15 +
    1.16 +#define FONT			"fixed"
    1.17 +#define SELBGCOLOR		"#666699"
    1.18 +#define SELFGCOLOR		"#eeeeee"
    1.19 +#define NORMBGCOLOR		"#333366"
    1.20 +#define NORMFGCOLOR		"#cccccc"
    1.21 +#define STATUSBGCOLOR		"#dddddd"
    1.22 +#define STATUSFGCOLOR		"#222222"
    1.23 +
    1.24  #define MODKEY			Mod1Mask
    1.25  #define MASTERW			60 /* percent */
    1.26  
    1.27  #define KEYS \
    1.28  static Key key[] = { \
    1.29  	/* modifier			key		function	arguments */ \
    1.30 -	{ MODKEY|ShiftMask,		XK_Return,	spawn, \
    1.31 -		{ .cmd = "exec uxterm -bg '#e0e0e0' -fg '#000000' -cr '#000000' +sb -fn '"FONT"'" } }, \
    1.32 -	{ MODKEY,			XK_p,		spawn, \
    1.33 -		{ .cmd = "exec `ls -lL /usr/bin /usr/X11R6/bin /usr/local/bin 2>/dev/null | " \
    1.34 -			"awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort -u | dmenu`" } }, \
    1.35 -	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \
    1.36 -	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \
    1.37 +	{ MODKEY|ShiftMask,		XK_Return,	spawn,		{ .cmd = "exec xterm" } }, \
    1.38 +	{ MODKEY,			XK_Tab,		focusnext,	{ 0 } }, \
    1.39 +	{ MODKEY|ShiftMask,		XK_Tab,		focusprev,	{ 0 } }, \
    1.40  	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
    1.41  	{ MODKEY,			XK_m,		togglemax,	{ 0 } }, \
    1.42  	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
    1.43  	{ MODKEY|ShiftMask,		XK_2,		tag,		{ .i = 1 } }, \
    1.44  	{ MODKEY|ShiftMask,		XK_3,		tag,		{ .i = 2 } }, \
    1.45 +	{ MODKEY|ShiftMask,		XK_4,		tag,		{ .i = 3 } }, \
    1.46 +	{ MODKEY|ShiftMask,		XK_5,		tag,		{ .i = 4 } }, \
    1.47  	{ MODKEY|ControlMask|ShiftMask,	XK_1,		toggletag,	{ .i = 0 } }, \
    1.48  	{ MODKEY|ControlMask|ShiftMask,	XK_2,		toggletag,	{ .i = 1 } }, \
    1.49  	{ MODKEY|ControlMask|ShiftMask,	XK_3,		toggletag,	{ .i = 2 } }, \
    1.50 +	{ MODKEY|ControlMask|ShiftMask,	XK_4,		toggletag,	{ .i = 3 } }, \
    1.51 +	{ MODKEY|ControlMask|ShiftMask,	XK_5,		toggletag,	{ .i = 4 } }, \
    1.52  	{ MODKEY|ShiftMask,		XK_c,		killclient,	{ 0 } }, \
    1.53  	{ MODKEY,			XK_space,	togglemode,	{ 0 } }, \
    1.54  	{ MODKEY,			XK_1,		view,		{ .i = 0 } }, \
    1.55  	{ MODKEY,			XK_2,		view,		{ .i = 1 } }, \
    1.56  	{ MODKEY,			XK_3,		view,		{ .i = 2 } }, \
    1.57 +	{ MODKEY,			XK_4,		view,		{ .i = 3 } }, \
    1.58 +	{ MODKEY,			XK_5,		view,		{ .i = 4 } }, \
    1.59  	{ MODKEY|ControlMask,		XK_1,		toggleview,	{ .i = 0 } }, \
    1.60  	{ MODKEY|ControlMask,		XK_2,		toggleview,	{ .i = 1 } }, \
    1.61  	{ MODKEY|ControlMask,		XK_3,		toggleview,	{ .i = 2 } }, \
    1.62 +	{ MODKEY|ControlMask,		XK_4,		toggleview,	{ .i = 3 } }, \
    1.63 +	{ MODKEY|ControlMask,		XK_5,		toggleview,	{ .i = 4 } }, \
    1.64  	{ MODKEY|ShiftMask,		XK_q,		quit,		{ 0 } }, \
    1.65  };
    1.66  
    1.67 +/* Query class:instance:title for regex matching info with following command:
    1.68 + * xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/{ printf("%s\n",$2) }' */
    1.69  #define RULES \
    1.70  static Rule rule[] = { \
    1.71  	/* class:instance:title regex	tags regex	isfloat */ \
    1.72 -	{ "Firefox.*",			"net",		False }, \
    1.73 +	{ "Firefox.*",			"2",		False }, \
    1.74  	{ "Gimp.*",			NULL,		True}, \
    1.75 -	{ "MPlayer.*",			NULL,		True}, \
    1.76 -	{ "Acroread.*",			NULL,		True}, \
    1.77  };
     2.1 --- a/config.default.h	Fri Aug 25 07:54:49 2006 +0200
     2.2 +++ b/config.default.h	Fri Aug 25 12:59:45 2006 +0200
     2.3 @@ -7,10 +7,15 @@
     2.4  const char *tags[] = { "1", "2", "3", "4", "5", NULL };
     2.5  
     2.6  #define DEFMODE			dotile /* dofloat */
     2.7 +
     2.8  #define FONT			"fixed"
     2.9 -#define BGCOLOR			"#666699"
    2.10 -#define FGCOLOR			"#eeeeee"
    2.11 -#define BORDERCOLOR		"#9999CC"
    2.12 +#define SELBGCOLOR		"#666699"
    2.13 +#define SELFGCOLOR		"#eeeeee"
    2.14 +#define NORMBGCOLOR		"#333366"
    2.15 +#define NORMFGCOLOR		"#cccccc"
    2.16 +#define STATUSBGCOLOR		"#dddddd"
    2.17 +#define STATUSFGCOLOR		"#222222"
    2.18 +
    2.19  #define MODKEY			Mod1Mask
    2.20  #define MASTERW			60 /* percent */
    2.21  
     3.1 --- a/draw.c	Fri Aug 25 07:54:49 2006 +0200
     3.2 +++ b/draw.c	Fri Aug 25 12:59:45 2006 +0200
     3.3 @@ -22,29 +22,16 @@
     3.4  }
     3.5  
     3.6  static void
     3.7 -drawtext(const char *text, Bool invert, Bool highlight)
     3.8 +drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
     3.9  {
    3.10  	int x, y, w, h;
    3.11  	static char buf[256];
    3.12  	unsigned int len, olen;
    3.13  	XGCValues gcv;
    3.14 -	XPoint points[5];
    3.15  	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
    3.16  
    3.17 -	XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
    3.18 +	XSetForeground(dpy, dc.gc, col[ColBG]);
    3.19  	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
    3.20 -	points[0].x = dc.x;
    3.21 -	points[0].y = dc.y;
    3.22 -	points[1].x = dc.w - 1;
    3.23 -	points[1].y = 0;
    3.24 -	points[2].x = 0;
    3.25 -	points[2].y = dc.h - 1;
    3.26 -	points[3].x = -(dc.w - 1);
    3.27 -	points[3].y = 0;
    3.28 -	points[4].x = 0;
    3.29 -	points[4].y = -(dc.h - 1);
    3.30 -	XSetForeground(dpy, dc.gc, dc.border);
    3.31 -	XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
    3.32  
    3.33  	if(!text)
    3.34  		return;
    3.35 @@ -74,15 +61,14 @@
    3.36  
    3.37  	if(w > dc.w)
    3.38  		return; /* too long */
    3.39 -	gcv.foreground = invert ? dc.bg : dc.fg;
    3.40 -	gcv.background = invert ? dc.fg : dc.bg;
    3.41 +	gcv.foreground = col[ColFG];
    3.42  	if(dc.font.set) {
    3.43 -		XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
    3.44 +		XChangeGC(dpy, dc.gc, GCForeground, &gcv);
    3.45  		XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
    3.46  	}
    3.47  	else {
    3.48  		gcv.font = dc.font.xfont->fid;
    3.49 -		XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
    3.50 +		XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
    3.51  		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
    3.52  	}
    3.53  	if(highlight) {
    3.54 @@ -108,21 +94,25 @@
    3.55  void
    3.56  drawstatus()
    3.57  {
    3.58 +	static const char *mode[] = { "~", "=" };
    3.59  	int i, x;
    3.60 -	Bool istile = arrange == dotile;
    3.61  
    3.62  	dc.x = dc.y = 0;
    3.63  	dc.w = bw;
    3.64 -	drawtext(NULL, !istile, False);
    3.65 +
    3.66 +	if(!modew)
    3.67 +		modew = textw(mode[0]) > textw(mode[1]) ? textw(mode[0]) : textw(mode[1]);
    3.68 +	drawtext(mode[arrange == dotile ? 1 : 0], dc.status, False);
    3.69  
    3.70  	dc.w = 0;
    3.71 +	dc.x = modew;
    3.72  	for(i = 0; i < ntags; i++) {
    3.73  		dc.x += dc.w;
    3.74  		dc.w = textw(tags[i]);
    3.75 -		if(istile)
    3.76 -			drawtext(tags[i], seltag[i], sel && sel->tags[i]);
    3.77 +		if(seltag[i])
    3.78 +			drawtext(tags[i], dc.sel, sel && sel->tags[i]);
    3.79  		else
    3.80 -			drawtext(tags[i], !seltag[i], sel && sel->tags[i]);
    3.81 +			drawtext(tags[i], dc.norm, sel && sel->tags[i]);
    3.82  	}
    3.83  	x = dc.x + dc.w;
    3.84  	dc.w = textw(stext);
    3.85 @@ -131,11 +121,11 @@
    3.86  		dc.x = x;
    3.87  		dc.w = bw - x;
    3.88  	}
    3.89 -	drawtext(stext, !istile, False);
    3.90 +	drawtext(stext, dc.status, False);
    3.91  
    3.92  	if(sel && ((dc.w = dc.x - x) > bh)) {
    3.93  		dc.x = x;
    3.94 -		drawtext(sel->name, istile, False);
    3.95 +		drawtext(sel->name, dc.sel, False);
    3.96  	}
    3.97  	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
    3.98  	XSync(dpy, False);
    3.99 @@ -145,20 +135,19 @@
   3.100  drawtitle(Client *c)
   3.101  {
   3.102  	int i;
   3.103 -	Bool istile = arrange == dotile;
   3.104  
   3.105  	if(c == sel && issel) {
   3.106  		drawstatus();
   3.107  		XUnmapWindow(dpy, c->twin);
   3.108 -		XSetWindowBorder(dpy, c->win, dc.fg);
   3.109 +		XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
   3.110  		return;
   3.111  	}
   3.112  
   3.113 -	XSetWindowBorder(dpy, c->win, dc.bg);
   3.114 +	XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
   3.115  	XMapWindow(dpy, c->twin);
   3.116  	dc.x = dc.y = 0;
   3.117  	dc.w = c->tw;
   3.118 -	drawtext(c->name, !istile, False);
   3.119 +	drawtext(c->name, dc.norm, False);
   3.120  	XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
   3.121  	XSync(dpy, False);
   3.122  }
     4.1 --- a/dwm.h	Fri Aug 25 07:54:49 2006 +0200
     4.2 +++ b/dwm.h	Fri Aug 25 12:59:45 2006 +0200
     4.3 @@ -23,6 +23,9 @@
     4.4  /* cursor */
     4.5  enum { CurNormal, CurResize, CurMove, CurLast };
     4.6  
     4.7 +/* color */
     4.8 +enum { ColFG, ColBG, ColLast };
     4.9 +
    4.10  /* window corners */
    4.11  typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
    4.12  
    4.13 @@ -36,9 +39,9 @@
    4.14  
    4.15  typedef struct { /* draw context */
    4.16  	int x, y, w, h;
    4.17 -	unsigned long bg;
    4.18 -	unsigned long fg;
    4.19 -	unsigned long border;
    4.20 +	unsigned long norm[ColLast];
    4.21 +	unsigned long sel[ColLast];
    4.22 +	unsigned long status[ColLast];
    4.23  	Drawable drawable;
    4.24  	Fnt font;
    4.25  	GC gc;
    4.26 @@ -66,7 +69,7 @@
    4.27  extern const char *tags[];
    4.28  extern char stext[1024];
    4.29  extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
    4.30 -extern unsigned int ntags, numlockmask;
    4.31 +extern unsigned int ntags, numlockmask, modew;
    4.32  extern void (*handler[LASTEvent])(XEvent *);
    4.33  extern void (*arrange)(Arg *);
    4.34  extern Atom wmatom[WMLast], netatom[NetLast];
     5.1 --- a/event.c	Fri Aug 25 07:54:49 2006 +0200
     5.2 +++ b/event.c	Fri Aug 25 12:59:45 2006 +0200
     5.3 @@ -105,7 +105,9 @@
     5.4  	XButtonPressedEvent *ev = &e->xbutton;
     5.5  
     5.6  	if(barwin == ev->window) {
     5.7 -		x = 0;
     5.8 +		if(ev->x < modew)
     5.9 +			return;
    5.10 +		x = modew;
    5.11  		for(a.i = 0; a.i < ntags; a.i++) {
    5.12  			x += textw(tags[a.i]);
    5.13  			if(ev->x < x) {
     6.1 --- a/main.c	Fri Aug 25 07:54:49 2006 +0200
     6.2 +++ b/main.c	Fri Aug 25 12:59:45 2006 +0200
     6.3 @@ -20,7 +20,7 @@
     6.4  char stext[1024];
     6.5  Bool *seltag;
     6.6  int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
     6.7 -unsigned int ntags, numlockmask;
     6.8 +unsigned int ntags, numlockmask, modew;
     6.9  Atom wmatom[WMLast], netatom[NetLast];
    6.10  Bool running = True;
    6.11  Bool issel = True;
    6.12 @@ -121,11 +121,15 @@
    6.13  	seltag[0] = True;
    6.14  
    6.15  	/* style */
    6.16 -	dc.bg = getcolor(BGCOLOR);
    6.17 -	dc.fg = getcolor(FGCOLOR);
    6.18 -	dc.border = getcolor(BORDERCOLOR);
    6.19 +	dc.norm[ColBG] = getcolor(NORMBGCOLOR);
    6.20 +	dc.norm[ColFG] = getcolor(NORMFGCOLOR);
    6.21 +	dc.sel[ColBG] = getcolor(SELBGCOLOR);
    6.22 +	dc.sel[ColFG] = getcolor(SELFGCOLOR);
    6.23 +	dc.status[ColBG] = getcolor(STATUSBGCOLOR);
    6.24 +	dc.status[ColFG] = getcolor(STATUSFGCOLOR);
    6.25  	setfont(FONT);
    6.26  
    6.27 +	modew = 0;
    6.28  	sx = sy = 0;
    6.29  	sw = DisplayWidth(dpy, screen);
    6.30  	sh = DisplayHeight(dpy, screen);
    6.31 @@ -133,7 +137,7 @@
    6.32  
    6.33  	bx = by = 0;
    6.34  	bw = sw;
    6.35 -	dc.h = bh = dc.font.height + 4;
    6.36 +	dc.h = bh = dc.font.height + 2;
    6.37  	wa.override_redirect = 1;
    6.38  	wa.background_pixmap = ParentRelative;
    6.39  	wa.event_mask = ButtonPressMask | ExposureMask;