You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.0 KiB

  1. /*
  2. * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
  3. * See LICENSE file for license details.
  4. */
  5. #include "dwm.h"
  6. void
  7. barclick(XButtonPressedEvent *e)
  8. {
  9. int x = 0;
  10. Arg a;
  11. for(a.i = 0; a.i < TLast; a.i++) {
  12. x += textw(tags[a.i]) + dc.font.height;
  13. if(e->x < x) {
  14. view(&a);
  15. return;
  16. }
  17. }
  18. }
  19. void
  20. draw_bar()
  21. {
  22. int i;
  23. dc.x = dc.y = 0;
  24. dc.w = bw;
  25. drawtext(NULL, False);
  26. dc.w = 0;
  27. for(i = 0; i < TLast; i++) {
  28. dc.x += dc.w;
  29. dc.w = textw(tags[i]) + dc.font.height;
  30. if(i == tsel) {
  31. swap((void **)&dc.fg, (void **)&dc.bg);
  32. drawtext(tags[i], True);
  33. swap((void **)&dc.fg, (void **)&dc.bg);
  34. }
  35. else
  36. drawtext(tags[i], True);
  37. }
  38. if(sel) {
  39. swap((void **)&dc.fg, (void **)&dc.bg);
  40. dc.x += dc.w;
  41. dc.w = textw(sel->name) + dc.font.height;
  42. drawtext(sel->name, True);
  43. swap((void **)&dc.fg, (void **)&dc.bg);
  44. }
  45. dc.w = textw(stext) + dc.font.height;
  46. dc.x = bx + bw - dc.w;
  47. drawtext(stext, False);
  48. XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
  49. XFlush(dpy);
  50. }