summaryrefslogtreecommitdiffstats
path: root/draw.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-15 17:19:19 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-15 17:19:19 +0200
commitc09bf8da071e05e2c1d714f0d31d41fe944bc11b (patch)
tree4c9a8ff881b8102f2700b48a47a2121a29b1fadd /draw.c
parentproceeded with cleaning up, sorting functions, etc (diff)
downloaddwm-c09bf8da071e05e2c1d714f0d31d41fe944bc11b.tar.gz
dwm-c09bf8da071e05e2c1d714f0d31d41fe944bc11b.zip
sanitized other stuff
Diffstat (limited to '')
-rw-r--r--draw.c104
1 files changed, 52 insertions, 52 deletions
diff --git a/draw.c b/draw.c
index 9743ec1..1c6613f 100644
--- a/draw.c
+++ b/draw.c
@@ -29,51 +29,18 @@ drawborder(void)
29 XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); 29 XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
30} 30}
31 31
32/* extern functions */ 32static unsigned int
33 33textnw(char *text, unsigned int len)
34void
35drawall()
36{
37 Client *c;
38
39 for(c = clients; c; c = getnext(c->next))
40 drawtitle(c);
41 drawstatus();
42}
43
44void
45drawstatus()
46{ 34{
47 int i; 35 XRectangle r;
48 Bool istile = arrange == dotile; 36 if(dc.font.set) {
49 37 XmbTextExtents(dc.font.set, text, len, NULL, &r);
50 dc.x = dc.y = 0; 38 return r.width;
51 dc.w = bw;
52 drawtext(NULL, !istile, False);
53
54 dc.w = 0;
55 for(i = 0; i < TLast; i++) {
56 dc.x += dc.w;
57 dc.w = textw(tags[i]);
58 if(istile)
59 drawtext(tags[i], (i == tsel), True);
60 else
61 drawtext(tags[i], (i != tsel), True);
62 }
63 if(sel) {
64 dc.x += dc.w;
65 dc.w = textw(sel->name);
66 drawtext(sel->name, istile, True);
67 } 39 }
68 dc.w = textw(stext); 40 return XTextWidth(dc.font.xfont, text, len);
69 dc.x = bx + bw - dc.w;
70 drawtext(stext, !istile, False);
71
72 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
73 XFlush(dpy);
74} 41}
75 42
76void 43static void
77drawtext(const char *text, Bool invert, Bool border) 44drawtext(const char *text, Bool invert, Bool border)
78{ 45{
79 int x, y, w, h; 46 int x, y, w, h;
@@ -123,6 +90,50 @@ drawtext(const char *text, Bool invert, Bool border)
123 } 90 }
124} 91}
125 92
93/* extern functions */
94
95void
96drawall()
97{
98 Client *c;
99
100 for(c = clients; c; c = getnext(c->next))
101 drawtitle(c);
102 drawstatus();
103}
104
105void
106drawstatus()
107{
108 int i;
109 Bool istile = arrange == dotile;
110
111 dc.x = dc.y = 0;
112 dc.w = bw;
113 drawtext(NULL, !istile, False);
114
115 dc.w = 0;
116 for(i = 0; i < TLast; i++) {
117 dc.x += dc.w;
118 dc.w = textw(tags[i]);
119 if(istile)
120 drawtext(tags[i], (i == tsel), True);
121 else
122 drawtext(tags[i], (i != tsel), True);
123 }
124 if(sel) {
125 dc.x += dc.w;
126 dc.w = textw(sel->name);
127 drawtext(sel->name, istile, True);
128 }
129 dc.w = textw(stext);
130 dc.x = bx + bw - dc.w;
131 drawtext(stext, !istile, False);
132
133 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
134 XFlush(dpy);
135}
136
126void 137void
127drawtitle(Client *c) 138drawtitle(Client *c)
128{ 139{
@@ -219,17 +230,6 @@ setfont(const char *fontstr)
219} 230}
220 231
221unsigned int 232unsigned int
222textnw(char *text, unsigned int len)
223{
224 XRectangle r;
225 if(dc.font.set) {
226 XmbTextExtents(dc.font.set, text, len, NULL, &r);
227 return r.width;
228 }
229 return XTextWidth(dc.font.xfont, text, len);
230}
231
232unsigned int
233textw(char *text) 233textw(char *text)
234{ 234{
235 return textnw(text, strlen(text)) + dc.font.height; 235 return textnw(text, strlen(text)) + dc.font.height;