Mercurial > dwm-meillo
comparison draw.c @ 572:427708bf5f36
added a similiar patch to Daves solution to indicate if there are clients with a specific tag
author | arg@mig29 |
---|---|
date | Wed, 22 Nov 2006 14:57:09 +0100 |
parents | f0688a69f17f |
children | 601842ee4484 |
comparison
equal
deleted
inserted
replaced
571:f0688a69f17f | 572:427708bf5f36 |
---|---|
6 #include <string.h> | 6 #include <string.h> |
7 #include <X11/Xlocale.h> | 7 #include <X11/Xlocale.h> |
8 | 8 |
9 /* static */ | 9 /* static */ |
10 | 10 |
11 static Bool | |
12 isoccupied(unsigned int t) | |
13 { | |
14 Client *c; | |
15 for(c = clients; c; c = c->next) | |
16 if(c->tags[t]) | |
17 return True; | |
18 return False; | |
19 } | |
20 | |
11 static unsigned int | 21 static unsigned int |
12 textnw(const char *text, unsigned int len) { | 22 textnw(const char *text, unsigned int len) { |
13 XRectangle r; | 23 XRectangle r; |
14 | 24 |
15 if(dc.font.set) { | 25 if(dc.font.set) { |
18 } | 28 } |
19 return XTextWidth(dc.font.xfont, text, len); | 29 return XTextWidth(dc.font.xfont, text, len); |
20 } | 30 } |
21 | 31 |
22 static void | 32 static void |
23 drawtext(const char *text, unsigned long col[ColLast], Bool highlight) { | 33 drawtext(const char *text, unsigned long col[ColLast], Bool ldot, Bool rdot) { |
24 int x, y, w, h; | 34 int x, y, w, h; |
25 static char buf[256]; | 35 static char buf[256]; |
26 unsigned int len, olen; | 36 unsigned int len, olen; |
27 XGCValues gcv; | 37 XGCValues gcv; |
28 XRectangle r = { dc.x, dc.y, dc.w, dc.h }; | 38 XRectangle r = { dc.x, dc.y, dc.w, dc.h }; |
61 else { | 71 else { |
62 gcv.font = dc.font.xfont->fid; | 72 gcv.font = dc.font.xfont->fid; |
63 XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv); | 73 XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv); |
64 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); | 74 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); |
65 } | 75 } |
66 if(highlight) { | 76 if(ldot) { |
67 r.x = dc.x + 2; | 77 r.x = dc.x + 2; |
68 r.y = dc.y + 2; | 78 r.y = dc.y + 2; |
69 r.width = r.height = (h + 2) / 4; | 79 r.width = r.height = (h + 2) / 4; |
70 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | 80 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); |
71 } | 81 } |
82 if(rdot) { | |
83 r.width = r.height = (h + 2) / 4; | |
84 r.x = dc.x + dc.w - r.width - 2; | |
85 r.y = dc.y + dc.h - r.height - 2; | |
86 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | |
87 } | |
72 } | 88 } |
73 | 89 |
74 /* extern */ | 90 /* extern */ |
75 | 91 |
76 void | 92 void |
88 | 104 |
89 dc.x = dc.y = 0; | 105 dc.x = dc.y = 0; |
90 for(i = 0; i < ntags; i++) { | 106 for(i = 0; i < ntags; i++) { |
91 dc.w = textw(tags[i]); | 107 dc.w = textw(tags[i]); |
92 if(seltag[i]) | 108 if(seltag[i]) |
93 drawtext(tags[i], dc.sel, sel && sel->tags[i]); | 109 drawtext(tags[i], dc.sel, sel && sel->tags[i], isoccupied(i)); |
94 else | 110 else |
95 drawtext(tags[i], dc.norm, sel && sel->tags[i]); | 111 drawtext(tags[i], dc.norm, sel && sel->tags[i], isoccupied(i)); |
96 dc.x += dc.w; | 112 dc.x += dc.w; |
97 } | 113 } |
98 dc.w = bmw; | 114 dc.w = bmw; |
99 drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False); | 115 drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False, False); |
100 x = dc.x + dc.w; | 116 x = dc.x + dc.w; |
101 dc.w = textw(stext); | 117 dc.w = textw(stext); |
102 dc.x = bw - dc.w; | 118 dc.x = bw - dc.w; |
103 if(dc.x < x) { | 119 if(dc.x < x) { |
104 dc.x = x; | 120 dc.x = x; |
105 dc.w = bw - x; | 121 dc.w = bw - x; |
106 } | 122 } |
107 drawtext(stext, dc.status, False); | 123 drawtext(stext, dc.status, False, False); |
108 if((dc.w = dc.x - x) > bh) { | 124 if((dc.w = dc.x - x) > bh) { |
109 dc.x = x; | 125 dc.x = x; |
110 drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm, False); | 126 drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm, False, False); |
111 } | 127 } |
112 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); | 128 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); |
113 XSync(dpy, False); | 129 XSync(dpy, False); |
114 } | 130 } |
115 | 131 |
123 } | 139 } |
124 XSetWindowBorder(dpy, c->win, dc.norm[ColBG]); | 140 XSetWindowBorder(dpy, c->win, dc.norm[ColBG]); |
125 XMapWindow(dpy, c->twin); | 141 XMapWindow(dpy, c->twin); |
126 dc.x = dc.y = 0; | 142 dc.x = dc.y = 0; |
127 dc.w = c->tw; | 143 dc.w = c->tw; |
128 drawtext(c->name, dc.norm, False); | 144 drawtext(c->name, dc.norm, False,False); |
129 XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0); | 145 XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0); |
130 XSync(dpy, False); | 146 XSync(dpy, False); |
131 } | 147 } |
132 | 148 |
133 unsigned long | 149 unsigned long |