From b837899f7aff816895ae892f965be461c8b027ef Mon Sep 17 00:00:00 2001 From: bakkeby Date: Fri, 1 May 2020 16:45:25 +0200 Subject: [PATCH] Adding option to be able to reverse cycle through flextile-deluxe layouts --- README.md | 4 ++-- config.def.h | 12 ++++++++---- patch/flextile-deluxe.c | 33 +++++++++++++++++++++++++-------- patch/pertag.c | 2 +- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index c06884b..23f82cd 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [dragcfact](https://github.com/bakkeby/patches/blob/master/dwm/dwm-cfacts-dragcfact-6.2.diff) - lets you resize clients' size (i.e. modify cfact) by holding modkey + shift + right-click and dragging the mouse - - [dragmfact](https://dwm.suckless.org/patches/dragmfact/) + - [dragmfact](https://github.com/bakkeby/patches/blob/master/dwm/dwm-dragmfact-6.2.diff) - lets you resize the split in layouts (i.e. modify mfact) by holding the modkey + shift + left-click and dragging the mouse - this is a bespoke patch that supports vertical and horizontal layout splits as well as centered master variants @@ -448,7 +448,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [fibonacci](https://dwm.suckless.org/patches/fibonacci/) - fibonacci (dwindle and spiral) layouts - - flextile-deluxe + - [flextile-deluxe](https://github.com/bakkeby/patches/blob/master/dwm/dwm-pertag-flextile_deluxe-6.2.diff) - a re-envisioned, flexible and over-the-top version of the original [flextile](https://dwm.suckless.org/patches/flextile/) patch supporting - multiple split layouts (horizontal, vertical, centered, floating, fixed) - tile arrangement on a per split basis (stack horizontally, stack vertically, grids, fibonacci) diff --git a/config.def.h b/config.def.h index 150dbee..50bcff6 100644 --- a/config.def.h +++ b/config.def.h @@ -810,10 +810,14 @@ static Key keys[] = { { MODKEY, XK_c, setlayout, {.v = &layouts[3]} }, #endif // COLUMNS_LAYOUT #if FLEXTILE_DELUXE_LAYOUT - { MODKEY|ControlMask, XK_t, rotatelayoutaxis, {.i = 0 } }, /* flextile, 0 = layout axis */ - { MODKEY|ControlMask, XK_Tab, rotatelayoutaxis, {.i = 1 } }, /* flextile, 1 = master axis */ - { MODKEY|ControlMask|ShiftMask, XK_Tab, rotatelayoutaxis, {.i = 2 } }, /* flextile, 2 = stack axis */ - { MODKEY|ControlMask|Mod1Mask, XK_Tab, rotatelayoutaxis, {.i = 3 } }, /* flextile, 3 = secondary stack axis */ + { MODKEY|ControlMask, XK_t, rotatelayoutaxis, {.i = +1 } }, /* flextile, 1 = layout axis */ + { MODKEY|ControlMask, XK_Tab, rotatelayoutaxis, {.i = +2 } }, /* flextile, 2 = master axis */ + { MODKEY|ControlMask|ShiftMask, XK_Tab, rotatelayoutaxis, {.i = +3 } }, /* flextile, 3 = stack axis */ + { MODKEY|ControlMask|Mod1Mask, XK_Tab, rotatelayoutaxis, {.i = +4 } }, /* flextile, 4 = secondary stack axis */ + { MODKEY|Mod5Mask, XK_t, rotatelayoutaxis, {.i = -1 } }, /* flextile, 1 = layout axis */ + { MODKEY|Mod5Mask, XK_Tab, rotatelayoutaxis, {.i = -2 } }, /* flextile, 2 = master axis */ + { MODKEY|Mod5Mask|ShiftMask, XK_Tab, rotatelayoutaxis, {.i = -3 } }, /* flextile, 3 = stack axis */ + { MODKEY|Mod5Mask|Mod1Mask, XK_Tab, rotatelayoutaxis, {.i = -4 } }, /* flextile, 4 = secondary stack axis */ { MODKEY|ControlMask, XK_Return, mirrorlayout, {0} }, /* flextile, flip master and stack areas */ #endif // FLEXTILE_DELUXE_LAYOUT { MODKEY, XK_space, setlayout, {0} }, diff --git a/patch/flextile-deluxe.c b/patch/flextile-deluxe.c index 6fade28..f96cc92 100644 --- a/patch/flextile-deluxe.c +++ b/patch/flextile-deluxe.c @@ -690,17 +690,34 @@ mirrorlayout(const Arg *arg) void rotatelayoutaxis(const Arg *arg) { + int incr = (arg->i > 0 ? 1 : -1); + int axis = abs(arg->i) - 1; + if (!selmon->lt[selmon->sellt]->arrange) return; - if (arg->i == 0) { - if (selmon->ltaxis[LAYOUT] >= 0) - selmon->ltaxis[LAYOUT] = selmon->ltaxis[LAYOUT] + 1 >= LAYOUT_LAST ? 0 : selmon->ltaxis[LAYOUT] + 1; - else - selmon->ltaxis[LAYOUT] = selmon->ltaxis[LAYOUT] - 1 <= -LAYOUT_LAST ? -0 : selmon->ltaxis[LAYOUT] - 1; - } else - selmon->ltaxis[arg->i] = selmon->ltaxis[arg->i] + 1 >= AXIS_LAST ? 0 : selmon->ltaxis[arg->i] + 1; + if (axis == LAYOUT) { + if (selmon->ltaxis[LAYOUT] >= 0) { + selmon->ltaxis[LAYOUT] += incr; + if (selmon->ltaxis[LAYOUT] >= LAYOUT_LAST) + selmon->ltaxis[LAYOUT] = 0; + else if (selmon->ltaxis[LAYOUT] < 0) + selmon->ltaxis[LAYOUT] = LAYOUT_LAST - 1; + } else { + selmon->ltaxis[LAYOUT] -= incr; + if (selmon->ltaxis[LAYOUT] <= -LAYOUT_LAST) + selmon->ltaxis[LAYOUT] = 0; + else if (selmon->ltaxis[LAYOUT] > 0) + selmon->ltaxis[LAYOUT] = -LAYOUT_LAST + 1; + } + } else { + selmon->ltaxis[axis] += incr; + if (selmon->ltaxis[axis] >= AXIS_LAST) + selmon->ltaxis[axis] = 0; + else if (selmon->ltaxis[axis] < 0) + selmon->ltaxis[axis] = AXIS_LAST - 1; + } #if PERTAG_PATCH - selmon->pertag->ltaxis[selmon->pertag->curtag][arg->i] = selmon->ltaxis[arg->i]; + selmon->pertag->ltaxis[selmon->pertag->curtag][axis] = selmon->ltaxis[axis]; #endif // PERTAG_PATCH arrange(selmon); setflexsymbols(selmon, 0); diff --git a/patch/pertag.c b/patch/pertag.c index 3b598ee..cc97a6c 100644 --- a/patch/pertag.c +++ b/patch/pertag.c @@ -36,7 +36,7 @@ pertagview(const Arg *arg) if (arg->ui == ~0) selmon->pertag->curtag = 0; else { - for (i=0; !(arg->ui & 1 << i); i++) ; + for (i = 0; !(arg->ui & 1 << i); i++) ; selmon->pertag->curtag = i + 1; } } else {