bstack.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. static void bstack(void)
  2. {
  3. unsigned int i, n, nx, ny, nw, nh, m, mw, mh, tw;
  4. Client *c;
  5. for (n = 0, c = nextvisible(clients); c; c = nextvisible(c->next))
  6. if (!c->minimized)
  7. n++;
  8. m = MAX(1, MIN(n, screen.nmaster));
  9. mh = n == m ? wah : screen.mfact * wah;
  10. mw = waw / m;
  11. tw = n == m ? 0 : waw / (n - m);
  12. nx = wax;
  13. ny = way;
  14. for (i = 0, c = nextvisible(clients); c; c = nextvisible(c->next)) {
  15. if (c->minimized)
  16. continue;
  17. if (i < m) { /* master */
  18. if (i > 0) {
  19. mvvline(ny, nx, ACS_VLINE, nh);
  20. mvaddch(ny, nx, ACS_TTEE);
  21. nx++;
  22. }
  23. nh = mh;
  24. nw = (i < m - 1) ? mw : (wax + waw) - nx;
  25. } else { /* tile window */
  26. if (i == m) {
  27. nx = wax;
  28. ny += mh;
  29. nh = (way + wah) - ny;
  30. }
  31. if (i > m) {
  32. mvvline(ny, nx, ACS_VLINE, nh);
  33. mvaddch(ny, nx, ACS_TTEE);
  34. nx++;
  35. }
  36. nw = (i < n - 1) ? tw : (wax + waw) - nx;
  37. }
  38. resize(c, nx, ny, nw, nh);
  39. nx += nw;
  40. i++;
  41. }
  42. /* Fill in nmaster intersections */
  43. if (n > m) {
  44. nx = wax;
  45. for (i = 0; i < m; i++) {
  46. if (i > 0) {
  47. mvaddch(ny, nx, ACS_PLUS);
  48. nx++;
  49. }
  50. nw = (i < m - 1) ? mw : (wax + waw) - nx;
  51. nx += nw;
  52. }
  53. }
  54. }