dwm-fullgaps-6.2.diff 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. diff --git a/config.def.h b/config.def.h
  2. index 1c0b587..38d2f6c 100644
  3. --- a/config.def.h
  4. +++ b/config.def.h
  5. @@ -2,6 +2,7 @@
  6. /* appearance */
  7. static const unsigned int borderpx = 1; /* border pixel of windows */
  8. +static const unsigned int gappx = 5; /* gaps between windows */
  9. static const unsigned int snap = 32; /* snap pixel */
  10. static const int showbar = 1; /* 0 means no bar */
  11. static const int topbar = 1; /* 0 means bottom bar */
  12. @@ -84,6 +85,9 @@ static Key keys[] = {
  13. { MODKEY, XK_period, focusmon, {.i = +1 } },
  14. { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
  15. { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
  16. + { MODKEY, XK_minus, setgaps, {.i = -1 } },
  17. + { MODKEY, XK_equal, setgaps, {.i = +1 } },
  18. + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
  19. TAGKEYS( XK_1, 0)
  20. TAGKEYS( XK_2, 1)
  21. TAGKEYS( XK_3, 2)
  22. diff --git a/dwm.c b/dwm.c
  23. index 4465af1..4363627 100644
  24. --- a/dwm.c
  25. +++ b/dwm.c
  26. @@ -119,6 +119,7 @@ struct Monitor {
  27. int by; /* bar geometry */
  28. int mx, my, mw, mh; /* screen size */
  29. int wx, wy, ww, wh; /* window area */
  30. + int gappx; /* gaps between windows */
  31. unsigned int seltags;
  32. unsigned int sellt;
  33. unsigned int tagset[2];
  34. @@ -199,6 +200,7 @@ static void sendmon(Client *c, Monitor *m);
  35. static void setclientstate(Client *c, long state);
  36. static void setfocus(Client *c);
  37. static void setfullscreen(Client *c, int fullscreen);
  38. +static void setgaps(const Arg *arg);
  39. static void setlayout(const Arg *arg);
  40. static void setmfact(const Arg *arg);
  41. static void setup(void);
  42. @@ -638,6 +640,7 @@ createmon(void)
  43. m->nmaster = nmaster;
  44. m->showbar = showbar;
  45. m->topbar = topbar;
  46. + m->gappx = gappx;
  47. m->lt[0] = &layouts[0];
  48. m->lt[1] = &layouts[1 % LENGTH(layouts)];
  49. strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
  50. @@ -1497,6 +1500,16 @@ setfullscreen(Client *c, int fullscreen)
  51. }
  52. }
  53. +void
  54. +setgaps(const Arg *arg)
  55. +{
  56. + if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
  57. + selmon->gappx = 0;
  58. + else
  59. + selmon->gappx += arg->i;
  60. + arrange(selmon);
  61. +}
  62. +
  63. void
  64. setlayout(const Arg *arg)
  65. {
  66. @@ -1683,16 +1696,16 @@ tile(Monitor *m)
  67. if (n > m->nmaster)
  68. mw = m->nmaster ? m->ww * m->mfact : 0;
  69. else
  70. - mw = m->ww;
  71. - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  72. + mw = m->ww - m->gappx;
  73. + for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  74. if (i < m->nmaster) {
  75. - h = (m->wh - my) / (MIN(n, m->nmaster) - i);
  76. - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
  77. - my += HEIGHT(c);
  78. + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
  79. + resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
  80. + my += HEIGHT(c) + m->gappx;
  81. } else {
  82. - h = (m->wh - ty) / (n - i);
  83. - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
  84. - ty += HEIGHT(c);
  85. + h = (m->wh - ty) / (n - i) - m->gappx;
  86. + resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
  87. + ty += HEIGHT(c) + m->gappx;
  88. }
  89. }
  90. --
  91. 2.20.1