diff --git a/config.h b/config.h index 097aab9..546af1e 100644 --- a/config.h +++ b/config.h @@ -140,21 +140,14 @@ static const Key keys[] = { { MODKEY, XKB_KEY_space, setlayout, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, - { MODKEY, XKB_KEY_0, view, {.ui = ~0} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} }, + { MODKEY, XKB_KEY_Left, shiftview, {.i = -1} }, + { MODKEY, XKB_KEY_Right, shiftview, {.i = +1} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, shiftclient, {.i = -1} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, shiftclient, {.i = +1} }, + { MODKEY, XKB_KEY_Up, focusstack, {.i = -1} }, + { MODKEY, XKB_KEY_Down, focusstack, {.i = +1} }, { MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} }, { MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} }, - TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0), - TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1), - TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2), - TAGKEYS( XKB_KEY_4, XKB_KEY_dollar, 3), - TAGKEYS( XKB_KEY_5, XKB_KEY_percent, 4), - TAGKEYS( XKB_KEY_6, XKB_KEY_asciicircum, 5), - TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6), - TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7), - TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8), { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} }, /* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */ diff --git a/dwl.c b/dwl.c index 44f3ad9..cc305fa 100644 --- a/dwl.c +++ b/dwl.c @@ -329,6 +329,8 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags); static void setpsel(struct wl_listener *listener, void *data); static void setsel(struct wl_listener *listener, void *data); static void setup(void); +static void shiftclient(const Arg *arg); +static void shiftview(const Arg *arg); static void spawn(const Arg *arg); static void startdrag(struct wl_listener *listener, void *data); static void tag(const Arg *arg); @@ -2709,6 +2711,34 @@ tagmon(const Arg *arg) setmon(sel, dirtomon(arg->i), 0); } +void +shiftview(const Arg *arg) +{ + Arg a; + unsigned int tagmask = selmon->tagset[selmon->seltags]; + if (arg->i > 0) + a.ui = (tagmask == (1u << (TAGCOUNT - 1))) ? 1 : tagmask << 1; + else + a.ui = (tagmask == 1) ? (1u << (TAGCOUNT - 1)) : tagmask >> 1; + view(&a); +} + +void +shiftclient(const Arg *arg) +{ + Client *sel = focustop(selmon); + Arg a; + unsigned int tagmask = selmon->tagset[selmon->seltags]; + if (!sel) + return; + if (arg->i > 0) + a.ui = (tagmask == (1u << (TAGCOUNT - 1))) ? 1 : tagmask << 1; + else + a.ui = (tagmask == 1) ? (1u << (TAGCOUNT - 1)) : tagmask >> 1; + sel->tags = a.ui; + view(&a); +} + void tile(Monitor *m) {