JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Cycle through all workspaces (empty or not) with M-<Up> and M-<Down>.
[spectrwm.git] / scrotwm.c
index 06b4a97..dfbdefc 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -425,6 +425,8 @@ union arg {
 #define SWM_ARG_ID_CYCLEWS_DOWN        (41)
 #define SWM_ARG_ID_CYCLESC_UP  (42)
 #define SWM_ARG_ID_CYCLESC_DOWN        (43)
+#define SWM_ARG_ID_CYCLEWS_UP_ALL      (44)
+#define SWM_ARG_ID_CYCLEWS_DOWN_ALL    (45)
 #define SWM_ARG_ID_STACKINC    (50)
 #define SWM_ARG_ID_STACKDEC    (51)
 #define SWM_ARG_ID_SS_ALL      (60)
@@ -2145,6 +2147,7 @@ cyclews(struct swm_region *r, union arg *args)
 {
        union                   arg a;
        struct swm_screen       *s = r->s;
+       int                     cycle_all = 0;
 
        DNPRINTF(SWM_D_WS, "cyclews id %d "
            "in screen[%d]:%dx%d+%d+%d ws %d\n", args->id,
@@ -2153,12 +2156,18 @@ cyclews(struct swm_region *r, union arg *args)
        a.id = r->ws->idx;
        do {
                switch (args->id) {
+               case SWM_ARG_ID_CYCLEWS_UP_ALL:
+                       cycle_all = 1;
+                       /* FALLTHROUGH */
                case SWM_ARG_ID_CYCLEWS_UP:
                        if (a.id < SWM_WS_MAX - 1)
                                a.id++;
                        else
                                a.id = 0;
                        break;
+               case SWM_ARG_ID_CYCLEWS_DOWN_ALL:
+                       cycle_all = 1;
+                       /* FALLTHROUGH */
                case SWM_ARG_ID_CYCLEWS_DOWN:
                        if (a.id > 0)
                                a.id--;
@@ -2169,7 +2178,8 @@ cyclews(struct swm_region *r, union arg *args)
                        return;
                };
 
-               if (cycle_empty == 0 && TAILQ_EMPTY(&s->ws[a.id].winlist))
+               if (!cycle_all &&
+                   (cycle_empty == 0 && TAILQ_EMPTY(&s->ws[a.id].winlist)))
                        continue;
                if (cycle_visible == 0 && s->ws[a.id].r != NULL)
                        continue;
@@ -3692,6 +3702,8 @@ enum keyfuncid {
        kf_ws_10,
        kf_ws_next,
        kf_ws_prev,
+       kf_ws_next_all,
+       kf_ws_prev_all,
        kf_ws_prior,
        kf_screen_next,
        kf_screen_prev,
@@ -3778,6 +3790,8 @@ 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_next_all",        cyclews,        {.id = SWM_ARG_ID_CYCLEWS_UP_ALL} },
+       { "ws_prev_all",        cyclews,        {.id = SWM_ARG_ID_CYCLEWS_DOWN_ALL} },
        { "ws_prior",           priorws,        {0} },
        { "screen_next",        cyclescr,       {.id = SWM_ARG_ID_CYCLESC_UP} },
        { "screen_prev",        cyclescr,       {.id = SWM_ARG_ID_CYCLESC_DOWN} },
@@ -4378,6 +4392,8 @@ 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_Up,          kf_ws_next_all, NULL);
+       setkeybinding(MODKEY,           XK_Down,        kf_ws_prev_all, 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);