]> code.delx.au - spectrwm/commitdiff
Add prior workspace
authorMarco Peereboom <marco@conformal.com>
Thu, 1 Jul 2010 19:01:15 +0000 (19:01 +0000)
committerMarco Peereboom <marco@conformal.com>
Thu, 1 Jul 2010 19:01:15 +0000 (19:01 +0000)
from
keenerd <keenerd@gmail.com>

scrotwm.1
scrotwm.c

index e5397327d3cb6b20d704871e41e5aa04a6a4e097..07d9ab3f30a7a7db5c5bb223108355bab82340af 100644 (file)
--- 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
index d68be7d2dbe56be416af0fa9e004a3217e224e83..2d9283c2abc91ecdafeee868fe9f18260afffa87 100644 (file)
--- 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;
 
@@ -1524,6 +1527,23 @@ cyclews(struct swm_region *r, union arg *args)
        } while (a.id != r->ws->idx);
 }
 
+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)
 {
@@ -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);
 }