Another copy of my dotfiles. Because I don't completely trust GitHub.
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.

180 lines
5.3 KiB

4 years ago
  1. diff -up a/config.def.h b/config.def.h
  2. --- a/config.def.h 2019-06-05 02:24:05.503321320 +0200
  3. +++ b/config.def.h 2019-06-05 10:46:48.099997829 +0200
  4. @@ -41,6 +41,8 @@ static const Layout layouts[] = {
  5. { "[]=", tile }, /* first entry is default */
  6. { "><>", NULL }, /* no layout function means floating behavior */
  7. { "[M]", monocle },
  8. + { "|M|", centeredmaster },
  9. + { ">M>", centeredfloatingmaster },
  10. };
  11. /* key definitions */
  12. @@ -79,6 +81,8 @@ static Key keys[] = {
  13. { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
  14. { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
  15. { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
  16. + { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
  17. + { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
  18. { MODKEY, XK_space, setlayout, {0} },
  19. { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
  20. { MODKEY, XK_0, view, {.ui = ~0 } },
  21. Only in a: config.def.h.orig
  22. Only in b: dwm-bottomstack-20160719-56a31dc.diff
  23. diff -up a/dwm.c b/dwm.c
  24. --- a/dwm.c 2019-06-05 02:25:40.169986187 +0200
  25. +++ b/dwm.c 2019-06-05 10:48:42.443328992 +0200
  26. @@ -235,6 +235,8 @@ static int xerror(Display *dpy, XErrorEv
  27. static int xerrordummy(Display *dpy, XErrorEvent *ee);
  28. static int xerrorstart(Display *dpy, XErrorEvent *ee);
  29. static void zoom(const Arg *arg);
  30. +static void centeredmaster(Monitor *m);
  31. +static void centeredfloatingmaster(Monitor *m);
  32. /* variables */
  33. static const char broken[] = "broken";
  34. @@ -2175,3 +2177,144 @@ main(int argc, char *argv[])
  35. XCloseDisplay(dpy);
  36. return EXIT_SUCCESS;
  37. }
  38. +
  39. +void
  40. +centeredmaster(Monitor *m)
  41. +{
  42. + unsigned int i, n, h, mw, mx, my, oty, ety, tw;
  43. + float mfacts = 0, lfacts = 0, rfacts = 0;
  44. + Client *c;
  45. +
  46. + /* count number of clients in the selected monitor */
  47. + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
  48. + if (n < m->nmaster)
  49. + mfacts += c->cfact;
  50. + else if ((n - m->nmaster) % 2)
  51. + lfacts += c->cfact;
  52. + else
  53. + rfacts += c->cfact;
  54. + }
  55. + if (n == 0)
  56. + return;
  57. + if(n == 1){
  58. + c = nexttiled(m->clients);
  59. + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
  60. + return;
  61. + }
  62. +
  63. + /* initialize areas */
  64. + mw = m->ww;
  65. + mx = 0;
  66. + my = 0;
  67. + tw = mw;
  68. +
  69. + if (n > m->nmaster) {
  70. + /* go mfact box in the center if more than nmaster clients */
  71. + mw = m->nmaster ? m->ww * m->mfact : 0;
  72. + tw = m->ww - mw;
  73. +
  74. + if (n - m->nmaster > 1) {
  75. + /* only one client */
  76. + mx = (m->ww - mw) / 2;
  77. + tw = (m->ww - mw) / 2;
  78. + }
  79. + }
  80. +
  81. + oty = 0;
  82. + ety = 0;
  83. + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  84. + if (i < m->nmaster) {
  85. + /* nmaster clients are stacked vertically, in the center
  86. + * of the screen */
  87. + h = (m->wh - my) * (c->cfact / mfacts);
  88. + resize(c, m->wx + mx, m->wy + my, mw - 2*c->bw,
  89. + h - 2*c->bw, 0);
  90. + if(my + HEIGHT(c) < m->mh)
  91. + my += HEIGHT(c);
  92. + mfacts -= c->cfact;
  93. + } else {
  94. + /* stack clients are stacked vertically */
  95. + if ((i - m->nmaster) % 2) {
  96. + h = (m->wh - ety) * (c->cfact / lfacts);
  97. + if(m->nmaster == 0)
  98. + resize(c, m->wx, m->wy + ety, tw - 2*c->bw,
  99. + h - 2*c->bw, 0);
  100. + else
  101. + resize(c, m->wx, m->wy + ety, tw - 2*c->bw,
  102. + h - 2*c->bw, 0);
  103. + if(ety + HEIGHT(c) < m->mh)
  104. + ety += HEIGHT(c);
  105. + lfacts -= c->cfact;
  106. + } else {
  107. + h = (m->wh - oty) * (c->cfact / rfacts);
  108. + resize(c, m->wx + mx + mw, m->wy + oty,
  109. + tw - 2*c->bw, h - 2*c->bw, 0);
  110. + if(oty + HEIGHT(c) < m->mh)
  111. + oty += HEIGHT(c);
  112. + rfacts -= c->cfact;
  113. + }
  114. + }
  115. +}
  116. +
  117. +void
  118. +centeredfloatingmaster(Monitor *m)
  119. +{
  120. + unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx;
  121. + float mfacts = 0, sfacts = 0;
  122. + Client *c;
  123. +
  124. + /* count number of clients in the selected monitor */
  125. + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
  126. + if (n < m->nmaster)
  127. + mfacts += c->cfact;
  128. + else
  129. + sfacts += c->cfact;
  130. + }
  131. + if (n == 0)
  132. + return;
  133. + if(n == 1){
  134. + c = nexttiled(m->clients);
  135. + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
  136. + return;
  137. + }
  138. +
  139. + /* initialize nmaster area */
  140. + if (n > m->nmaster) {
  141. + /* go mfact box in the center if more than nmaster clients */
  142. + if (m->ww > m->wh) {
  143. + mw = m->nmaster ? m->ww * m->mfact : 0;
  144. + mh = m->nmaster ? m->wh * 0.9 : 0;
  145. + } else {
  146. + mh = m->nmaster ? m->wh * m->mfact : 0;
  147. + mw = m->nmaster ? m->ww * 0.9 : 0;
  148. + }
  149. + mx = mxo = (m->ww - mw) / 2;
  150. + my = myo = (m->wh - mh) / 2;
  151. + } else {
  152. + /* go fullscreen if all clients are in the master area */
  153. + mh = m->wh;
  154. + mw = m->ww;
  155. + mx = mxo = 0;
  156. + my = myo = 0;
  157. + }
  158. +
  159. + for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  160. + if (i < m->nmaster) {
  161. + /* nmaster clients are stacked horizontally, in the center
  162. + * of the screen */
  163. + w = (mw + mxo - mx) * (c->cfact / mfacts);
  164. + resize(c, m->wx + mx, m->wy + my, w - 2*c->bw,
  165. + mh - 2*c->bw, 0);
  166. + if(mx + WIDTH(c) < m->mw)
  167. + mx += WIDTH(c);
  168. + mfacts -= c->cfact;
  169. + } else {
  170. + /* stack clients are stacked horizontally */
  171. + w = (m->ww - tx) * (c->cfact / sfacts);
  172. + resize(c, m->wx + tx, m->wy, w - 2*c->bw,
  173. + m->wh - 2*c->bw, 0);
  174. + if(tx + WIDTH(c) < m->mw)
  175. + tx += WIDTH(c);
  176. + sfacts -= c->cfact;
  177. + }
  178. +}