dwm-uselessgap-20211119-58414bee958f2.diff 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From 58414bee958f2e7ed91d6fe31f503ec4a406981b Mon Sep 17 00:00:00 2001
  2. From: cirala <thim@cederlund.de>
  3. Date: Fri, 19 Nov 2021 18:14:07 +0100
  4. Subject: [PATCH] Fix for dwm-uselessgap
  5. Previous versions of the patch doubles the
  6. gap between the master and slave stacks.
  7. ---
  8. config.h | 3 ++-
  9. dwm.c | 38 +++++++++++++++++++++++++++++++-------
  10. 2 files changed, 33 insertions(+), 8 deletions(-)
  11. diff --git a/config.h b/config.h
  12. index a2ac963..17a205f 100644
  13. --- a/config.h
  14. +++ b/config.h
  15. @@ -2,6 +2,7 @@
  16. /* appearance */
  17. static const unsigned int borderpx = 1; /* border pixel of windows */
  18. +static const unsigned int gappx = 6; /* gaps between windows */
  19. static const unsigned int snap = 32; /* snap pixel */
  20. static const int showbar = 1; /* 0 means no bar */
  21. static const int topbar = 1; /* 0 means bottom bar */
  22. @@ -34,7 +35,7 @@ static const Rule rules[] = {
  23. /* layout(s) */
  24. static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
  25. static const int nmaster = 1; /* number of clients in master area */
  26. -static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
  27. +static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */
  28. static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
  29. static const Layout layouts[] = {
  30. diff --git a/dwm.c b/dwm.c
  31. index 5e4d494..b626e89 100644
  32. --- a/dwm.c
  33. +++ b/dwm.c
  34. @@ -52,8 +52,8 @@
  35. #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
  36. #define LENGTH(X) (sizeof X / sizeof X[0])
  37. #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
  38. -#define WIDTH(X) ((X)->w + 2 * (X)->bw)
  39. -#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
  40. +#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
  41. +#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
  42. #define TAGMASK ((1 << LENGTH(tags)) - 1)
  43. #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
  44. @@ -1277,12 +1277,36 @@ void
  45. resizeclient(Client *c, int x, int y, int w, int h)
  46. {
  47. XWindowChanges wc;
  48. + unsigned int n;
  49. + unsigned int gapoffset;
  50. + unsigned int gapincr;
  51. + Client *nbc;
  52. - c->oldx = c->x; c->x = wc.x = x;
  53. - c->oldy = c->y; c->y = wc.y = y;
  54. - c->oldw = c->w; c->w = wc.width = w;
  55. - c->oldh = c->h; c->h = wc.height = h;
  56. wc.border_width = c->bw;
  57. +
  58. + /* Get number of clients for the client's monitor */
  59. + for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
  60. +
  61. + /* Do nothing if layout is floating */
  62. + if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
  63. + gapincr = gapoffset = 0;
  64. + } else {
  65. + /* Remove border and gap if layout is monocle or only one client */
  66. + if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
  67. + gapoffset = 0;
  68. + gapincr = -2 * borderpx;
  69. + wc.border_width = 0;
  70. + } else {
  71. + gapoffset = gappx;
  72. + gapincr = 2 * gappx;
  73. + }
  74. + }
  75. +
  76. + c->oldx = c->x; c->x = wc.x = x + gapoffset;
  77. + c->oldy = c->y; c->y = wc.y = y + gapoffset;
  78. + c->oldw = c->w; c->w = wc.width = w - gapincr;
  79. + c->oldh = c->h; c->h = wc.height = h - gapincr;
  80. +
  81. XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
  82. configure(c);
  83. XSync(dpy, False);
  84. @@ -1688,7 +1712,7 @@ tile(Monitor *m)
  85. for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  86. if (i < m->nmaster) {
  87. h = (m->wh - my) / (MIN(n, m->nmaster) - i);
  88. - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
  89. + resize(c, m->wx, m->wy + my, mw - (2*c->bw) + (n > 1 ? gappx : 0), h - (2*c->bw), 0);
  90. if (my + HEIGHT(c) < m->wh)
  91. my += HEIGHT(c);
  92. } else {
  93. --
  94. 2.33.1