From bd4ebce470952a0be2ffeaaaf33f7592a3a07c54 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 13 Nov 2021 02:29:39 +0500 Subject: [PATCH] Make code made by pertag patch more readable --- dwm.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/dwm.c b/dwm.c index fb5f2e9..a9dbfb6 100644 --- a/dwm.c +++ b/dwm.c @@ -1788,15 +1788,27 @@ setfullscreen(Client *c, int fullscreen) void setlayout(const Arg *arg) { - if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) + if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) { selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1; - if (arg && arg->v) - selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v; - strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); - if (selmon->sel) + } + + if (arg && arg->v) { + const Layout *const new_layout = arg->v; + selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = new_layout; + selmon->lt[selmon->sellt] = new_layout; + } + + strncpy( + selmon->ltsymbol, + selmon->lt[selmon->sellt]->symbol, + sizeof(selmon->ltsymbol) + ); + + if (selmon->sel) { arrange(selmon); - else + } else { drawbar(selmon); + } } /* arg > 1.0 will set mfact absolutely */