2006-07-14 15:07:38 +07:00
|
|
|
/*
|
|
|
|
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dwm.h"
|
|
|
|
|
2006-07-14 15:34:07 +07:00
|
|
|
void
|
|
|
|
barclick(XButtonPressedEvent *e)
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
Arg a;
|
|
|
|
for(a.i = 0; a.i < TLast; a.i++) {
|
|
|
|
x += textw(tags[a.i]) + dc.font.height;
|
|
|
|
if(e->x < x) {
|
|
|
|
view(&a);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-14 15:07:38 +07:00
|
|
|
void
|
|
|
|
draw_bar()
|
|
|
|
{
|
2006-07-14 23:59:25 +07:00
|
|
|
int i, modw;
|
2006-07-14 23:55:50 +07:00
|
|
|
char *mode = arrange == tiling ? "#" : "~";
|
|
|
|
|
2006-07-14 15:07:38 +07:00
|
|
|
dc.x = dc.y = 0;
|
|
|
|
dc.w = bw;
|
2006-07-14 22:43:56 +07:00
|
|
|
drawtext(NULL, False, False);
|
2006-07-14 15:07:38 +07:00
|
|
|
|
2006-07-14 23:59:25 +07:00
|
|
|
modw = textw(mode) + dc.font.height;
|
|
|
|
dc.w = 0;
|
2006-07-14 15:07:38 +07:00
|
|
|
for(i = 0; i < TLast; i++) {
|
|
|
|
dc.x += dc.w;
|
|
|
|
dc.w = textw(tags[i]) + dc.font.height;
|
2006-07-14 22:43:56 +07:00
|
|
|
drawtext(tags[i], i == tsel, True);
|
2006-07-14 15:07:38 +07:00
|
|
|
}
|
|
|
|
if(sel) {
|
|
|
|
dc.x += dc.w;
|
|
|
|
dc.w = textw(sel->name) + dc.font.height;
|
2006-07-14 22:43:56 +07:00
|
|
|
drawtext(sel->name, True, True);
|
2006-07-14 15:07:38 +07:00
|
|
|
}
|
|
|
|
dc.w = textw(stext) + dc.font.height;
|
2006-07-14 23:59:25 +07:00
|
|
|
dc.x = bx + bw - dc.w - modw;
|
2006-07-14 22:43:56 +07:00
|
|
|
drawtext(stext, False, False);
|
2006-07-14 23:59:25 +07:00
|
|
|
|
|
|
|
dc.x = bx + bw - modw;
|
|
|
|
dc.w = modw;
|
|
|
|
drawtext(mode, True, True);
|
|
|
|
|
2006-07-14 15:07:38 +07:00
|
|
|
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
|
|
|
XFlush(dpy);
|
|
|
|
}
|