cyclelayouts patch

- Apply cyclelayouts patch
- Add patch link to README
- Add new layout cycling keybindings to man page
This commit is contained in:
Sravan Balaji
2020-08-30 13:51:19 -04:00
parent bfa185fac4
commit 7d5b1b38a2
4 changed files with 28 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ and (re)compiling the source code.
* [autostart](https://dwm.suckless.org/patches/autostart/)
* [centeredmaster](https://dwm.suckless.org/patches/centeredmaster/)
* [combo](https://dwm.suckless.org/patches/combo/)
* [cyclelayouts](https://dwm.suckless.org/patches/cyclelayouts/)
* [gridmode](https://dwm.suckless.org/patches/gridmode/)
* [movestack](https://dwm.suckless.org/patches/movestack/)
* [ru_gaps](https://dwm.suckless.org/patches/ru_gaps/)

View File

@@ -53,6 +53,7 @@ static const Layout layouts[] = {
{ "|M|", centeredmaster },
{ ">M>", centeredfloatingmaster },
{ "HHH", grid },
{ NULL, NULL },
};
/* key definitions */
@@ -112,6 +113,8 @@ static Key keys[] = {
{ MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_g, setlayout, {.v = &layouts[5]} },
{ MODKEY|ControlMask, XK_comma, cyclelayout, {.i = -1 } },
{ MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0} },

6
dwm.1
View File

@@ -137,6 +137,12 @@ Sets grid layout.
.B Mod1\-space
Toggles between current and previous layout.
.TP
.B Mod1\-Control\-,
Cycles backwards in layout list.
.TP
.B Mod1\-Control\-.
Cycles forwards in layout list.
.TP
.B Mod1\-j
Focus next window.
.TP

18
dwm.c
View File

@@ -183,6 +183,7 @@ static void configure(Client *c);
static void configurenotify(XEvent *e);
static void configurerequest(XEvent *e);
static Monitor *createmon(void);
static void cyclelayout(const Arg *arg);
static void destroynotify(XEvent *e);
static void detach(Client *c);
static void detachstack(Client *c);
@@ -786,6 +787,23 @@ createmon(void)
return m;
}
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] }));
}
}
void
destroynotify(XEvent *e)
{