dwm-meillo
diff draw.c @ 342:a1901753deef
updated man page
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Wed, 23 Aug 2006 18:50:46 +0200 |
parents | ae0affabdc02 |
children | 93192711a36a |
line diff
1.1 --- a/draw.c Wed Aug 23 14:40:44 2006 +0200 1.2 +++ b/draw.c Wed Aug 23 18:50:46 2006 +0200 1.3 @@ -22,19 +22,9 @@ 1.4 } 1.5 1.6 static void 1.7 -drawtext(const char *text, Bool invert) 1.8 +drawborder() 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 - XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); 1.20 - XSetForeground(dpy, dc.gc, dc.border); 1.21 points[0].x = dc.x; 1.22 points[0].y = dc.y; 1.23 points[1].x = dc.w - 1; 1.24 @@ -46,6 +36,23 @@ 1.25 points[4].x = 0; 1.26 points[4].y = -(dc.h - 1); 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 @@ -75,18 +82,25 @@ 1.49 1.50 if(w > dc.w) 1.51 return; /* too long */ 1.52 - 1.53 gcv.foreground = invert ? dc.bg : dc.fg; 1.54 gcv.background = invert ? dc.fg : dc.bg; 1.55 if(dc.font.set) { 1.56 XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv); 1.57 - XmbDrawImageString(dpy, dc.drawable, dc.font.set, dc.gc, 1.58 - x, y, buf, len); 1.59 + XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); 1.60 } 1.61 else { 1.62 gcv.font = dc.font.xfont->fid; 1.63 XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv); 1.64 - XDrawImageString(dpy, dc.drawable, dc.gc, x, y, buf, len); 1.65 + XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); 1.66 + } 1.67 + if(highlight) { 1.68 + tmp = dc; 1.69 + dc.x += 2; 1.70 + dc.y += 2; 1.71 + dc.w -= 4; 1.72 + dc.h -= 4; 1.73 + drawborder(); 1.74 + dc = tmp; 1.75 } 1.76 } 1.77 1.78 @@ -110,36 +124,29 @@ 1.79 1.80 dc.x = dc.y = 0; 1.81 dc.w = bw; 1.82 - drawtext(NULL, !istile); 1.83 + drawtext(NULL, !istile, False); 1.84 1.85 dc.w = 0; 1.86 for(i = 0; i < ntags; i++) { 1.87 dc.x += dc.w; 1.88 dc.w = textw(tags[i]); 1.89 if(istile) 1.90 - drawtext(tags[i], seltag[i]); 1.91 + drawtext(tags[i], seltag[i], sel && sel->tags[i]); 1.92 else 1.93 - drawtext(tags[i], !seltag[i]); 1.94 + drawtext(tags[i], !seltag[i], sel && sel->tags[i]); 1.95 } 1.96 x = dc.x + dc.w; 1.97 dc.w = textw(stext); 1.98 dc.x = bx + bw - dc.w; 1.99 - drawtext(stext, !istile); 1.100 + if(dc.x < x) { 1.101 + dc.x = x; 1.102 + dc.w = bw - x; 1.103 + } 1.104 + drawtext(stext, !istile, False); 1.105 1.106 - if(sel) { 1.107 - for(i = 0; i < ntags; i++) 1.108 - if(sel->tags[i]) { 1.109 - dc.w = textw(tags[i]); 1.110 - dc.x -= dc.w; 1.111 - if(dc.x < x) 1.112 - break; 1.113 - drawtext(tags[i], istile); 1.114 - } 1.115 - if(dc.x > x && (dc.x - x) > bh) { 1.116 - dc.w = dc.x - x; 1.117 - dc.x = x; 1.118 - drawtext(sel->name, istile); 1.119 - } 1.120 + if(sel && ((dc.w = dc.x - x) > bh)) { 1.121 + dc.x = x; 1.122 + drawtext(sel->name, istile, False); 1.123 } 1.124 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); 1.125 XSync(dpy, False); 1.126 @@ -153,26 +160,17 @@ 1.127 1.128 if(c == sel && issel) { 1.129 drawstatus(); 1.130 - XUnmapWindow(dpy, c->title); 1.131 + XUnmapWindow(dpy, c->twin); 1.132 XSetWindowBorder(dpy, c->win, dc.fg); 1.133 return; 1.134 } 1.135 1.136 XSetWindowBorder(dpy, c->win, dc.bg); 1.137 - XMapWindow(dpy, c->title); 1.138 - 1.139 - dc.y = dc.w = 0; 1.140 - dc.x = c->tw; 1.141 - for(i = 0; i < ntags; i++) 1.142 - if(c->tags[i]) { 1.143 - dc.w = textw(tags[i]); 1.144 - dc.x -= dc.w; 1.145 - drawtext(tags[i], !istile); 1.146 - } 1.147 - dc.w = dc.x; 1.148 - dc.x = 0; 1.149 - drawtext(c->name, !istile); 1.150 - XCopyArea(dpy, dc.drawable, c->title, dc.gc, 0, 0, c->tw, c->th, 0, 0); 1.151 + XMapWindow(dpy, c->twin); 1.152 + dc.x = dc.y = 0; 1.153 + dc.w = c->tw; 1.154 + drawtext(c->name, !istile, False); 1.155 + XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0); 1.156 XSync(dpy, False); 1.157 } 1.158