diff --git a/config.h b/config.h index f01b27b..dbb9f61 100644 --- a/config.h +++ b/config.h @@ -50,12 +50,10 @@ static const Layout layouts[] = { }; /* custom functions declarations */ -static unsigned int nexttag(void); -static unsigned int prevtag(void); -static void tagtonext(const Arg *arg); -static void tagtoprev(const Arg *arg); -static void viewnext(const Arg *arg); -static void viewprev(const Arg *arg); +static unsigned int adjtag(const Arg *arg); +static void viewadj(const Arg *arg); +static void tagadj(const Arg *arg); +static void toggletagadj(const Arg *arg); /* key definitions */ #define MODKEY Mod1Mask @@ -101,10 +99,12 @@ 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_comma, viewprev, {0} }, - { MODKEY, XK_period, viewnext, {0} }, - { MODKEY|ShiftMask, XK_comma, tagtoprev, {0} }, - { MODKEY|ShiftMask, XK_period, tagtonext, {0} }, + { MODKEY, XK_comma, viewadj, {.i = -1 } }, + { MODKEY, XK_period, viewadj, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagadj, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagadj, {.i = +1 } }, + { MODKEY|ControlMask|ShiftMask, XK_comma, toggletagadj, {.i = -1 } }, + { MODKEY|ControlMask|ShiftMask, XK_period, toggletagadj, {.i = +1 } }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) @@ -154,51 +154,34 @@ static Button buttons[] = { /* custom functions */ unsigned int -nexttag(void) +adjtag(const Arg *arg) { unsigned int seltag = selmon->tagset[selmon->seltags]; - return seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1; -} - -unsigned int -prevtag(void) -{ - unsigned int seltag = selmon->tagset[selmon->seltags]; - return seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1; + if (arg->i > 0) + return seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1; + else + return seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1; } void -tagtonext(const Arg *arg) +viewadj(const Arg *arg) { - unsigned int tmp; + view(&(const Arg){.ui = adjtag(arg)}); +} +void +tagadj(const Arg *arg) +{ if (selmon->sel == NULL) return; - - tag(&(const Arg){.ui = nexttag()}); - /* view(&(const Arg){.ui = tmp }); */ + tag(&(const Arg){.ui = adjtag(arg)}); } void -tagtoprev(const Arg *arg) +toggletagadj(const Arg *arg) { - unsigned int tmp; - if (selmon->sel == NULL) return; + toggletag(&(const Arg){.ui = adjtag(arg)}); - tag(&(const Arg){.ui = prevtag()}); - /* view(&(const Arg){.ui = tmp }); */ -} - -void -viewnext(const Arg *arg) -{ - view(&(const Arg){.ui = nexttag()}); -} - -void -viewprev(const Arg *arg) -{ - view(&(const Arg){.ui = prevtag()}); }