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.

154 lines
2.6 KiB

18 years ago
17 years ago
  1. /* See LICENSE file for copyright and license details. */
  2. #include "dwm.h"
  3. #include <stdlib.h>
  4. unsigned int blw = 0;
  5. Layout *lt = NULL;
  6. /* static */
  7. static unsigned int nlayouts = 0;
  8. LAYOUTS
  9. /* extern */
  10. void
  11. floating(void) {
  12. Client *c;
  13. if(lt->arrange != floating)
  14. return;
  15. for(c = clients; c; c = c->next)
  16. if(isvisible(c)) {
  17. unban(c);
  18. resize(c, c->x, c->y, c->w, c->h, True);
  19. }
  20. else
  21. ban(c);
  22. focus(NULL);
  23. restack();
  24. }
  25. void
  26. focusclient(const char *arg) {
  27. Client *c;
  28. if(!sel || !arg)
  29. return;
  30. if(atoi(arg) < 0) {
  31. for(c = sel->prev; c && !isvisible(c); c = c->prev);
  32. if(!c) {
  33. for(c = clients; c && c->next; c = c->next);
  34. for(; c && !isvisible(c); c = c->prev);
  35. }
  36. }
  37. else {
  38. for(c = sel->next; c && !isvisible(c); c = c->next);
  39. if(!c)
  40. for(c = clients; c && !isvisible(c); c = c->next);
  41. }
  42. if(c) {
  43. focus(c);
  44. restack();
  45. }
  46. }
  47. void
  48. initlayouts(void) {
  49. unsigned int i, w;
  50. lt = &layout[0];
  51. nlayouts = sizeof layout / sizeof layout[0];
  52. for(blw = i = 0; i < nlayouts; i++) {
  53. w = textw(layout[i].symbol);
  54. if(w > blw)
  55. blw = w;
  56. }
  57. }
  58. Client *
  59. nexttiled(Client *c) {
  60. for(; c && (c->isfloating || !isvisible(c)); c = c->next);
  61. return c;
  62. }
  63. void
  64. restack(void) {
  65. Client *c;
  66. XEvent ev;
  67. XWindowChanges wc;
  68. drawstatus();
  69. if(!sel)
  70. return;
  71. if(sel->isfloating || lt->arrange == floating)
  72. XRaiseWindow(dpy, sel->win);
  73. if(lt->arrange != floating) {
  74. wc.stack_mode = Below;
  75. wc.sibling = barwin;
  76. if(!sel->isfloating) {
  77. XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
  78. wc.sibling = sel->win;
  79. }
  80. for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
  81. if(c == sel)
  82. continue;
  83. XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
  84. wc.sibling = c->win;
  85. }
  86. }
  87. XSync(dpy, False);
  88. while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
  89. }
  90. void
  91. setlayout(const char *arg) {
  92. int i;
  93. if(!arg) {
  94. lt++;
  95. if(lt == layout + nlayouts)
  96. lt = layout;
  97. }
  98. else {
  99. i = atoi(arg);
  100. if(i < 0 || i >= nlayouts)
  101. return;
  102. lt = &layout[i];
  103. }
  104. if(sel)
  105. lt->arrange();
  106. else
  107. drawstatus();
  108. }
  109. void
  110. togglebar(const char *arg) {
  111. if(bpos == BarOff)
  112. bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
  113. else
  114. bpos = BarOff;
  115. updatebarpos();
  116. lt->arrange();
  117. }
  118. void
  119. togglemax(const char *arg) {
  120. XEvent ev;
  121. if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
  122. return;
  123. if((sel->ismax = !sel->ismax)) {
  124. sel->rx = sel->x;
  125. sel->ry = sel->y;
  126. sel->rw = sel->w;
  127. sel->rh = sel->h;
  128. resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
  129. }
  130. else
  131. resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
  132. drawstatus();
  133. while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
  134. }