dwm-gridmode-20170909-ceac8c9.diff 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From b04bb473cf9818277d33a591f7fe2dfae96afaaf Mon Sep 17 00:00:00 2001
  2. From: Joshua Haase <hahj87@gmail.com>
  3. Date: Mon, 15 Aug 2016 17:06:18 -0500
  4. Subject: [PATCH] Apply modified gridmode patch.
  5. ---
  6. config.def.h | 3 +++
  7. layouts.c | 27 +++++++++++++++++++++++++++
  8. 2 files changed, 30 insertions(+)
  9. create mode 100644 layouts.c
  10. diff --git a/config.def.h b/config.def.h
  11. index a9ac303..30b7c4a 100644
  12. --- a/config.def.h
  13. +++ b/config.def.h
  14. @@ -36,11 +36,13 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95]
  15. static const int nmaster = 1; /* number of clients in master area */
  16. static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
  17. +#include "layouts.c"
  18. static const Layout layouts[] = {
  19. /* symbol arrange function */
  20. { "[]=", tile }, /* first entry is default */
  21. { "><>", NULL }, /* no layout function means floating behavior */
  22. { "[M]", monocle },
  23. + { "HHH", grid },
  24. };
  25. /* key definitions */
  26. @@ -76,6 +78,7 @@ static Key keys[] = {
  27. { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
  28. { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
  29. { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
  30. + { MODKEY, XK_g, setlayout, {.v = &layouts[3]} },
  31. { MODKEY, XK_space, setlayout, {0} },
  32. { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
  33. { MODKEY, XK_0, view, {.ui = ~0 } },
  34. diff --git a/layouts.c b/layouts.c
  35. new file mode 100644
  36. index 0000000..d26acf3
  37. --- /dev/null
  38. +++ b/layouts.c
  39. @@ -0,0 +1,27 @@
  40. +void
  41. +grid(Monitor *m) {
  42. + unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows;
  43. + Client *c;
  44. +
  45. + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next))
  46. + n++;
  47. +
  48. + /* grid dimensions */
  49. + for(rows = 0; rows <= n/2; rows++)
  50. + if(rows*rows >= n)
  51. + break;
  52. + cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
  53. +
  54. + /* window geoms (cell height/width) */
  55. + ch = m->wh / (rows ? rows : 1);
  56. + cw = m->ww / (cols ? cols : 1);
  57. + for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
  58. + cx = m->wx + (i / rows) * cw;
  59. + cy = m->wy + (i % rows) * ch;
  60. + /* adjust height/width of last row/column's windows */
  61. + ah = ((i + 1) % rows == 0) ? m->wh - ch * rows : 0;
  62. + aw = (i >= rows * (cols - 1)) ? m->ww - cw * cols : 0;
  63. + resize(c, cx, cy, cw - 2 * c->bw + aw, ch - 2 * c->bw + ah, False);
  64. + i++;
  65. + }
  66. +}
  67. --
  68. 2.14.1