From 127d89b4246e3743ac24c425a80733cbf3dd832a Mon Sep 17 00:00:00 2001 From: krolyxon Date: Sun, 5 Jun 2022 13:02:48 +0530 Subject: layoutscroll patch --- dwm.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'dwm.c') diff --git a/dwm.c b/dwm.c index 405b49f..331c78b 100644 --- a/dwm.c +++ b/dwm.c @@ -148,6 +148,7 @@ struct Monitor { Monitor *next; Window barwin; const Layout *lt[2]; + int ltcur; /* current layout */ Pertag *pertag; }; @@ -220,6 +221,7 @@ static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); +static void layoutscroll(const Arg *arg); static void setgaps(const Arg *arg); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); @@ -675,6 +677,7 @@ createmon(void) m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; + m->ltcur = 0; m->gappx = gappx; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; @@ -1600,6 +1603,25 @@ setgaps(const Arg *arg) arrange(selmon); } +void +layoutscroll(const Arg *arg) +{ + if (!arg || !arg->i) + return; + int switchto = selmon->ltcur + arg->i; + int l = LENGTH(layouts); + + if (switchto == l) + switchto = 0; + else if(switchto < 0) + switchto = l - 1; + + selmon->ltcur = switchto; + Arg arg2 = {.v= &layouts[switchto] }; + setlayout(&arg2); + +} + void setlayout(const Arg *arg) { -- cgit v1.2.3