[wiki] [sites] [dwm][patch] ru_gaps updated layouts to prevent crash with 50+ clients || Aaron Duxler

From: <git_AT_suckless.org>
Date: Sat, 25 Apr 2020 16:07:18 +0200

commit 89d85f85d85bd279531cc678dea59fa89447dec3
Author: Aaron Duxler <aaron_AT_duxler.xyz>
Date: Sat Apr 25 16:07:13 2020 +0200

    [dwm][patch] ru_gaps updated layouts to prevent crash with 50+ clients

diff --git a/dwm.suckless.org/patches/cfacts/dwm-cfacts_deck-6.2.diff b/dwm.suckless.org/patches/cfacts/dwm-cfacts_deck-6.2.diff
new file mode 100644
index 00000000..b36e3c55
--- /dev/null
+++ b/dwm.suckless.org/patches/cfacts/dwm-cfacts_deck-6.2.diff
_AT_@ -0,0 +1,70 @@
+diff -up a/config.def.h b/config.def.h
+--- a/config.def.h 2020-04-17 13:37:50.926942626 +0200
++++ b/config.def.h 2020-04-25 15:55:19.651489583 +0200
+_AT_@ -41,6 +41,7 @@ static const Layout layouts[] = {
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "[D]", deck },
+ };
+
+ /* key definitions */
+_AT_@ -76,6 +77,7 @@ static Key keys[] = {
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
++ { MODKEY, XK_c, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+Only in b: config.def.h.orig
+Only in b: config.def.h.rej
+diff -up a/dwm.c b/dwm.c
+--- a/dwm.c 2020-04-17 13:37:50.926942626 +0200
++++ b/dwm.c 2020-04-25 15:58:19.435210980 +0200
+_AT_@ -157,6 +157,7 @@ static void configure(Client *c);
+ static void configurenotify(XEvent *e);
+ static void configurerequest(XEvent *e);
+ static Monitor *createmon(void);
++static void deck(Monitor *m);
+ static void destroynotify(XEvent *e);
+ static void detach(Client *c);
+ static void detachstack(Client *c);
+_AT_@ -655,6 +656,37 @@ destroynotify(XEvent *e)
+ }
+
+ void
++deck(Monitor *m) {
++ unsigned int i, n, h, mw, my;
++ float mfacts = 0;
++ Client *c;
++
++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
++ if (n < m->nmaster)
++ mfacts += c->cfact;
++ }
++ if(n == 0)
++ return;
++
++ if(n > m->nmaster) {
++ mw = m->nmaster ? m->ww * m->mfact : 0;
++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
++ }
++ else
++ mw = m->ww;
++ for(i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
++ if(i < m->nmaster) {
++ h = (m->wh - my) * (c->cfact / mfacts);
++ resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
++ if (my + HEIGHT(c) < m->wh)
++ my += HEIGHT(c);
++ mfacts -= c->cfact;
++ }
++ else
++ resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False);
++}
++
++void
+ detach(Client *c)
+ {
+ Client **tc;
diff --git a/dwm.suckless.org/patches/cfacts/index.md b/dwm.suckless.org/patches/cfacts/index.md
index bc0954e3..14817a57 100644
--- a/dwm.suckless.org/patches/cfacts/index.md
+++ b/dwm.suckless.org/patches/cfacts/index.md
_AT_@ -51,9 +51,10 @@ Just patch these on top of the original cfacts patch.
 
 * [dwm-cfacts\_bottomstack-6.2.diff](dwm-cfacts_bottomstack-6.2.diff)
 * [dwm-cfacts\_centeredmaster-6.2.diff](dwm-cfacts_centeredmaster-6.2.diff)
+* [dwm-cfacts\_deck-6.2.diff](dwm-cfacts_deck-6.2.diff)
 
 Author
 ------
 * Patrick Steinhardt (pks) <ps_AT_pks.im>
-* Aaron Duxler <aaron_AT_duxler.xyz> - Additional layouts bottomstack + centeredmaster
+* Aaron Duxler <aaron_AT_duxler.xyz> - Additional layouts bottomstack + centeredmaster + deck
 * mss <mss_AT_waifu.club> - dwm-6.2 port.
diff --git a/dwm.suckless.org/patches/ru_gaps/dwm-ru_bottomstack-6.2.diff b/dwm.suckless.org/patches/ru_gaps/dwm-ru_bottomstack-6.2.diff
index c722f541..6afa6750 100644
--- a/dwm.suckless.org/patches/ru_gaps/dwm-ru_bottomstack-6.2.diff
+++ b/dwm.suckless.org/patches/ru_gaps/dwm-ru_bottomstack-6.2.diff
_AT_@ -31,7 +31,7 @@ diff -up a/dwm.c b/dwm.c
  static void togglebar(const Arg *arg);
  static void togglefloating(const Arg *arg);
  static void toggletag(const Arg *arg);
-_AT_@ -2176,3 +2178,83 @@ main(int argc, char *argv[])
+_AT_@ -2176,3 +2178,87 @@ main(int argc, char *argv[])
          XCloseDisplay(dpy);
          return EXIT_SUCCESS;
  }
