dwm-meillo

diff draw.c @ 77:38c8f7f7d401

sanitized other stuff
author Anselm R. Garbe <garbeam@wmii.de>
date Sat, 15 Jul 2006 17:19:19 +0200
parents 4bd49f404f10
children aabebd6e61f3
line diff
     1.1 --- a/draw.c	Sat Jul 15 17:00:56 2006 +0200
     1.2 +++ b/draw.c	Sat Jul 15 17:19:19 2006 +0200
     1.3 @@ -29,51 +29,18 @@
     1.4  	XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
     1.5  }
     1.6  
     1.7 -/* extern functions */
     1.8 -
     1.9 -void
    1.10 -drawall()
    1.11 +static unsigned int
    1.12 +textnw(char *text, unsigned int len)
    1.13  {
    1.14 -	Client *c;
    1.15 -
    1.16 -	for(c = clients; c; c = getnext(c->next))
    1.17 -		drawtitle(c);
    1.18 -	drawstatus();
    1.19 +	XRectangle r;
    1.20 +	if(dc.font.set) {
    1.21 +		XmbTextExtents(dc.font.set, text, len, NULL, &r);
    1.22 +		return r.width;
    1.23 +	}
    1.24 +	return XTextWidth(dc.font.xfont, text, len);
    1.25  }
    1.26  
    1.27 -void
    1.28 -drawstatus()
    1.29 -{
    1.30 -	int i;
    1.31 -	Bool istile = arrange == dotile;
    1.32 -
    1.33 -	dc.x = dc.y = 0;
    1.34 -	dc.w = bw;
    1.35 -	drawtext(NULL, !istile, False);
    1.36 -
    1.37 -	dc.w = 0;
    1.38 -	for(i = 0; i < TLast; i++) {
    1.39 -		dc.x += dc.w;
    1.40 -		dc.w = textw(tags[i]);
    1.41 -		if(istile)
    1.42 -			drawtext(tags[i], (i == tsel), True);
    1.43 -		else
    1.44 -			drawtext(tags[i], (i != tsel), True);
    1.45 -	}
    1.46 -	if(sel) {
    1.47 -		dc.x += dc.w;
    1.48 -		dc.w = textw(sel->name);
    1.49 -		drawtext(sel->name, istile, True);
    1.50 -	}
    1.51 -	dc.w = textw(stext);
    1.52 -	dc.x = bx + bw - dc.w;
    1.53 -	drawtext(stext, !istile, False);
    1.54 -
    1.55 -	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
    1.56 -	XFlush(dpy);
    1.57 -}
    1.58 -
    1.59 -void
    1.60 +static void
    1.61  drawtext(const char *text, Bool invert, Bool border)
    1.62  {
    1.63  	int x, y, w, h;
    1.64 @@ -123,6 +90,50 @@
    1.65  	}
    1.66  }
    1.67  
    1.68 +/* extern functions */
    1.69 +
    1.70 +void
    1.71 +drawall()
    1.72 +{
    1.73 +	Client *c;
    1.74 +
    1.75 +	for(c = clients; c; c = getnext(c->next))
    1.76 +		drawtitle(c);
    1.77 +	drawstatus();
    1.78 +}
    1.79 +
    1.80 +void
    1.81 +drawstatus()
    1.82 +{
    1.83 +	int i;
    1.84 +	Bool istile = arrange == dotile;
    1.85 +
    1.86 +	dc.x = dc.y = 0;
    1.87 +	dc.w = bw;
    1.88 +	drawtext(NULL, !istile, False);
    1.89 +
    1.90 +	dc.w = 0;
    1.91 +	for(i = 0; i < TLast; i++) {
    1.92 +		dc.x += dc.w;
    1.93 +		dc.w = textw(tags[i]);
    1.94 +		if(istile)
    1.95 +			drawtext(tags[i], (i == tsel), True);
    1.96 +		else
    1.97 +			drawtext(tags[i], (i != tsel), True);
    1.98 +	}
    1.99 +	if(sel) {
   1.100 +		dc.x += dc.w;
   1.101 +		dc.w = textw(sel->name);
   1.102 +		drawtext(sel->name, istile, True);
   1.103 +	}
   1.104 +	dc.w = textw(stext);
   1.105 +	dc.x = bx + bw - dc.w;
   1.106 +	drawtext(stext, !istile, False);
   1.107 +
   1.108 +	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
   1.109 +	XFlush(dpy);
   1.110 +}
   1.111 +
   1.112  void
   1.113  drawtitle(Client *c)
   1.114  {
   1.115 @@ -219,17 +230,6 @@
   1.116  }
   1.117  
   1.118  unsigned int
   1.119 -textnw(char *text, unsigned int len)
   1.120 -{
   1.121 -	XRectangle r;
   1.122 -	if(dc.font.set) {
   1.123 -		XmbTextExtents(dc.font.set, text, len, NULL, &r);
   1.124 -		return r.width;
   1.125 -	}
   1.126 -	return XTextWidth(dc.font.xfont, text, len);
   1.127 -}
   1.128 -
   1.129 -unsigned int
   1.130  textw(char *text)
   1.131  {
   1.132  	return textnw(text, strlen(text)) + dc.font.height;