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.

82 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 mwfact = MWFACT;
  6. /* extern */
  7. void
  8. addtomwfact(const char *arg) {
  9. double delta;
  10. if(isarrange(tile))
  11. return;
  12. /* arg handling, manipulate mwfact */
  13. if(arg && (1 == sscanf(arg, "%lf", &delta))) {
  14. if(delta + mwfact > 0.1 && delta + mwfact < 0.9)
  15. mwfact += delta;
  16. }
  17. 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 : mwfact * 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. if(c->isfloating)
  35. continue;
  36. c->ismax = False;
  37. if(i == 0) { /* master */
  38. nw = mw - 2 * c->border;
  39. nh = wah - 2 * c->border;
  40. }
  41. else { /* tile window */
  42. if(i == 1) {
  43. ny = way;
  44. nx += mw;
  45. }
  46. nw = waw - mw - 2 * c->border;
  47. if(i + 1 == n) /* remainder */
  48. nh = (way + wah) - ny - 2 * c->border;
  49. else
  50. nh = th - 2 * c->border;
  51. }
  52. resize(c, nx, ny, nw, nh, False);
  53. if(n > 1 && th != wah)
  54. ny += nh + 2 * c->border;
  55. i++;
  56. }
  57. }
  58. void
  59. zoom(const char *arg) {
  60. Client *c;
  61. if(!sel || !isarrange(tile) || sel->isfloating)
  62. return;
  63. if((c = sel) == nexttiled(clients))
  64. if(!(c = nexttiled(c->next)))
  65. return;
  66. detach(c);
  67. attach(c);
  68. focus(c);
  69. arrange();
  70. }