annotate bar.c @ 58:1269bd127551
made barclick to select the specific tag
author |
Anselm R. Garbe <garbeam@wmii.de> |
date |
Fri, 14 Jul 2006 10:34:07 +0200 |
parents |
f005d46462e8 |
children |
50450aa24a46 |
rev |
line source |
garbeam@57
|
1 /*
|
garbeam@57
|
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
garbeam@57
|
3 * See LICENSE file for license details.
|
garbeam@57
|
4 */
|
garbeam@57
|
5
|
garbeam@57
|
6 #include "dwm.h"
|
garbeam@57
|
7
|
garbeam@57
|
8 void
|
garbeam@58
|
9 barclick(XButtonPressedEvent *e)
|
garbeam@58
|
10 {
|
garbeam@58
|
11 int x = 0;
|
garbeam@58
|
12 Arg a;
|
garbeam@58
|
13 for(a.i = 0; a.i < TLast; a.i++) {
|
garbeam@58
|
14 x += textw(tags[a.i]) + dc.font.height;
|
garbeam@58
|
15 if(e->x < x) {
|
garbeam@58
|
16 view(&a);
|
garbeam@58
|
17 return;
|
garbeam@58
|
18 }
|
garbeam@58
|
19 }
|
garbeam@58
|
20 }
|
garbeam@58
|
21
|
garbeam@58
|
22 void
|
garbeam@57
|
23 draw_bar()
|
garbeam@57
|
24 {
|
garbeam@57
|
25 int i;
|
garbeam@57
|
26 dc.x = dc.y = 0;
|
garbeam@57
|
27 dc.w = bw;
|
garbeam@57
|
28 drawtext(NULL, False);
|
garbeam@57
|
29
|
garbeam@57
|
30 dc.w = 0;
|
garbeam@57
|
31 for(i = 0; i < TLast; i++) {
|
garbeam@57
|
32 dc.x += dc.w;
|
garbeam@57
|
33 dc.w = textw(tags[i]) + dc.font.height;
|
garbeam@57
|
34 if(i == tsel) {
|
garbeam@57
|
35 swap((void **)&dc.fg, (void **)&dc.bg);
|
garbeam@57
|
36 drawtext(tags[i], True);
|
garbeam@57
|
37 swap((void **)&dc.fg, (void **)&dc.bg);
|
garbeam@57
|
38 }
|
garbeam@57
|
39 else
|
garbeam@57
|
40 drawtext(tags[i], True);
|
garbeam@57
|
41 }
|
garbeam@57
|
42 if(sel) {
|
garbeam@57
|
43 swap((void **)&dc.fg, (void **)&dc.bg);
|
garbeam@57
|
44 dc.x += dc.w;
|
garbeam@57
|
45 dc.w = textw(sel->name) + dc.font.height;
|
garbeam@57
|
46 drawtext(sel->name, True);
|
garbeam@57
|
47 swap((void **)&dc.fg, (void **)&dc.bg);
|
garbeam@57
|
48 }
|
garbeam@57
|
49 dc.w = textw(stext) + dc.font.height;
|
garbeam@57
|
50 dc.x = bx + bw - dc.w;
|
garbeam@57
|
51 drawtext(stext, False);
|
garbeam@57
|
52 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
garbeam@57
|
53 XFlush(dpy);
|
garbeam@57
|
54 }
|