aewl

changeset 344:93192711a36a

changing tag indicator through underline
author Anselm R. Garbe <arg@10kloc.org>
date Thu, 24 Aug 2006 09:25:10 +0200
parents 336d3a2c3f80
children 977585eb2d35
files draw.c main.c
diffstat 2 files changed, 17 insertions(+), 26 deletions(-) [+]
line diff
     1.1 --- a/draw.c	Wed Aug 23 19:05:03 2006 +0200
     1.2 +++ b/draw.c	Thu Aug 24 09:25:10 2006 +0200
     1.3 @@ -22,9 +22,17 @@
     1.4  }
     1.5  
     1.6  static void
     1.7 -drawborder()
     1.8 +drawtext(const char *text, Bool invert, Bool underline)
     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, invert ? dc.fg : dc.bg);
    1.18 +	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
    1.19  	points[0].x = dc.x;
    1.20  	points[0].y = dc.y;
    1.21  	points[1].x = dc.w - 1;
    1.22 @@ -35,24 +43,8 @@
    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.border);
    1.27  	XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
    1.28 -}
    1.29 -
    1.30 -static void
    1.31 -drawtext(const char *text, Bool invert, Bool highlight)
    1.32 -{
    1.33 -	int x, y, w, h;
    1.34 -	static char buf[256];
    1.35 -	unsigned int len, olen;
    1.36 -	DC tmp;
    1.37 -	XGCValues gcv;
    1.38 -	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
    1.39 -
    1.40 -	XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
    1.41 -	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
    1.42 -	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
    1.43 -	XSetForeground(dpy, dc.gc, dc.border);
    1.44 -	drawborder();
    1.45  
    1.46  	if(!text)
    1.47  		return;
    1.48 @@ -93,14 +85,12 @@
    1.49  		XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
    1.50  		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
    1.51  	}
    1.52 -	if(highlight) {
    1.53 -		tmp = dc;
    1.54 -		dc.x += 2;
    1.55 -		dc.y += 2;
    1.56 -		dc.w -= 4;
    1.57 -		dc.h -= 4;
    1.58 -		drawborder();
    1.59 -		dc = tmp;
    1.60 +	if(underline) {
    1.61 +		points[0].x = dc.x + (h / 2) - 1;
    1.62 +		points[0].y = dc.y + dc.h - 3;
    1.63 +		points[1].x = dc.w - h + 2;
    1.64 +		points[1].y = 0;
    1.65 +		XDrawLines(dpy, dc.drawable, dc.gc, points, 2, CoordModePrevious);
    1.66  	}
    1.67  }
    1.68  
     2.1 --- a/main.c	Wed Aug 23 19:05:03 2006 +0200
     2.2 +++ b/main.c	Thu Aug 24 09:25:10 2006 +0200
     2.3 @@ -145,6 +145,7 @@
     2.4  
     2.5  	dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
     2.6  	dc.gc = XCreateGC(dpy, root, 0, 0);
     2.7 +	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
     2.8  
     2.9  	issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
    2.10  	strcpy(stext, "dwm-"VERSION);