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.

132 lines
2.5 KiB

  1. /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
  2. * See LICENSE file for license details.
  3. */
  4. #include "dwm.h"
  5. /* static */
  6. static void
  7. togglemax(Client *c) {
  8. XEvent ev;
  9. if(c->isfixed)
  10. return;
  11. if((c->ismax = !c->ismax)) {
  12. c->rx = c->x;
  13. c->ry = c->y;
  14. c->rw = c->w;
  15. c->rh = c->h;
  16. resize(c, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
  17. }
  18. else
  19. resize(c, c->rx, c->ry, c->rw, c->rh, True);
  20. while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
  21. }
  22. /* extern */
  23. void
  24. dotile(void) {
  25. unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
  26. Client *c;
  27. for(n = 0, c = nextmanaged(clients); c; c = nextmanaged(c->next))
  28. n++;
  29. /* window geoms */
  30. mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
  31. mw = (n > nmaster) ? (waw * master) / 1000 : waw;
  32. th = (n > nmaster) ? wah / (n - nmaster) : 0;
  33. tw = waw - mw;
  34. for(i = 0, c = clients; c; c = c->next)
  35. if(isvisible(c)) {
  36. if(c->isbanned)
  37. XMoveWindow(dpy, c->win, c->x, c->y);
  38. c->isbanned = False;
  39. if(c->isfloat)
  40. continue;
  41. c->ismax = False;
  42. nx = wax;
  43. ny = way;
  44. if(i < nmaster) {
  45. ny += i * mh;
  46. nw = mw - 2 * BORDERPX;
  47. nh = mh - 2 * BORDERPX;
  48. }
  49. else { /* tile window */
  50. nx += mw;
  51. nw = tw - 2 * BORDERPX;
  52. if(th > 2 * BORDERPX) {
  53. ny += (i - nmaster) * th;
  54. nh = th - 2 * BORDERPX;
  55. }
  56. else /* fallback if th <= 2 * BORDERPX */
  57. nh = wah - 2 * BORDERPX;
  58. }
  59. resize(c, nx, ny, nw, nh, False);
  60. i++;
  61. }
  62. else {
  63. c->isbanned = True;
  64. XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
  65. }
  66. if(!sel || !isvisible(sel)) {
  67. for(c = stack; c && !isvisible(c); c = c->snext);
  68. focus(c);
  69. }
  70. restack();
  71. }
  72. void
  73. incnmaster(Arg *arg) {
  74. if((arrange == dofloat) || (nmaster + arg->i < 1)
  75. || (wah / (nmaster + arg->i) <= 2 * BORDERPX))
  76. return;
  77. nmaster += arg->i;
  78. if(sel)
  79. arrange();
  80. else
  81. drawstatus();
  82. }
  83. void
  84. resizemaster(Arg *arg) {
  85. if(arrange != dotile)
  86. return;
  87. if(arg->i == 0)
  88. master = MASTER;
  89. else {
  90. if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
  91. || waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
  92. return;
  93. master += arg->i;
  94. }
  95. arrange();
  96. }
  97. void
  98. zoom(Arg *arg) {
  99. unsigned int n;
  100. Client *c;
  101. if(!sel)
  102. return;
  103. if(sel->isfloat || (arrange == dofloat)) {
  104. togglemax(sel);
  105. return;
  106. }
  107. for(n = 0, c = nextmanaged(clients); c; c = nextmanaged(c->next))
  108. n++;
  109. if((c = sel) == nextmanaged(clients))
  110. if(!(c = nextmanaged(c->next)))
  111. return;
  112. detach(c);
  113. if(clients)
  114. clients->prev = c;
  115. c->next = clients;
  116. clients = c;
  117. focus(c);
  118. arrange();
  119. }