summaryrefslogtreecommitdiffstats
path: root/draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'draw.c')
-rw-r--r--draw.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/draw.c b/draw.c
index cee56f9..4441a88 100644
--- a/draw.c
+++ b/draw.c
@@ -8,6 +8,16 @@
8 8
9/* static */ 9/* static */
10 10
11static Bool
12isoccupied(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
11static unsigned int 21static unsigned int
12textnw(const char *text, unsigned int len) { 22textnw(const char *text, unsigned int len) {
13 XRectangle r; 23 XRectangle r;
@@ -20,7 +30,7 @@ textnw(const char *text, unsigned int len) {
20} 30}
21 31
22static void 32static void
23drawtext(const char *text, unsigned long col[ColLast], Bool highlight) { 33drawtext(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;
@@ -63,12 +73,18 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
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 */
@@ -90,13 +106,13 @@ drawstatus(void) {
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;
@@ -104,10 +120,10 @@ drawstatus(void) {
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);
@@ -125,7 +141,7 @@ drawtitle(Client *c) {
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}