bstack.c 813 B

123456789101112131415161718192021222324252627282930
  1. static void
  2. bstack(Monitor *m) {
  3. int x, y, h, w, mh;
  4. unsigned int i, n;
  5. Client *c;
  6. for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
  7. if(n == 0)
  8. return;
  9. /* master */
  10. c = nexttiled(m->clients);
  11. mh = m->mfact * m->wh;
  12. resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
  13. if(--n == 0)
  14. return;
  15. /* tile stack */
  16. x = m->wx;
  17. y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
  18. w = m->ww / n;
  19. h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
  20. if(w < bh)
  21. w = m->ww;
  22. for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
  23. resize(c, x, y, /* remainder */ ((i + 1 == n)
  24. ? m->wx + m->ww - x - 2 * c->bw : w - 2 * c->bw), h - 2 * c->bw, False);
  25. if(w != m->ww)
  26. x = c->x + WIDTH(c);
  27. }
  28. }