Another copy of my dotfiles. Because I don't completely trust GitHub.
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.

70 lines
1.4 KiB

  1. int
  2. width_fancybar(Bar *bar, BarArg *a)
  3. {
  4. return a->w;
  5. }
  6. int
  7. draw_fancybar(Bar *bar, BarArg *a)
  8. {
  9. int ftw, mw, ew = 0, n = 0;
  10. unsigned int i;
  11. Client *c;
  12. Monitor *m = bar->mon;
  13. #if BAR_TITLE_LEFT_PAD_PATCH && BAR_TITLE_RIGHT_PAD_PATCH
  14. int x = a->x + lrpad / 2, w = a->w - lrpad;
  15. #elif BAR_TITLE_LEFT_PAD_PATCH
  16. int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
  17. #elif BAR_TITLE_RIGHT_PAD_PATCH
  18. int x = a->x, w = a->w - lrpad / 2;
  19. #else
  20. int x = a->x, w = a->w;
  21. #endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH
  22. for (c = m->clients; c; c = c->next) {
  23. if (ISVISIBLE(c))
  24. n++;
  25. }
  26. if (n > 0) {
  27. ftw = TEXTW(m->sel->name);
  28. mw = (ftw >= w || n == 1) ? 0 : (w - ftw) / (n - 1);
  29. i = 0;
  30. for (c = m->clients; c; c = c->next) {
  31. if (!ISVISIBLE(c) || c == m->sel)
  32. continue;
  33. ftw = TEXTW(c->name);
  34. if (ftw < mw)
  35. ew += (mw - ftw);
  36. else
  37. i++;
  38. }
  39. if (i > 0)
  40. mw += ew / i;
  41. for (c = m->clients; c; c = c->next) {
  42. if (!ISVISIBLE(c))
  43. continue;
  44. ftw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
  45. drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]);
  46. if (ftw > 0) /* trap special handling of 0 in drw_text */
  47. drw_text(drw, x, a->y, ftw, a->h, lrpad / 2, c->name, 0, False);
  48. drawstateindicator(c->mon, c, 1, x, a->y, ftw, a->h, 0, 0, c->isfixed);
  49. x += ftw;
  50. w -= ftw;
  51. }
  52. }
  53. return n;
  54. }
  55. int
  56. click_fancybar(Bar *bar, Arg *arg, BarArg *a)
  57. {
  58. return ClkWinTitle;
  59. }