From 84e97ecaa768fdee7b95630580321a2b40404b7c Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Fri, 1 Oct 2021 21:27:46 +0200 Subject: [PATCH] Patch shiftview --- config.h | 2 ++ dwm.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/config.h b/config.h index 0a9c4dd..0bf3e38 100644 --- a/config.h +++ b/config.h @@ -77,6 +77,8 @@ static Key keys[] = { { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_n, viewadjacent, { .i = +1 } }, + { MODKEY, XK_p, viewadjacent, { .i = -1 } }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, diff --git a/dwm.c b/dwm.c index a20fb1d..7cbd3c5 100644 --- a/dwm.c +++ b/dwm.c @@ -210,6 +210,7 @@ static void showhide(Client *c); static void sigchld(int unused); static void spawn(const Arg *arg); static void tag(const Arg *arg); +static void viewadjacent(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *m); static void togglebar(const Arg *arg); @@ -1683,6 +1684,26 @@ tag(const Arg *arg) } } +/** 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 +viewadjacent(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); +} + void tagmon(const Arg *arg) { -- 2.39.5