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.

86 lines
1.5 KiB

17 years ago
17 years ago
17 years ago
17 years ago
  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. setmwfact(const char *arg) {
  9. double delta;
  10. if(!isarrange(tile))
  11. return;
  12. /* arg handling, manipulate mwfact */
  13. if(arg == NULL)
  14. mwfact = MWFACT;
  15. else if(1 == sscanf(arg, "%lf", &delta)) {
  16. if(arg[0] != '+' && arg[0] != '-')
  17. mwfact = delta;
  18. else
  19. mwfact += delta;
  20. if(mwfact < 0.1)
  21. mwfact = 0.1;
  22. else if(mwfact > 0.9)
  23. mwfact = 0.9;
  24. }
  25. arrange();
  26. }
  27. void
  28. tile(void) {
  29. unsigned int i, n, nx, ny, nw, nh, mw, th;
  30. Client *c;
  31. for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
  32. n++;
  33. /* window geoms */
  34. mw = (n == 1) ? waw : mwfact * waw;
  35. th = (n > 1) ? wah / (n - 1) : 0;
  36. if(n > 1 && th < bh)
  37. th = wah;
  38. nx = wax;
  39. ny = way;
  40. for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) {
  41. c->ismax = False;
  42. if(i == 0) { /* master */
  43. nw = mw - 2 * c->border;
  44. nh = wah - 2 * c->border;
  45. }
  46. else { /* tile window */
  47. if(i == 1) {
  48. ny = way;
  49. nx += mw;
  50. }
  51. nw = waw - mw - 2 * c->border;
  52. if(i + 1 == n) /* remainder */
  53. nh = (way + wah) - ny - 2 * c->border;
  54. else
  55. nh = th - 2 * c->border;
  56. }
  57. resize(c, nx, ny, nw, nh, False);
  58. if(n > 1 && th != wah)
  59. ny += nh + 2 * c->border;
  60. i++;
  61. }
  62. }
  63. void
  64. zoom(const char *arg) {
  65. Client *c;
  66. if(!sel || !isarrange(tile) || 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. arrange();
  75. }