t* dwm + patches URI git clone git://git.codevoid.de/dwm-sdk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 85a0fca4734ba778997102ae1ed362fb28dc4cc5 DIR parent 8fe815dc2e08be1441e12d96c11cf0c54c84c06e URI Author: Stefan Hagen <sh+git[at]codevoid[dot]de> Date: Fri, 16 Nov 2018 18:09:27 +0100 Apply tag to right/left patch Diffstat: M config.def.h | 4 ++++ M config.h | 4 ++++ M dwm.1 | 12 ++++++++++++ M dwm.c | 48 +++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 0 deletions(-) --- DIR diff --git a/config.def.h b/config.def.h t@@ -79,6 +79,10 @@ static Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + { MODKEY, XK_Left, viewtoleft, {0} }, + { MODKEY, XK_Right, viewtoright, {0} }, + { MODKEY|ShiftMask, XK_Left, tagtoleft, {0} }, + { MODKEY|ShiftMask, XK_Right, tagtoright, {0} }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) DIR diff --git a/config.h b/config.h t@@ -97,6 +97,10 @@ static Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + { MODKEY, XK_Left, viewtoleft, {0} }, + { MODKEY, XK_Right, viewtoright, {0} }, + { MODKEY|ShiftMask, XK_Left, tagtoleft, {0} }, + { MODKEY|ShiftMask, XK_Right, tagtoright, {0} }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) DIR diff --git a/dwm.1 b/dwm.1 t@@ -71,6 +71,18 @@ Send focused window to previous screen, if any. .B Mod1\-Shift\-. Send focused window to next screen, if any. .TP +.B Mod1\-Right +Focus tag on the right, if any. +.TP +.B Mod1\-Left +Focus tag on the left, if any. +.TP +.B Mod1\-Shift\-Right +Send focused window to tag on the right, if any. +.TP +.B Mod1\-Shift\-Left +Send focused window to tag on the left, if any. +.TP .B Mod1\-b Toggles bar on and off. .TP DIR diff --git a/dwm.c b/dwm.c t@@ -235,6 +235,8 @@ static void sigchld(int unused); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); +static void tagtoleft(const Arg *arg); +static void tagtoright(const Arg *arg); static int textnw(const char *text, unsigned int len); static void tile(Monitor *); static void togglebar(const Arg *arg); t@@ -255,6 +257,8 @@ static void updatewindowtype(Client *c); static void updatetitle(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); +static void viewtoleft(const Arg *arg); +static void viewtoright(const Arg *arg); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); static int xerror(Display *dpy, XErrorEvent *ee); t@@ -1750,6 +1754,28 @@ tagmon(const Arg *arg) { sendmon(selmon->sel, dirtomon(arg->i)); } +void +tagtoleft(const Arg *arg) { + if(selmon->sel != NULL + && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + && selmon->tagset[selmon->seltags] > 1) { + selmon->sel->tags >>= 1; + focus(NULL); + arrange(selmon); + } +} + +void +tagtoright(const Arg *arg) { + if(selmon->sel != NULL + && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { + selmon->sel->tags <<= 1; + focus(NULL); + arrange(selmon); + } +} + int textnw(const char *text, unsigned int len) { XRectangle r; t@@ -2201,6 +2227,28 @@ view(const Arg *arg) { arrange(selmon); } +void +viewtoleft(const Arg *arg) { + if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + && selmon->tagset[selmon->seltags] > 1) { + selmon->seltags ^= 1; /* toggle sel tagset */ + selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1; + focus(NULL); + arrange(selmon); + } +} + +void +viewtoright(const Arg *arg) { + if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { + selmon->seltags ^= 1; /* toggle sel tagset */ + selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1; + focus(NULL); + arrange(selmon); + } +} + Client * wintoclient(Window w) { Client *c;