X-Git-Url: https://git.xinqibao.xyz/dwm.git/blobdiff_plain/9cd686c93a80b4095d4ee0960bef320ccd9ea02c..91a1f6926e2594156219c1caaf4729c5d86498a5:/bar.c diff --git a/bar.c b/bar.c index 9914e56..3027bc2 100644 --- a/bar.c +++ b/bar.c @@ -5,36 +5,50 @@ #include "dwm.h" +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; + } + } +} + void draw_bar() { - int i; + int i, modw; + char *mode = arrange == tiling ? "#" : "~"; + dc.x = dc.y = 0; dc.w = bw; - drawtext(NULL, False); + drawtext(NULL, False, False); + modw = textw(mode) + dc.font.height; dc.w = 0; for(i = 0; i < TLast; i++) { dc.x += dc.w; dc.w = textw(tags[i]) + dc.font.height; - if(i == tsel) { - swap((void **)&dc.fg, (void **)&dc.bg); - drawtext(tags[i], True); - swap((void **)&dc.fg, (void **)&dc.bg); - } - else - drawtext(tags[i], True); + drawtext(tags[i], i == tsel, True); } if(sel) { - swap((void **)&dc.fg, (void **)&dc.bg); dc.x += dc.w; dc.w = textw(sel->name) + dc.font.height; - drawtext(sel->name, True); - swap((void **)&dc.fg, (void **)&dc.bg); + drawtext(sel->name, True, True); } dc.w = textw(stext) + dc.font.height; - dc.x = bx + bw - dc.w; - drawtext(stext, False); + dc.x = bx + bw - dc.w - modw; + drawtext(stext, False, False); + + dc.x = bx + bw - modw; + dc.w = modw; + drawtext(mode, True, True); + XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); XFlush(dpy); }