]> git.ekhem.eu.org Git - dwm.git/commitdiff
Patch shiftview
authorJakub Czajka <jakub@ekhem.eu.org>
Fri, 1 Oct 2021 19:27:46 +0000 (21:27 +0200)
committerJakub Czajka <jakub@ekhem.eu.org>
Sat, 14 Oct 2023 20:46:02 +0000 (22:46 +0200)
config.h
dwm.c

index 0a9c4dd0ace115e96b758503fe0b1aa8ae2231b8..0bf3e386875d3103b941adf3bcd941693ccfa22d 100644 (file)
--- 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 a20fb1d7dfc5f837006ff5e316d39f5a62cbe72e..7cbd3c5d9ce99ad50bed94a6f80e007bd67b50d9 100644 (file)
--- 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)
 {