Configuration file for DWM on MacBook Air
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.

103 lines
1.9 KiB

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