dwm

[fork] dynamic window manager
Log | Files | Refs | README | LICENSE

commit 2de481c1eaa57389a7cbc4cbc0f597d2859aad80
parent 4a8db016ab56d3c0527334b1b1d1224c9e147eb4
Author: hhvn <dev@hhvn.uk>
Date:   Fri, 15 Apr 2022 19:29:34 +0100

Add focuslt() (similar to focusstack) to bring back flexible layout quantities

Diffstat:
Mconfig.h | 8+++++---
Mdwm.c | 19+++++++++++++++----
2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/config.h b/config.h @@ -39,8 +39,10 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ -static Layout layout = { tileicon, tile }; -static Layout altlayout = { monocleicon, monocle }; +static Layout layouts[] = { + { tileicon, tile }, + { monocleicon, monocle }, +}; /* key definitions */ #define MODKEY Mod4Mask @@ -72,7 +74,7 @@ static Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, - { MODKEY, XK_slash, swaplt, {0} }, + { MODKEY, XK_slash, focuslt, {.i = +1 } }, /* Tags */ TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) diff --git a/dwm.c b/dwm.c @@ -208,7 +208,7 @@ static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); //static void setgaps(const Arg *arg); -static void swaplt(const Arg *arg); +static void focuslt(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); @@ -630,7 +630,7 @@ createmon(void) m->showbar = showbar; m->topbar = topbar; m->gappx = gappx; - m->lt = &layout; + m->lt = &layouts[0]; m->pertag = ecalloc(1, sizeof(Pertag)); m->pertag->curtag = m->pertag->prevtag = 1; @@ -1537,9 +1537,20 @@ setfullscreen(Client *c, int fullscreen) } void -swaplt(const Arg *arg) +focuslt(const Arg *arg) { - selmon->lt = selmon->pertag->ltidxs[selmon->pertag->curtag] = selmon->lt == &layout ? &altlayout : &layout; + int i; + if (!arg->i || arg->i > 1 || arg->i < 0) + return; + for (i = 0; i < LENGTH(layouts); i++) + if (selmon->lt == &layouts[i]) + break; + i += arg->i; + if (i == LENGTH(layouts)) + i = 0; + else if (i < 0) + i = LENGTH(layouts) - 1; + selmon->lt = selmon->pertag->ltidxs[selmon->pertag->curtag] = &layouts[i]; if (selmon->sel) arrange(selmon); else