Skip to content

Commit

Permalink
Add new 'ws_empty' action.
Browse files Browse the repository at this point in the history
Switches to the first empty workspace.
Unbound by default.
  • Loading branch information
LordReg committed Oct 3, 2017
1 parent ddf4d66 commit 82efe69
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spectrwm.1
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ wind_kill
mvrg_next
.It Aq Ar unbound
mvrg_prev
.It Aq Ar unbound
ws_empty
.It Cm M- Ns Aq Cm Right
ws_next
.It Cm M- Ns Aq Cm Left
Expand Down Expand Up @@ -853,6 +855,8 @@ is 1 through 9.
Move current window to workspace in next region.
.It Cm mvrg_prev
Move current window to workspace in previous region.
.It Cm ws_empty
Switch to the first empty workspace.
.It Cm ws_next
Switch to next workspace with a window in it.
.It Cm ws_prev
Expand Down
24 changes: 24 additions & 0 deletions spectrwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ enum actionid {
FN_WS_20,
FN_WS_21,
FN_WS_22,
FN_WS_EMPTY,
FN_WS_NEXT,
FN_WS_NEXT_ALL,
FN_WS_NEXT_MOVE,
Expand Down Expand Up @@ -1021,6 +1022,7 @@ void debug_refresh(struct ws_win *);
void debug_toggle(struct binding *, struct swm_region *, union arg *);
void destroynotify(xcb_destroy_notify_event_t *);
void dumpwins(struct binding *, struct swm_region *, union arg *);
void emptyws(struct binding *, struct swm_region *, union arg *);
int enable_wm(void);
void enternotify(xcb_enter_notify_event_t *);
void event_drain(uint8_t);
Expand Down Expand Up @@ -4390,6 +4392,27 @@ cyclews(struct binding *bp, struct swm_region *r, union arg *args)
DNPRINTF(SWM_D_FOCUS, "cyclews: done\n");
}

void
emptyws(struct binding *bp, struct swm_region *r, union arg *args)
{
int i;
union arg a;

(void)args;

DNPRINTF(SWM_D_WS, "emptyws: id: %d, 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);

for (i = 0; i < workspace_limit; ++i)
if (TAILQ_EMPTY(&r->s->ws[i].winlist)) {
a.id = i;
switchws(bp, r, &a);
break;
}

DNPRINTF(SWM_D_FOCUS, "emptyws: done\n");
}

void
priorws(struct binding *bp, struct swm_region *r, union arg *args)
{
Expand Down Expand Up @@ -7530,6 +7553,7 @@ struct action {
{ "ws_20", switchws, 0, {.id = 19} },
{ "ws_21", switchws, 0, {.id = 20} },
{ "ws_22", switchws, 0, {.id = 21} },
{ "ws_empty", emptyws, 0, {0} },
{ "ws_next", cyclews, 0, {.id = SWM_ARG_ID_CYCLEWS_UP} },
{ "ws_next_all", cyclews, 0, {.id = SWM_ARG_ID_CYCLEWS_UP_ALL} },
{ "ws_next_move", cyclews, 0, {.id = SWM_ARG_ID_CYCLEWS_MOVE_UP} },
Expand Down

0 comments on commit 82efe69

Please sign in to comment.