garbeam@57: /* garbeam@57: * (C)opyright MMVI Anselm R. Garbe garbeam@57: * See LICENSE file for license details. garbeam@57: */ garbeam@57: garbeam@57: #include "dwm.h" garbeam@57: garbeam@57: void garbeam@58: barclick(XButtonPressedEvent *e) garbeam@58: { garbeam@58: int x = 0; garbeam@58: Arg a; garbeam@58: for(a.i = 0; a.i < TLast; a.i++) { garbeam@58: x += textw(tags[a.i]) + dc.font.height; garbeam@58: if(e->x < x) { garbeam@58: view(&a); garbeam@58: return; garbeam@58: } garbeam@58: } garbeam@58: } garbeam@58: garbeam@58: void garbeam@57: draw_bar() garbeam@57: { garbeam@57: int i; garbeam@57: dc.x = dc.y = 0; garbeam@57: dc.w = bw; garbeam@57: drawtext(NULL, False); garbeam@57: garbeam@57: dc.w = 0; garbeam@57: for(i = 0; i < TLast; i++) { garbeam@57: dc.x += dc.w; garbeam@57: dc.w = textw(tags[i]) + dc.font.height; garbeam@57: if(i == tsel) { garbeam@57: swap((void **)&dc.fg, (void **)&dc.bg); garbeam@57: drawtext(tags[i], True); garbeam@57: swap((void **)&dc.fg, (void **)&dc.bg); garbeam@57: } garbeam@57: else garbeam@57: drawtext(tags[i], True); garbeam@57: } garbeam@57: if(sel) { garbeam@57: swap((void **)&dc.fg, (void **)&dc.bg); garbeam@57: dc.x += dc.w; garbeam@57: dc.w = textw(sel->name) + dc.font.height; garbeam@57: drawtext(sel->name, True); garbeam@57: swap((void **)&dc.fg, (void **)&dc.bg); garbeam@57: } garbeam@57: dc.w = textw(stext) + dc.font.height; garbeam@57: dc.x = bx + bw - dc.w; garbeam@57: drawtext(stext, False); garbeam@57: XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); garbeam@57: XFlush(dpy); garbeam@57: }