dwm-meillo

diff draw.c @ 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
line diff
     1.1 --- a/draw.c	Thu Aug 24 12:07:10 2006 +0200
     1.2 +++ b/draw.c	Fri Aug 25 07:54:49 2006 +0200
     1.3 @@ -22,15 +22,16 @@
     1.4  }
     1.5  
     1.6  static void
     1.7 -drawtext(const char *text, unsigned int colidx, Bool highlight)
     1.8 +drawtext(const char *text, Bool invert, Bool highlight)
     1.9  {
    1.10  	int x, y, w, h;
    1.11  	static char buf[256];
    1.12  	unsigned int len, olen;
    1.13 +	XGCValues gcv;
    1.14  	XPoint points[5];
    1.15  	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
    1.16  
    1.17 -	XSetForeground(dpy, dc.gc, dc.bg[colidx]);
    1.18 +	XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
    1.19  	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
    1.20  	points[0].x = dc.x;
    1.21  	points[0].y = dc.y;
    1.22 @@ -42,7 +43,7 @@
    1.23  	points[3].y = 0;
    1.24  	points[4].x = 0;
    1.25  	points[4].y = -(dc.h - 1);
    1.26 -	XSetForeground(dpy, dc.gc, dc.fg[colidx]);
    1.27 +	XSetForeground(dpy, dc.gc, dc.border);
    1.28  	XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
    1.29  
    1.30  	if(!text)
    1.31 @@ -73,24 +74,22 @@
    1.32  
    1.33  	if(w > dc.w)
    1.34  		return; /* too long */
    1.35 -	if(dc.font.set)
    1.36 +	gcv.foreground = invert ? dc.bg : dc.fg;
    1.37 +	gcv.background = invert ? dc.fg : dc.bg;
    1.38 +	if(dc.font.set) {
    1.39 +		XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
    1.40  		XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
    1.41 +	}
    1.42  	else {
    1.43 -		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
    1.44 +		gcv.font = dc.font.xfont->fid;
    1.45 +		XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
    1.46  		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
    1.47  	}
    1.48  	if(highlight) {
    1.49 -		points[0].x = dc.x + 1;
    1.50 -		points[0].y = dc.y + 1;
    1.51 -		points[1].x = dc.w - 3;
    1.52 -		points[1].y = 0;
    1.53 -		points[2].x = 0;
    1.54 -		points[2].y = dc.h - 3;
    1.55 -		points[3].x = -(dc.w - 3);
    1.56 -		points[3].y = 0;
    1.57 -		points[4].x = 0;
    1.58 -		points[4].y = -(dc.h - 3);
    1.59 -		XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
    1.60 +		r.x = dc.x + 2;
    1.61 +		r.y = dc.y + 2;
    1.62 +		r.width = r.height = 3;
    1.63 +		XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
    1.64  	}
    1.65  }
    1.66  
    1.67 @@ -114,16 +113,16 @@
    1.68  
    1.69  	dc.x = dc.y = 0;
    1.70  	dc.w = bw;
    1.71 -	drawtext(NULL, istile ? 1 : 0, False);
    1.72 +	drawtext(NULL, !istile, False);
    1.73  
    1.74  	dc.w = 0;
    1.75  	for(i = 0; i < ntags; i++) {
    1.76  		dc.x += dc.w;
    1.77  		dc.w = textw(tags[i]);
    1.78  		if(istile)
    1.79 -			drawtext(tags[i], seltag[i] ? 0 : 1, sel && sel->tags[i]);
    1.80 +			drawtext(tags[i], seltag[i], sel && sel->tags[i]);
    1.81  		else
    1.82 -			drawtext(tags[i], seltag[i] ? 1 : 0, sel && sel->tags[i]);
    1.83 +			drawtext(tags[i], !seltag[i], sel && sel->tags[i]);
    1.84  	}
    1.85  	x = dc.x + dc.w;
    1.86  	dc.w = textw(stext);
    1.87 @@ -132,11 +131,11 @@
    1.88  		dc.x = x;
    1.89  		dc.w = bw - x;
    1.90  	}
    1.91 -	drawtext(stext, istile ? 1 : 0, False);
    1.92 +	drawtext(stext, !istile, False);
    1.93  
    1.94  	if(sel && ((dc.w = dc.x - x) > bh)) {
    1.95  		dc.x = x;
    1.96 -		drawtext(sel->name, istile ? 0 : 1, False);
    1.97 +		drawtext(sel->name, istile, False);
    1.98  	}
    1.99  	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
   1.100  	XSync(dpy, False);
   1.101 @@ -151,15 +150,15 @@
   1.102  	if(c == sel && issel) {
   1.103  		drawstatus();
   1.104  		XUnmapWindow(dpy, c->twin);
   1.105 -		XSetWindowBorder(dpy, c->win, dc.fg[1]);
   1.106 +		XSetWindowBorder(dpy, c->win, dc.fg);
   1.107  		return;
   1.108  	}
   1.109  
   1.110 -	XSetWindowBorder(dpy, c->win, dc.bg[0]);
   1.111 +	XSetWindowBorder(dpy, c->win, dc.bg);
   1.112  	XMapWindow(dpy, c->twin);
   1.113  	dc.x = dc.y = 0;
   1.114  	dc.w = c->tw;
   1.115 -	drawtext(c->name, istile ? 1 : 0, False);
   1.116 +	drawtext(c->name, !istile, False);
   1.117  	XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
   1.118  	XSync(dpy, False);
   1.119  }