_AT_@ -63,14 +63,16 @@ diff -up a/dwm.c b/dwm.c
 + if (i < m->nmaster) {
 + w = (m->ww - mx) / (MIN(n, m->nmaster) - i) - m->gappx;
 + resize(c, m->wx + mx, m->wy + m->gappx, w - 2*c->bw, mh - 2*c->bw - m->gappx*(5-ns)/2, 0);
-+ mx += WIDTH(c) + m->gappx;
++ if(mx + WIDTH(c) + m->gappx < m->mw)
++ mx += WIDTH(c) + m->gappx;
 + } else {
 + w = (m->ww - tx) / (n - i) - m->gappx;
 + if(m->nmaster == 0)
 + resize(c, m->wx + tx, m->wy + mh, w - (2*c->bw), m->wh - mh - 2*c->bw - m->gappx, False);
 + else
 + resize(c, m->wx + tx, m->wy + mh + m->gappx/ns, w - (2*c->bw), m->wh - mh - 2*c->bw - m->gappx*(5-ns)/2, False);
-+ tx += WIDTH(c) + m->gappx;
++ if (tx + WIDTH(c) + m->gappx < m->mw)
++ tx += WIDTH(c) + m->gappx;
 + }
 +}
 +
_AT_@ -108,10 +110,12 @@ diff -up a/dwm.c b/dwm.c
 + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
 + if (i < m->nmaster) {
 + resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0);
-+ mx += WIDTH(c) + m->gappx;
++ if(mx + WIDTH(c) + m->gappx < m->mw)
++ mx += WIDTH(c) + m->gappx;
 + } else {
 + resize(c, sx, sy, sw - (2*c->bw), sh / (n - MIN(n, m->nmaster)) - (2*c->bw), 0);
-+ sy += HEIGHT(c) + m->gappx;
++ if(sy + HEIGHT(c) + m->gappx < m->mh)
++ sy += HEIGHT(c) + m->gappx;
 + }
 + }
 +}
diff --git a/dwm.suckless.org/patches/ru_gaps/dwm-ru_centeredmaster-6.2.diff b/dwm.suckless.org/patches/ru_gaps/dwm-ru_centeredmaster-6.2.diff
index de1c1d11..6a4d5222 100644
--- a/dwm.suckless.org/patches/ru_gaps/dwm-ru_centeredmaster-6.2.diff
+++ b/dwm.suckless.org/patches/ru_gaps/dwm-ru_centeredmaster-6.2.diff
_AT_@ -31,7 +31,7 @@ diff -up a/dwm.c b/dwm.c
  
  /* variables */
  static const char broken[] = "broken";
-_AT_@ -2176,3 +2178,122 @@ main(int argc, char *argv[])
+_AT_@ -2176,3 +2178,127 @@ main(int argc, char *argv[])
          XCloseDisplay(dpy);
          return EXIT_SUCCESS;
  }
_AT_@ -85,17 +85,20 @@ diff -up a/dwm.c b/dwm.c
 + resize(c, m->wx + mx + m->gappx/2, m->wy + my, mw - 2*c->bw - m->gappx, h - 2*c->bw - m->gappx, 0);
 + else
 + resize(c, m->wx + mx + m->gappx, m->wy + my, mw - 2*c->bw - m->gappx*3/2, h - 2*c->bw - m->gappx, 0);
