tile.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. static void tile(void)
  2. {
  3. unsigned int i, n, nx, ny, nw, nh, m, mw, mh, th;
  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. mw = n == m ? waw : screen.mfact * waw;
  10. mh = wah / m;
  11. th = n == m ? 0 : wah / (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. nw = mw;
  19. nh = (i < m - 1) ? mh : (way + wah) - ny;
  20. } else { /* tile window */
  21. if (i == m) {
  22. ny = way;
  23. nx += mw;
  24. mvvline(ny, nx, ACS_VLINE, wah);
  25. mvaddch(ny, nx, ACS_TTEE);
  26. nx++;
  27. nw = waw - mw -1;
  28. }
  29. nh = (i < n - 1) ? th : (way + wah) - ny;
  30. if (i > m)
  31. mvaddch(ny, nx - 1, ACS_LTEE);
  32. }
  33. resize(c, nx, ny, nw, nh);
  34. ny += nh;
  35. i++;
  36. }
  37. /* Fill in nmaster intersections */
  38. if (n > m) {
  39. ny = way + mh;
  40. for (i = 1; i < m; i++) {
  41. mvaddch(ny, nx - 1, ((ny - 1) % th ? ACS_RTEE : ACS_PLUS));
  42. ny += mh;
  43. }
  44. }
  45. }