commit 89d85f85d85bd279531cc678dea59fa89447dec3
Author: Aaron Duxler <[email protected]>
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
@@ -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
+@@ -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 */
+@@ -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
+@@ -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);
+@@ -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
@@ -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) <[email protected]>
-* Aaron Duxler <[email protected]> - Additional layouts bottomstack + 
centeredmaster
+* Aaron Duxler <[email protected]> - Additional layouts bottomstack + 
centeredmaster + deck
 * mss <[email protected]> - 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
@@ -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);
-@@ -2176,3 +2178,83 @@ main(int argc, char *argv[])
+@@ -2176,3 +2178,87 @@ main(int argc, char *argv[])
        XCloseDisplay(dpy);
        return EXIT_SUCCESS;
  }
@@ -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;
 +              }
 +}
 +
@@ -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
@@ -31,7 +31,7 @@ diff -up a/dwm.c b/dwm.c
  
  /* variables */
  static const char broken[] = "broken";
-@@ -2176,3 +2178,122 @@ main(int argc, char *argv[])
+@@ -2176,3 +2178,127 @@ main(int argc, char *argv[])
        XCloseDisplay(dpy);
        return EXIT_SUCCESS;
  }
@@ -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;
 +              }
 +      }
 +}
@@ -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
@@ -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);
-@@ -658,6 +659,38 @@ destroynotify(XEvent *e)
+@@ -658,6 +659,39 @@ destroynotify(XEvent *e)
  }
  
  void
@@ -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
@@ -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
 @@ -2,6 +2,7 @@
  
  /* appearance */
@@ -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
 @@ -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];
@@ -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])
-@@ -1673,26 +1693,35 @@ tagmon(const Arg *arg)
+@@ -1673,26 +1693,37 @@ tagmon(const Arg *arg)
  void
  tile(Monitor *m)
  {
@@ -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
@@ -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.
@@ -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
 ---------------


Reply via email to