JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
I prefer the tiled/floating indicator on the right side
[dwm.git] / bar.c
1 /*
2  * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3  * See LICENSE file for license details.
4  */
5
6 #include "dwm.h"
7
8 void
9 barclick(XButtonPressedEvent *e)
10 {
11         int x = 0;
12         Arg a;
13         for(a.i = 0; a.i < TLast; a.i++) {
14                 x += textw(tags[a.i]) + dc.font.height;
15                 if(e->x < x) {
16                         view(&a);
17                         return;
18                 }
19         }
20 }
21
22 void
23 draw_bar()
24 {
25         int i, modw;
26         char *mode = arrange == tiling ? "#" : "~";
27
28         dc.x = dc.y = 0;
29         dc.w = bw;
30         drawtext(NULL, False, False);
31
32         modw = textw(mode) + dc.font.height;
33         dc.w = 0;
34         for(i = 0; i < TLast; i++) {
35                 dc.x += dc.w;
36                 dc.w = textw(tags[i]) + dc.font.height;
37                 drawtext(tags[i], i == tsel, True);
38         }
39         if(sel) {
40                 dc.x += dc.w;
41                 dc.w = textw(sel->name) + dc.font.height;
42                 drawtext(sel->name, True, True);
43         }
44         dc.w = textw(stext) + dc.font.height;
45         dc.x = bx + bw - dc.w - modw;
46         drawtext(stext, False, False);
47
48         dc.x = bx + bw - modw;
49         dc.w = modw;
50         drawtext(mode, True, True);
51
52         XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
53         XFlush(dpy);
54 }