commit 8d696af2768ceeb17dcbd74cac8e910aba6ff333 parent 414a49ecbf99d3090139ff37e7403b35c9895789 Author: Miles Alan <m@milesalan.com> Date: Tue, 28 Apr 2020 20:38:08 -0500 Fix cycle layouts function to be a lot simpler and actually work Diffstat:
| M | dwm.c | | | 17 | ++++++----------- |
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/dwm.c b/dwm.c @@ -887,18 +887,13 @@ createmon(void) void cyclelayout(const Arg *arg) { - Layout *l; - for(l = (Layout *)ppcyclelayouts; l != selmon->lt[selmon->sellt]; l++); + int i; + Arg a; + + for(i = 0; i < LENGTH(ppcyclelayouts) && &ppcyclelayouts[i] != selmon->lt[selmon->sellt]; i++); if(arg->i > 0) { - if(l->symbol && (l + 1)->symbol) - setlayout(&((Arg) { .v = (l + 1) })); - else - setlayout(&((Arg) { .v = ppcyclelayouts })); - } else { - if(l != ppcyclelayouts && (l - 1)->symbol) - setlayout(&((Arg) { .v = (l - 1) })); - else - setlayout(&((Arg) { .v = &ppcyclelayouts[LENGTH(ppcyclelayouts) - 2] })); + a.v = &ppcyclelayouts[i + 1 < LENGTH(ppcyclelayouts) ? i + 1 : 0]; + setlayout(&a); } }