Configuration of dwm for Mac Computers
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.

102 lines
2.0 KiB

  1. /* See LICENSE file for copyright and license details. */
  2. int bx, by, bw, bh, blw, mx, my, mw, mh, tx, ty, tw, th, wx, wy, ww, wh;
  3. void setmfact(const char *arg);
  4. void tile(void);
  5. void tileresize(Client *c, int x, int y, int w, int h);
  6. void updatetilegeom(void);
  7. void
  8. setmfact(const char *arg) {
  9. double d;
  10. if(!arg || lt->arrange != tile)
  11. return;
  12. else {
  13. d = strtod(arg, NULL);
  14. if(arg[0] == '-' || arg[0] == '+')
  15. d += mfact;
  16. if(d < 0.1 || d > 0.9)
  17. return;
  18. mfact = d;
  19. }
  20. updatetilegeom();
  21. arrange();
  22. }
  23. void
  24. tile(void) {
  25. int x, y, h, w;
  26. unsigned int i, n;
  27. Client *c;
  28. for(n = 0, c = nextunfloating(clients); c; c = nextunfloating(c->next), n++);
  29. if(n == 0)
  30. return;
  31. /* master */
  32. c = nextunfloating(clients);
  33. if(n == 1)
  34. tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw);
  35. else
  36. tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw);
  37. if(--n == 0)
  38. return;
  39. /* tile stack */
  40. x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw;
  41. y = ty;
  42. w = (tx > c->x + c->w) ? wx + ww - x : tw;
  43. h = th / n;
  44. if(h < bh)
  45. h = th;
  46. for(i = 0, c = nextunfloating(c->next); c; c = nextunfloating(c->next), i++) {
  47. if(i + 1 == n) /* remainder */
  48. tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
  49. else
  50. tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw);
  51. if(h != th)
  52. y = c->y + c->h + 2 * c->bw;
  53. }
  54. }
  55. void
  56. tileresize(Client *c, int x, int y, int w, int h) {
  57. resize(c, x, y, w, h, resizehints);
  58. if(resizehints && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
  59. /* client doesn't accept size constraints */
  60. resize(c, x, y, w, h, False);
  61. }
  62. void
  63. zoom(const char *arg) {
  64. Client *c = sel;
  65. if(c == nextunfloating(clients))
  66. if(!c || !(c = nextunfloating(c->next)))
  67. return;
  68. if(lt->arrange == tile && !sel->isfloating) {
  69. detach(c);
  70. attach(c);
  71. focus(c);
  72. }
  73. arrange();
  74. }
  75. void
  76. updatetilegeom(void) {
  77. /* master area geometry */
  78. mx = wx;
  79. my = wy;
  80. mw = mfact * ww;
  81. mh = wh;
  82. /* tile area geometry */
  83. tx = mx + mw;
  84. ty = wy;
  85. tw = ww - mw;
  86. th = wh;
  87. }