cyclelayouts: reimplementing patch to not require the NULL layout, addresses #331

pull/336/head
bakkeby 1 year ago
parent 954e60b735
commit f713ddee39

@ -704,9 +704,6 @@ static const Layout layouts[] = {
#if NROWGRID_LAYOUT
{ "###", nrowgrid, {0} },
#endif
#if CYCLELAYOUTS_PATCH
{ NULL, NULL, {0} },
#endif
};
#else
static const Layout layouts[] = {
@ -754,9 +751,6 @@ static const Layout layouts[] = {
#if NROWGRID_LAYOUT
{ "###", nrowgrid },
#endif
#if CYCLELAYOUTS_PATCH
{ NULL, NULL },
#endif
};
#endif // FLEXTILE_DELUXE_LAYOUT

@ -1,18 +1,10 @@
void
cyclelayout(const Arg *arg)
{
Layout *l;
for (l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++);
if (arg->i > 0) {
if (l->symbol && (l + 1)->symbol)
setlayout(&((Arg) { .v = (l + 1) }));
else
setlayout(&((Arg) { .v = layouts }));
} else {
if (l != layouts && (l - 1)->symbol)
setlayout(&((Arg) { .v = (l - 1) }));
else
setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] }));
}
}
int i;
int num_layouts = LENGTH(layouts);
for (i = 0; i < num_layouts && &layouts[i] != selmon->lt[selmon->sellt]; i++);
i += arg->i;
setlayout(&((Arg) { .v = &layouts[(i % num_layouts + num_layouts) % num_layouts] })); // modulo
}

Loading…
Cancel
Save