bstackhoriz.c 824 B

12345678910111213141516171819202122232425262728293031
  1. static void
  2. bstackhoriz(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;
  19. h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
  20. h /= n;
  21. if(h < bh)
  22. h = m->wh;
  23. for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
  24. resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
  25. ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
  26. if(h != m->wh)
  27. y = c->y + HEIGHT(c);
  28. }
  29. }