dwm-meillo

changeset 352:5a8bdc3b37cb

back to 3 colors
author Anselm R. Garbe <arg@10kloc.org>
date Fri, 25 Aug 2006 07:54:49 +0200
parents d822b5fbe11e
children 8a06efe5b563
files config.arg.h config.default.h draw.c dwm.h main.c
diffstat 5 files changed, 35 insertions(+), 38 deletions(-) [+]
line diff
     1.1 --- a/config.arg.h	Thu Aug 24 12:07:10 2006 +0200
     1.2 +++ b/config.arg.h	Fri Aug 25 07:54:49 2006 +0200
     1.3 @@ -8,10 +8,9 @@
     1.4  
     1.5  #define DEFMODE			dotile /* dofloat */
     1.6  #define FONT			"-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
     1.7 -#define NORMBGCOLOR		"#666699"
     1.8 -#define NORMFGCOLOR		"#eeeeee"
     1.9 -#define SELBGCOLOR		"#eeeeee"
    1.10 -#define SELFGCOLOR		"#000088"
    1.11 +#define BGCOLOR			"#666699"
    1.12 +#define FGCOLOR			"#eeeeee"
    1.13 +#define BORDERCOLOR		"#9999CC"
    1.14  #define MODKEY			Mod1Mask
    1.15  #define MASTERW			60 /* percent */
    1.16  
     2.1 --- a/config.default.h	Thu Aug 24 12:07:10 2006 +0200
     2.2 +++ b/config.default.h	Fri Aug 25 07:54:49 2006 +0200
     2.3 @@ -8,10 +8,9 @@
     2.4  
     2.5  #define DEFMODE			dotile /* dofloat */
     2.6  #define FONT			"fixed"
     2.7 -#define NORMBGCOLOR		"#666699"
     2.8 -#define NORMFGCOLOR		"#eeeeee"
     2.9 -#define SELBGCOLOR		"#eeeeee"
    2.10 -#define SELFGCOLOR		"#666699"
    2.11 +#define BGCOLOR			"#666699"
    2.12 +#define FGCOLOR			"#eeeeee"
    2.13 +#define BORDERCOLOR		"#9999CC"
    2.14  #define MODKEY			Mod1Mask
    2.15  #define MASTERW			60 /* percent */
    2.16  
     3.1 --- a/draw.c	Thu Aug 24 12:07:10 2006 +0200
     3.2 +++ b/draw.c	Fri Aug 25 07:54:49 2006 +0200
     3.3 @@ -22,15 +22,16 @@
     3.4  }
     3.5  
     3.6  static void
     3.7 -drawtext(const char *text, unsigned int colidx, Bool highlight)
     3.8 +drawtext(const char *text, Bool invert, 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, dc.bg[colidx]);
    3.18 +	XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
    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 @@ -42,7 +43,7 @@
    3.23  	points[3].y = 0;
    3.24  	points[4].x = 0;
    3.25  	points[4].y = -(dc.h - 1);
    3.26 -	XSetForeground(dpy, dc.gc, dc.fg[colidx]);
    3.27 +	XSetForeground(dpy, dc.gc, dc.border);
    3.28  	XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
    3.29  
    3.30  	if(!text)
    3.31 @@ -73,24 +74,22 @@
    3.32  
    3.33  	if(w > dc.w)
    3.34  		return; /* too long */
    3.35 -	if(dc.font.set)
    3.36 +	gcv.foreground = invert ? dc.bg : dc.fg;
    3.37 +	gcv.background = invert ? dc.fg : dc.bg;
    3.38 +	if(dc.font.set) {
    3.39 +		XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
    3.40  		XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
    3.41 +	}
    3.42  	else {
    3.43 -		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
    3.44 +		gcv.font = dc.font.xfont->fid;
    3.45 +		XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
    3.46  		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
    3.47  	}
    3.48  	if(highlight) {
    3.49 -		points[0].x = dc.x + 1;
    3.50 -		points[0].y = dc.y + 1;
    3.51 -		points[1].x = dc.w - 3;
    3.52 -		points[1].y = 0;
    3.53 -		points[2].x = 0;
    3.54 -		points[2].y = dc.h - 3;
    3.55 -		points[3].x = -(dc.w - 3);
    3.56 -		points[3].y = 0;
    3.57 -		points[4].x = 0;
    3.58 -		points[4].y = -(dc.h - 3);
    3.59 -		XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
    3.60 +		r.x = dc.x + 2;
    3.61 +		r.y = dc.y + 2;
    3.62 +		r.width = r.height = 3;
    3.63 +		XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
    3.64  	}
    3.65  }
    3.66  
    3.67 @@ -114,16 +113,16 @@
    3.68  
    3.69  	dc.x = dc.y = 0;
    3.70  	dc.w = bw;
    3.71 -	drawtext(NULL, istile ? 1 : 0, False);
    3.72 +	drawtext(NULL, !istile, False);
    3.73  
    3.74  	dc.w = 0;
    3.75  	for(i = 0; i < ntags; i++) {
    3.76  		dc.x += dc.w;
    3.77  		dc.w = textw(tags[i]);
    3.78  		if(istile)
    3.79 -			drawtext(tags[i], seltag[i] ? 0 : 1, sel && sel->tags[i]);
    3.80 +			drawtext(tags[i], seltag[i], sel && sel->tags[i]);
    3.81  		else
    3.82 -			drawtext(tags[i], seltag[i] ? 1 : 0, sel && sel->tags[i]);
    3.83 +			drawtext(tags[i], !seltag[i], sel && sel->tags[i]);
    3.84  	}
    3.85  	x = dc.x + dc.w;
    3.86  	dc.w = textw(stext);
    3.87 @@ -132,11 +131,11 @@
    3.88  		dc.x = x;
    3.89  		dc.w = bw - x;
    3.90  	}
    3.91 -	drawtext(stext, istile ? 1 : 0, False);
    3.92 +	drawtext(stext, !istile, False);
    3.93  
    3.94  	if(sel && ((dc.w = dc.x - x) > bh)) {
    3.95  		dc.x = x;
    3.96 -		drawtext(sel->name, istile ? 0 : 1, False);
    3.97 +		drawtext(sel->name, istile, False);
    3.98  	}
    3.99  	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
   3.100  	XSync(dpy, False);
   3.101 @@ -151,15 +150,15 @@
   3.102  	if(c == sel && issel) {
   3.103  		drawstatus();
   3.104  		XUnmapWindow(dpy, c->twin);
   3.105 -		XSetWindowBorder(dpy, c->win, dc.fg[1]);
   3.106 +		XSetWindowBorder(dpy, c->win, dc.fg);
   3.107  		return;
   3.108  	}
   3.109  
   3.110 -	XSetWindowBorder(dpy, c->win, dc.bg[0]);
   3.111 +	XSetWindowBorder(dpy, c->win, dc.bg);
   3.112  	XMapWindow(dpy, c->twin);
   3.113  	dc.x = dc.y = 0;
   3.114  	dc.w = c->tw;
   3.115 -	drawtext(c->name, istile ? 1 : 0, False);
   3.116 +	drawtext(c->name, !istile, False);
   3.117  	XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
   3.118  	XSync(dpy, False);
   3.119  }
     4.1 --- a/dwm.h	Thu Aug 24 12:07:10 2006 +0200
     4.2 +++ b/dwm.h	Fri Aug 25 07:54:49 2006 +0200
     4.3 @@ -36,8 +36,9 @@
     4.4  
     4.5  typedef struct { /* draw context */
     4.6  	int x, y, w, h;
     4.7 -	unsigned long bg[2];
     4.8 -	unsigned long fg[2];
     4.9 +	unsigned long bg;
    4.10 +	unsigned long fg;
    4.11 +	unsigned long border;
    4.12  	Drawable drawable;
    4.13  	Fnt font;
    4.14  	GC gc;
     5.1 --- a/main.c	Thu Aug 24 12:07:10 2006 +0200
     5.2 +++ b/main.c	Fri Aug 25 07:54:49 2006 +0200
     5.3 @@ -121,10 +121,9 @@
     5.4  	seltag[0] = True;
     5.5  
     5.6  	/* style */
     5.7 -	dc.bg[0] = getcolor(NORMBGCOLOR);
     5.8 -	dc.fg[0] = getcolor(NORMFGCOLOR);
     5.9 -	dc.bg[1] = getcolor(SELBGCOLOR);
    5.10 -	dc.fg[1] = getcolor(SELFGCOLOR);
    5.11 +	dc.bg = getcolor(BGCOLOR);
    5.12 +	dc.fg = getcolor(FGCOLOR);
    5.13 +	dc.border = getcolor(BORDERCOLOR);
    5.14  	setfont(FONT);
    5.15  
    5.16  	sx = sy = 0;