-+ my += HEIGHT(c) + m->gappx;
++ if(my + HEIGHT(c) + m->gappx < m->mh)
++ my += HEIGHT(c) + m->gappx;
 + } else {
 + /* stack clients are stacked vertically */
 + if ((i - m->nmaster) % 2) {
 + h = (m->wh - ety) / ( (1 + n - i) / 2);
 + resize(c, m->wx + m->gappx, m->wy + ety, tw - (2*c->bw) - m->gappx*3/2, h - 2*c->bw - m->gappx, 0);
-+ ety += HEIGHT(c) + m->gappx;
++ if(ety + HEIGHT(c) + m->gappx < m->mh)
++ ety += HEIGHT(c) + m->gappx;
 + } else {
 + h = (m->wh - oty) / ((1 + n - i) / 2);
 + resize(c, m->wx + mx + mw + m->gappx/2, m->wy + oty, tw - (2*c->bw) - m->gappx*3/2, h - 2*c->bw - m->gappx, 0);
-+ oty += HEIGHT(c) + m->gappx;
++ if(oty + HEIGHT(c) + m->gappx < m->mh)
++ oty += HEIGHT(c) + m->gappx;
 + }
 + }
 +}
_AT_@ -145,12 +148,14 @@ diff -up a/dwm.c b/dwm.c
 + w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i) + m->gappx;
 + resize(c, m->wx + mx, m->wy + my + m->gappx, w - 2*(c->bw + m->gappx),
 + mh - 2*(c->bw + m->gappx), 0);
-+ mx += WIDTH(c) + m->gappx;
++ if(mx + WIDTH(c) + m->gappx < m->mw)
++ mx += WIDTH(c) + m->gappx;
 + } else {
 + /* stack clients are stacked horizontally */
 + w = (m->ww - tx) / (n - i) + m->gappx;
 + resize(c, m->wx + tx, m->wy + m->gappx, w - 2*(c->bw + m->gappx),
 + m->wh - 2*(c->bw + m->gappx), 0);
-+ tx += WIDTH(c) + m->gappx;
++ if(tx + WIDTH(c) + m->gappx < m->mw)
++ tx += WIDTH(c) + m->gappx;
 + }
 +}
diff --git a/dwm.suckless.org/patches/ru_gaps/dwm-ru_deck-6.2.diff b/dwm.suckless.org/patches/ru_gaps/dwm-ru_deck-6.2.diff
index d78672c4..e58f8fa9 100644
--- a/dwm.suckless.org/patches/ru_gaps/dwm-ru_deck-6.2.diff
+++ b/dwm.suckless.org/patches/ru_gaps/dwm-ru_deck-6.2.diff
_AT_@ -29,7 +29,7 @@ diff -up a/dwm.c b/dwm.c
  static void destroynotify(XEvent *e);
  static void detach(Client *c);
  static void detachstack(Client *c);
-_AT_@ -658,6 +659,38 @@ destroynotify(XEvent *e)
+_AT_@ -658,6 +659,39 @@ destroynotify(XEvent *e)
  }
  
  void
_AT_@ -58,7 +58,8 @@ diff -up a/dwm.c b/dwm.c
 + if(i < m->nmaster) {
 + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
 + resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx*(5-ns)/2, h - (2*c->bw), False);
-+ my += HEIGHT(c) + m->gappx;
++ if (my + HEIGHT(c) + m->gappx < m->wh)
++ my += HEIGHT(c) + m->gappx;
 + }
 + else
 + resize(c, m->wx + mw + m->gappx/ns, m->wy + m->gappx, m->ww - mw - (2*c->bw) - m->gappx*(5-ns)/2, m->wh - (2*c->bw) - 2*m->gappx, False);
diff --git a/dwm.suckless.org/patches/ru_gaps/dwm-ru_gaps-6.2.diff b/dwm.suckless.org/patches/ru_gaps/dwm-ru_gaps-6.2.diff
index 1bd9ae0d..09a031d6 100644
--- a/dwm.suckless.org/patches/ru_gaps/dwm-ru_gaps-6.2.diff
+++ b/dwm.suckless.org/patches/ru_gaps/dwm-ru_gaps-6.2.diff
_AT_@ -1,6 +1,6 @@
 diff -up a/config.def.h b/config.def.h
---- a/config.def.h 2019-07-21 22:43:04.535873031 +0200
-+++ b/config.def.h 2019-07-24 08:48:08.038433535 +0200
+--- a/config.def.h 2020-04-17 13:37:50.926942626 +0200
++++ b/config.def.h 2020-04-25 15:24:56.722215722 +0200
 _AT_@ -2,6 +2,7 @@
  
  /* appearance */
_AT_@ -20,13 +20,13 @@ diff -up a/config.def.h b/config.def.h
          TAGKEYS( XK_2, 1)
          TAGKEYS( XK_3, 2)
 diff -up a/dwm.c b/dwm.c
