From d5661656c786ef778d03de52beb5738ff1cc28af Mon Sep 17 00:00:00 2001 From: frosty Date: Tue, 3 Sep 2024 23:42:46 -0400 Subject: [PATCH] patch: shiftview --- config.def.h | 4 ++++ shiftview.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 shiftview.c diff --git a/config.def.h b/config.def.h index 9efa774..4f25a30 100644 --- a/config.def.h +++ b/config.def.h @@ -60,6 +60,8 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; +#include "shiftview.c" + static const Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = dmenucmd } }, @@ -81,6 +83,8 @@ static const Key keys[] = { { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_y, shiftview, {.i = +1 } }, + { MODKEY|ShiftMask, XK_y, shiftview, {.i = -1 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, diff --git a/shiftview.c b/shiftview.c new file mode 100644 index 0000000..e82053a --- /dev/null +++ b/shiftview.c @@ -0,0 +1,19 @@ +/** Function to shift the current view to the left/right + * + * @param: "arg->i" stores the number of tags to shift right (positive value) + * or left (negative value) + */ +void +shiftview(const Arg *arg) { + Arg shifted; + + if(arg->i > 0) // left circular shift + shifted.ui = (selmon->tagset[selmon->seltags] << arg->i) + | (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i)); + + else // right circular shift + shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i) + | selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i); + + view(&shifted); +}