From dcc5981499de2fe353900e02895576e09b5e2896 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 21 Apr 2024 09:33:01 +0200 Subject: [PATCH] Add cycletags patch See https://github.com/bakkeby/patches/blob/master/dwm/dwm-shiftviewclients-6.2.diff --- config.h | 4 +++- dwm.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/config.h b/config.h index 53daba5..bb8f7dd 100644 --- a/config.h +++ b/config.h @@ -76,7 +76,9 @@ static const Key keys[] = { { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, // { MODKEY, XK_Return, zoom, {0} }, - { MODKEY, XK_Tab, view, {0} }, +// { MODKEY, XK_Tab, view, {0} }, + { MODKEY, XK_Tab, cycletags, { .i = +1 } }, + { MODKEY|ShiftMask, XK_Tab, cycletags, { .i = -1 } }, { MODKEY|ShiftMask, XK_c, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, diff --git a/dwm.c b/dwm.c index f1d86b2..61fa0d6 100644 --- a/dwm.c +++ b/dwm.c @@ -157,6 +157,7 @@ static void configure(Client *c); static void configurenotify(XEvent *e); static void configurerequest(XEvent *e); static Monitor *createmon(void); +static void cycletags(const Arg *arg); static void destroynotify(XEvent *e); static void detach(Client *c); static void detachstack(Client *c); @@ -647,6 +648,31 @@ createmon(void) return m; } +void +cycletags(const Arg *arg) +{ + Arg shifted; + Client *c; + unsigned int tagmask = 0; + + for (c = selmon->clients; c; c = c->next) + tagmask = tagmask | c->tags; + + shifted.ui = selmon->tagset[selmon->seltags]; + if (arg->i > 0) // left circular shift + do { + shifted.ui = (shifted.ui << arg->i) + | (shifted.ui >> (LENGTH(tags) - arg->i)); + } while (tagmask && !(shifted.ui & tagmask)); + else // right circular shift + do { + shifted.ui = (shifted.ui >> (- arg->i) + | shifted.ui << (LENGTH(tags) + arg->i)); + } while (tagmask && !(shifted.ui & tagmask)); + + view(&shifted); +} + void destroynotify(XEvent *e) {