Feature: Cycle through workspaces

On command pw/nw, cycle through all workspaces (starting from
previous/next one) until we reach the current one again.
This commit is contained in:
Cedric Staub 2010-01-15 16:30:28 +01:00 committed by Michael Stapelberg
parent d949a335e6
commit c606d93630
1 changed files with 18 additions and 2 deletions

View File

@ -768,7 +768,15 @@ static void next_previous_workspace(xcb_connection_t *conn, int direction) {
Workspace *ws = c_ws;
if (direction == 'n') {
while ((ws = TAILQ_NEXT(ws, workspaces)) != TAILQ_END(workspaces_head)) {
while (1) {
ws = TAILQ_NEXT(ws, workspaces);
if (ws == TAILQ_END(workspaces))
ws = TAILQ_FIRST(workspaces);
if (ws == c_ws)
return;
if (ws->screen == NULL)
continue;
@ -776,7 +784,15 @@ static void next_previous_workspace(xcb_connection_t *conn, int direction) {
return;
}
} else if (direction == 'p') {
while ((ws = TAILQ_PREV(ws, workspaces_head, workspaces)) != TAILQ_END(workspaces)) {
while (1) {
ws = TAILQ_PREV(ws, workspaces_head, workspaces);
if (ws == TAILQ_END(workspaces))
ws = TAILQ_LAST(workspaces, workspaces_head);
if (ws == c_ws)
return;
if (ws->screen == NULL)
continue;