diff options
| -rw-r--r-- | config.def.h | 6 | ||||
| -rw-r--r-- | monsterwm.c | 18 |
2 files changed, 17 insertions, 7 deletions
diff --git a/config.def.h b/config.def.h index 2e4d113..05ab773 100644 --- a/config.def.h +++ b/config.def.h @@ -56,8 +56,10 @@ static key keys[] = { { MOD1, XK_l, resize_master, {.i = +10}}, /* increase */ { MOD1, XK_o, resize_stack, {.i = -10}}, /* shrink */ { MOD1, XK_p, resize_stack, {.i = +10}}, /* grow */ - { MOD1|SHIFT, XK_Left, rotate_desktop, {.i = -1}}, /* prev */ - { MOD1|SHIFT, XK_Right, rotate_desktop, {.i = +1}}, /* next */ + { MOD1|CONTROL, XK_h, rotate, {.i = PREV}}, + { MOD1|CONTROL, XK_l, rotate, {.i = NEXT}}, + { MOD1|SHIFT, XK_h, rotate_filled, {.i = PREV}}, + { MOD1|SHIFT, XK_l, rotate_filled, {.i = NEXT}}, { MOD1, XK_Tab, last_desktop, {NULL}}, { MOD1, XK_Return, swap_master, {NULL}}, { MOD1|SHIFT, XK_j, move_down, {NULL}}, diff --git a/monsterwm.c b/monsterwm.c index 8831eaa..4132e68 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -17,7 +17,7 @@ #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) #define BUTTONMASK ButtonPressMask|ButtonReleaseMask -enum { RESIZE, MOVE }; +enum { PREV = -1, NEXT = 1, RESIZE, MOVE }; enum { TILE, MONOCLE, BSTACK, GRID, MODES }; enum { WM_PROTOCOLS, WM_DELETE_WINDOW, WM_COUNT }; enum { NET_SUPPORTED, NET_FULLSCREEN, NET_WM_STATE, NET_ACTIVE, NET_COUNT }; @@ -137,7 +137,8 @@ static void quit(const Arg *arg); static void removeclient(client *c); static void resize_master(const Arg *arg); static void resize_stack(const Arg *arg); -static void rotate_desktop(const Arg *arg); +static void rotate(const Arg *arg); +static void rotate_filled(const Arg *arg); static void run(void); static void save_desktop(int i); static void select_desktop(int i); @@ -751,9 +752,16 @@ void resize_stack(const Arg *arg) { tile(); } -/* jump and focus the 'current + n' desktop */ -void rotate_desktop(const Arg *arg) { - change_desktop(&(Arg){.i = (current_desktop + DESKTOPS + arg->i) % DESKTOPS}); +/* jump and focus the next or previous desktop */ +void rotate(const Arg *arg) { + change_desktop(&(Arg){.i = (DESKTOPS + current_desktop + arg->i) % DESKTOPS}); +} + +/* jump and focus the next or previous desktop that has clients */ +void rotate_filled(const Arg *arg) { + int n = arg->i; + while (n < DESKTOPS && !desktops[(DESKTOPS + current_desktop + n) % DESKTOPS].head) (n += arg->i); + change_desktop(&(Arg){.i = (DESKTOPS + current_desktop + n) % DESKTOPS}); } /* main event loop - on receival of an event call the appropriate event handler */ |
