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.

88 lines
1.5 KiB

  1. /* See LICENSE file for copyright and license details. */
  2. #include "dwm.h"
  3. #include <stdio.h>
  4. /* static */
  5. static double master = MASTER;
  6. /* extern */
  7. void
  8. incmaster(const char *arg) {
  9. double delta;
  10. if(lt->arrange != tile)
  11. return;
  12. /* arg handling, manipulate master */
  13. if(arg && (1 == sscanf(arg, "%lf", &delta))) {
  14. if(delta + master > 0.1 && delta + master < 0.9)
  15. master += delta;
  16. }
  17. lt->arrange();
  18. }
  19. void
  20. tile(void) {
  21. unsigned int i, n, nx, ny, nw, nh, mw, th;
  22. Client *c;
  23. for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
  24. n++;
  25. /* window geoms */
  26. mw = (n == 1) ? waw : master * waw;
  27. th = (n > 1) ? wah / (n - 1) : 0;
  28. if(n > 1 && th < bh)
  29. th = wah;
  30. nx = wax;
  31. ny = way;
  32. for(i = 0, c = clients; c; c = c->next)
  33. if(isvisible(c)) {
  34. unban(c);
  35. if(c->isfloating)
  36. continue;
  37. c->ismax = False;
  38. if(i == 0) { /* master */
  39. nw = mw - 2 * c->border;
  40. nh = wah - 2 * c->border;
  41. }
  42. else { /* tile window */
  43. if(i == 1) {
  44. ny = way;
  45. nx += mw;
  46. }
  47. nw = waw - mw - 2 * c->border;
  48. if(i + 1 == n) /* remainder */
  49. nh = (way + wah) - ny - 2 * c->border;
  50. else
  51. nh = th - 2 * c->border;
  52. }
  53. resize(c, nx, ny, nw, nh, False);
  54. if(n > 1 && th != wah)
  55. ny += nh + 2 * c->border;
  56. i++;
  57. }
  58. else
  59. ban(c);
  60. focus(NULL);
  61. restack();
  62. }
  63. void
  64. zoom(const char *arg) {
  65. Client *c;
  66. if(!sel || lt->arrange == floating || sel->isfloating)
  67. return;
  68. if((c = sel) == nexttiled(clients))
  69. if(!(c = nexttiled(c->next)))
  70. return;
  71. detach(c);
  72. attach(c);
  73. focus(c);
  74. lt->arrange();
  75. }