Xinqi Bao's Git

bar shows if currently is tiled (Mod1-space) or floating (Mod1-Shift-space) mode
[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;
26 char *mode = arrange == tiling ? "#" : "~";
27
28 dc.x = dc.y = 0;
29 dc.w = bw;
30 drawtext(NULL, False, False);
31
32 dc.w = textw(mode) + dc.font.height;
33 drawtext(mode, True, True);
34
35 for(i = 0; i < TLast; i++) {
36 dc.x += dc.w;
37 dc.w = textw(tags[i]) + dc.font.height;
38 drawtext(tags[i], i == tsel, True);
39 }
40 if(sel) {
41 dc.x += dc.w;
42 dc.w = textw(sel->name) + dc.font.height;
43 drawtext(sel->name, True, True);
44 }
45 dc.w = textw(stext) + dc.font.height;
46 dc.x = bx + bw - dc.w;
47 drawtext(stext, False, False);
48 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
49 XFlush(dpy);
50 }