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.

104 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 y, h;
  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. y = ty;
  41. h = th / n;
  42. if(h < bh)
  43. h = th;
  44. for(i = 0, c = nextunfloating(c->next); c; c = nextunfloating(c->next), i++) {
  45. if(i + 1 == n) /* remainder */
  46. tileresize(c, tx, y, tw - 2 * c->bw, (ty + th) - y - 2 * c->bw);
  47. else
  48. tileresize(c, tx, y, tw - 2 * c->bw, h - 2 * c->bw);
  49. if(h != th)
  50. y = c->y + c->h + 2 * c->bw;
  51. }
  52. }
  53. void
  54. tileresize(Client *c, int x, int y, int w, int h) {
  55. resize(c, x, y, w, h, resizehints);
  56. if(resizehints && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
  57. /* client doesn't accept size constraints */
  58. resize(c, x, y, w, h, False);
  59. }
  60. void
  61. zoom(const char *arg) {
  62. Client *c = sel;
  63. if(c == nextunfloating(clients))
  64. if(!c || !(c = nextunfloating(c->next)))
  65. return;
  66. if(lt->arrange == tile && !sel->isfloating) {
  67. detach(c);
  68. attach(c);
  69. focus(c);
  70. }
  71. arrange();
  72. }
  73. void
  74. updatetilegeom(void) {
  75. #ifdef TILEGEOM /* define your own if you are Xinerama user */
  76. TILEGEOM
  77. #else
  78. /* master area geometry */
  79. mx = wx;
  80. my = wy;
  81. mw = mfact * ww;
  82. mh = wh;
  83. /* tile area geometry */
  84. tx = mx + mw;
  85. ty = wy;
  86. tw = ww - mw;
  87. th = wh;
  88. #endif
  89. }