diff options
| author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2012-03-01 19:29:51 +0200 |
|---|---|---|
| committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2012-12-16 02:11:13 +0200 |
| commit | 90335c584b26c0d35424d538428c478c11334695 (patch) | |
| tree | 7c241eed3ef4081390cb830828443eac6a435376 | |
| parent | 5f4c250dfccca65f7547b7d5546aa67a2d2ad46a (diff) | |
toggle to previously focused desktop
| -rw-r--r-- | config.def.h | 1 | ||||
| -rw-r--r-- | monsterwm.c | 12 |
2 files changed, 11 insertions, 2 deletions
diff --git a/config.def.h b/config.def.h index 0e301d3..3c2c7cf 100644 --- a/config.def.h +++ b/config.def.h @@ -55,6 +55,7 @@ static Key keys[] = { { MOD1|SHIFT, XK_c, killclient, {NULL}}, { MOD1, XK_j, next_win, {NULL}}, { MOD1, XK_k, prev_win, {NULL}}, + { MOD1, XK_Tab, last_desktop, {NULL}}, { MOD1, XK_Return, swap_master, {NULL}}, { MOD1|SHIFT, XK_j, move_down, {NULL}}, { MOD1|SHIFT, XK_k, move_up, {NULL}}, diff --git a/monsterwm.c b/monsterwm.c index 008e421..71e2d04 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -81,6 +81,7 @@ typedef struct { static void change_desktop(const Arg *arg); static void client_to_desktop(const Arg *arg); static void killclient(); +static void last_desktop(); static void move_down(); static void move_up(); static void moveresize(const Arg *arg); @@ -177,7 +178,7 @@ static int xerrorstart(Display *dis, XErrorEvent *ee); * currdeskidx - which desktop is currently active */ static Bool running = True; -static int wh, ww, currdeskidx; +static int wh, ww, currdeskidx, prevdeskidx; static unsigned int numlockmask, win_unfocus, win_focus; static Display *dis; static Window root; @@ -262,7 +263,7 @@ void buttonpress(XEvent *e) { */ void change_desktop(const Arg *arg) { if (arg->i == currdeskidx || arg->i < 0 || arg->i >= DESKTOPS) return; - Desktop *d = &desktops[currdeskidx], *n = &desktops[(currdeskidx = arg->i)]; + Desktop *d = &desktops[(prevdeskidx = currdeskidx)], *n = &desktops[(currdeskidx = arg->i)]; if (n->curr) XMapWindow(dis, n->curr->win); for (Client *c = n->head; c; c = c->next) XMapWindow(dis, c->win); XChangeWindowAttributes(dis, root, CWEventMask, &(XSetWindowAttributes){.do_not_propagate_mask = SubstructureNotifyMask}); @@ -657,6 +658,13 @@ void killclient(void) { } /** + * focus the previously/last focused desktop + */ +void last_desktop(void) { + change_desktop(&(Arg){.i = prevdeskidx}); +} + +/** * a map request is received when a window wants to display itself. * if the window has override_redirect flag set, * then it should not be handled by the wm. |
