dwm-fullgaps-20200508-7b77734.diff 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. From 7b7773458c072e4b24d6ea32d0364a8e402e4a43 Mon Sep 17 00:00:00 2001
  2. From: swy7ch <swy7ch@protonmail.com>
  3. Date: Fri, 8 May 2020 19:07:24 +0200
  4. Subject: [PATCH] [PATCH] update dwm-fullgaps patch to be used with tile layout
  5. update
  6. the recent tile layout changes in commit HEAD~1 (f09418b) broke the
  7. patch
  8. this patch adapt the new `if` statements to take gaps into account
  9. this patch also provides manpage entries for the keybindings
  10. ---
  11. config.def.h | 4 ++++
  12. dwm.1 | 10 ++++++++++
  13. dwm.c | 33 +++++++++++++++++++++++----------
  14. 3 files changed, 37 insertions(+), 10 deletions(-)
  15. diff --git a/config.def.h b/config.def.h
  16. index 1c0b587..38d2f6c 100644
  17. --- a/config.def.h
  18. +++ b/config.def.h
  19. @@ -2,6 +2,7 @@
  20. /* appearance */
  21. static const unsigned int borderpx = 1; /* border pixel of windows */
  22. +static const unsigned int gappx = 5; /* gaps between windows */
  23. static const unsigned int snap = 32; /* snap pixel */
  24. static const int showbar = 1; /* 0 means no bar */
  25. static const int topbar = 1; /* 0 means bottom bar */
  26. @@ -84,6 +85,9 @@ static Key keys[] = {
  27. { MODKEY, XK_period, focusmon, {.i = +1 } },
  28. { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
  29. { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
  30. + { MODKEY, XK_minus, setgaps, {.i = -1 } },
  31. + { MODKEY, XK_equal, setgaps, {.i = +1 } },
  32. + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
  33. TAGKEYS( XK_1, 0)
  34. TAGKEYS( XK_2, 1)
  35. TAGKEYS( XK_3, 2)
  36. diff --git a/dwm.1 b/dwm.1
  37. index 13b3729..0202d96 100644
  38. --- a/dwm.1
  39. +++ b/dwm.1
  40. @@ -140,6 +140,16 @@ View all windows with any tag.
  41. .B Mod1\-Control\-[1..n]
  42. Add/remove all windows with nth tag to/from the view.
  43. .TP
  44. +.B Mod1\--
  45. +Decrease the gaps around windows.
  46. +.TP
  47. +.B Mod1\-=
  48. +Increase the gaps around windows.
  49. +.TP
  50. +.B Mod1\-Shift-=
  51. +Reset the gaps around windows to
  52. +.BR 0 .
  53. +.TP
  54. .B Mod1\-Shift\-q
  55. Quit dwm.
  56. .SS Mouse commands
  57. diff --git a/dwm.c b/dwm.c
  58. index 9fd0286..45a58f3 100644
  59. --- a/dwm.c
  60. +++ b/dwm.c
  61. @@ -119,6 +119,7 @@ struct Monitor {
  62. int by; /* bar geometry */
  63. int mx, my, mw, mh; /* screen size */
  64. int wx, wy, ww, wh; /* window area */
  65. + int gappx; /* gaps between windows */
  66. unsigned int seltags;
  67. unsigned int sellt;
  68. unsigned int tagset[2];
  69. @@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m);
  70. static void setclientstate(Client *c, long state);
  71. static void setfocus(Client *c);
  72. static void setfullscreen(Client *c, int fullscreen);
  73. +static void setgaps(const Arg *arg);
  74. static void setlayout(const Arg *arg);
  75. static void setmfact(const Arg *arg);
  76. static void setup(void);
  77. @@ -639,6 +641,7 @@ createmon(void)
  78. m->nmaster = nmaster;
  79. m->showbar = showbar;
  80. m->topbar = topbar;
  81. + m->gappx = gappx;
  82. m->lt[0] = &layouts[0];
  83. m->lt[1] = &layouts[1 % LENGTH(layouts)];
  84. strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
  85. @@ -1498,6 +1501,16 @@ setfullscreen(Client *c, int fullscreen)
  86. }
  87. }
  88. +void
  89. +setgaps(const Arg *arg)
  90. +{
  91. + if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
  92. + selmon->gappx = 0;
  93. + else
  94. + selmon->gappx += arg->i;
  95. + arrange(selmon);
  96. +}
  97. +
  98. void
  99. setlayout(const Arg *arg)
  100. {
  101. @@ -1684,18 +1697,18 @@ tile(Monitor *m)
  102. if (n > m->nmaster)
  103. mw = m->nmaster ? m->ww * m->mfact : 0;
  104. else
  105. - mw = m->ww;
  106. - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  107. + mw = m->ww - m->gappx;
  108. + for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  109. if (i < m->nmaster) {
  110. - h = (m->wh - my) / (MIN(n, m->nmaster) - i);
  111. - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
  112. - if (my + HEIGHT(c) < m->wh)
  113. - my += HEIGHT(c);
  114. + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
  115. + resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
  116. + if (my + HEIGHT(c) + m->gappx < m->wh)
  117. + my += HEIGHT(c) + m->gappx;
  118. } else {
  119. - h = (m->wh - ty) / (n - i);
  120. - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
  121. - if (ty + HEIGHT(c) < m->wh)
  122. - ty += HEIGHT(c);
  123. + h = (m->wh - ty) / (n - i) - m->gappx;
  124. + resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
  125. + if (ty + HEIGHT(c) + m->gappx < m->wh)
  126. + ty += HEIGHT(c) + m->gappx;
  127. }
  128. }
  129. --
  130. 2.26.2