---- a/dwm.c 2019-07-21 22:43:04.535873031 +0200
-+++ b/dwm.c 2019-07-24 08:50:44.989360476 +0200
+--- a/dwm.c 2020-04-17 13:37:50.926942626 +0200
++++ b/dwm.c 2020-04-25 15:29:37.664175514 +0200
 _AT_@ -119,6 +119,7 @@ struct Monitor {
          int by; /* bar geometry */
          int mx, my, mw, mh; /* screen size */
          int wx, wy, ww, wh; /* window area */
-+ int gappx; /* gaps between windows */
++ unsigend int gappx; /* gaps between windows */
          unsigned int seltags;
          unsigned int sellt;
          unsigned int tagset[2];
_AT_@ -77,7 +77,7 @@ diff -up a/dwm.c b/dwm.c
  setlayout(const Arg *arg)
  {
          if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
-_AT_@ -1673,26 +1693,35 @@ tagmon(const Arg *arg)
+_AT_@ -1673,26 +1693,37 @@ tagmon(const Arg *arg)
  void
  tile(Monitor *m)
  {
_AT_@ -113,13 +113,15 @@ diff -up a/dwm.c b/dwm.c
 - my += HEIGHT(c);
 + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
 + resize(c, m->wx + m->gappx, m->wy + my, mw - 2*c->bw - m->gappx*(5-ns)/2, h - 2*c->bw, 0);
-+ my += HEIGHT(c) + m->gappx;
++ if(my + HEIGHT(c) + m->gappx < m->wh)
++ my += HEIGHT(c) + m->gappx;
                  } else {
 - h = (m->wh - ty) / (n - i);
 - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
 - ty += HEIGHT(c);
 + h = (m->wh - ty) / (n - i) - m->gappx;
 + resize(c, m->wx + mw + m->gappx/ns, m->wy + ty, m->ww - mw - (2*c->bw) - m->gappx*(5-ns)/2, h - 2*c->bw, 0);
-+ ty += HEIGHT(c) + m->gappx;
++ if(ty + HEIGHT(c) + m->gappx < m->wh)
++ ty += HEIGHT(c) + m->gappx;
                  }
  }
diff --git a/dwm.suckless.org/patches/ru_gaps/index.md b/dwm.suckless.org/patches/ru_gaps/index.md
index f72a5707..a30ce0d2 100644
--- a/dwm.suckless.org/patches/ru_gaps/index.md
+++ b/dwm.suckless.org/patches/ru_gaps/index.md
_AT_@ -17,7 +17,7 @@ You might want to set resizehints in config.h to zero to get smooth animations w
 
 Download
 --------
-* [dwm-ru\_gaps-6.2.diff](dwm-ru_gaps-6.2.diff) - 24-07-2019
+* [dwm-ru\_gaps-6.2.diff](dwm-ru_gaps-6.2.diff) - 25-04-2020
 
 Apply the following patches on top of the previous patch to add
 additional layouts with resizeable gap support.
_AT_@ -31,13 +31,13 @@ A copy of the [gaplessgrid](../gaplessgrid/), but with resizeable gaps.
 
 A copy of the [bottomstack](../bottomstack/), but with resizeable gaps.
 The bstackhoriz function of this patch is taken from [vanitygaps](https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-vanitygaps-6.2.diff)
-* [dwm-ru\_bottomstack-6.2.diff](dwm-ru_bottomstack-6.2.diff) - 24-07-2019
+* [dwm-ru\_bottomstack-6.2.diff](dwm-ru_bottomstack-6.2.diff) - 25-04-2020
 
 A copy of the [centeredmaster](../centeredmaster/), but with resizeable gaps.
-* [dwm-ru\_centeredmaster-6.2.diff](dwm-ru_centeredmaster-6.2.diff) - 24-07-2019
+* [dwm-ru\_centeredmaster-6.2.diff](dwm-ru_centeredmaster-6.2.diff) - 25-04-2020
 
 A copy of the [deck](../deck/), but with resizeable gaps.
-* [dwm-ru\_deck-6.2.diff](dwm-ru_deck-6.2.diff) - 24-07-2019
+* [dwm-ru\_deck-6.2.diff](dwm-ru_deck-6.2.diff) - 25-04-2020
 
 Related patches
 ---------------
Received on Sat Apr 25 2020 - 16:07:18 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 25 2020 - 16:12:49 CEST