From: Marco Peereboom Date: Thu, 1 Jul 2010 19:01:15 +0000 (+0000) Subject: Add prior workspace X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=f35cc2805277b466803534b7cd4345cd55a0deb0;p=spectrwm.git Add prior workspace from keenerd --- diff --git a/scrotwm.1 b/scrotwm.1 index e539732..07d9ab3 100644 --- a/scrotwm.1 +++ b/scrotwm.1 @@ -315,6 +315,8 @@ wind_kill ws_next .It Cm M- Ns Aq Cm Left ws_prev +.It Cm M-a +ws_prior .It Cm M-S- Ns Aq Cm Right screen_next .It Cm M-S- Ns Aq Cm Left @@ -402,6 +404,8 @@ is 1 through 10 Switch to next workspace with a window in it .It Cm ws_prev Switch to previous workspace with a window in it +.It Cm ws_prior +Switch to last visited workspace .It Cm screen_next Move pointer to next region .It Cm screen_prev diff --git a/scrotwm.c b/scrotwm.c index d68be7d..2d9283c 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -236,6 +236,7 @@ struct swm_region { TAILQ_ENTRY(swm_region) entry; struct swm_geometry g; struct workspace *ws; /* current workspace on this region */ + struct workspace *ws_prior; /* prior workspace on this region */ struct swm_screen *s; /* screen idx */ Window bar_window; }; @@ -1469,9 +1470,11 @@ switchws(struct swm_region *r, union arg *args) old_ws->r = NULL; unmap_old = 1; } else { + other_r->ws_prior = new_ws; other_r->ws = old_ws; old_ws->r = other_r; } + this_r->ws_prior = old_ws; this_r->ws = new_ws; new_ws->r = this_r; @@ -1525,6 +1528,23 @@ cyclews(struct swm_region *r, union arg *args) } void +priorws(struct swm_region *r, union arg *args) +{ + union arg a; + struct swm_screen *s = r->s; + + DNPRINTF(SWM_D_WS, "priorws id %d " + "in screen[%d]:%dx%d+%d+%d ws %d\n", args->id, + r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r), r->ws->idx); + + if (r->ws_prior == NULL) + return; + + a.id = r->ws_prior->idx; + switchws(r, &a); +} + +void cyclescr(struct swm_region *r, union arg *args) { struct swm_region *rr = NULL; @@ -2506,6 +2526,7 @@ enum keyfuncid { kf_ws_10, kf_ws_next, kf_ws_prev, + kf_ws_prior, kf_screen_next, kf_screen_prev, kf_mvws_1, @@ -2579,6 +2600,7 @@ struct keyfunc { { "ws_10", switchws, {.id = 9} }, { "ws_next", cyclews, {.id = SWM_ARG_ID_CYCLEWS_UP} }, { "ws_prev", cyclews, {.id = SWM_ARG_ID_CYCLEWS_DOWN} }, + { "ws_prior", priorws, {0} }, { "screen_next", cyclescr, {.id = SWM_ARG_ID_CYCLESC_UP} }, { "screen_prev", cyclescr, {.id = SWM_ARG_ID_CYCLESC_DOWN} }, { "mvws_1", send_to_ws, {.id = 0} }, @@ -3101,6 +3123,7 @@ setup_keys(void) setkeybinding(MODKEY, XK_0, kf_ws_10, NULL); setkeybinding(MODKEY, XK_Right, kf_ws_next, NULL); setkeybinding(MODKEY, XK_Left, kf_ws_prev, NULL); + setkeybinding(MODKEY, XK_a, kf_ws_prior, NULL); setkeybinding(MODKEY|ShiftMask, XK_Right, kf_screen_next, NULL); setkeybinding(MODKEY|ShiftMask, XK_Left, kf_screen_prev, NULL); setkeybinding(MODKEY|ShiftMask, XK_1, kf_mvws_1, NULL); @@ -4393,6 +4416,7 @@ new_region(struct swm_screen *s, int x, int y, int w, int h) HEIGHT(r) = h; r->s = s; r->ws = ws; + r->ws_prior = NULL; ws->r = r; TAILQ_INSERT_TAIL(&s->rl, r, entry); }