aewl

view bar.c @ 71:7681ef838201

bar shows if currently is tiled (Mod1-space) or floating (Mod1-Shift-space) mode
author Anselm R. Garbe <garbeam@wmii.de>
date Fri, 14 Jul 2006 18:55:50 +0200
parents 50450aa24a46
children d0eb0bb63c40
line source
1 /*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
4 */
6 #include "dwm.h"
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 }
22 void
23 draw_bar()
24 {
25 int i;
26 char *mode = arrange == tiling ? "#" : "~";
28 dc.x = dc.y = 0;
29 dc.w = bw;
30 drawtext(NULL, False, False);
32 dc.w = textw(mode) + dc.font.height;
33 drawtext(mode, True, True);
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 }