From 9db8535b4cd55702bbdf0fd005882b469a989e4f Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 22 Jul 2009 00:16:16 +0200 Subject: [PATCH] =?UTF-8?q?Some=20little=20fixes=20(mostly=20formatting)?= =?UTF-8?q?=20for=20bapt=E2=80=99s=20patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands.c | 61 +++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/src/commands.c b/src/commands.c index b57b3ac5..0322a51d 100644 --- a/src/commands.c +++ b/src/commands.c @@ -845,31 +845,38 @@ static char **append_argument(char **original, char *argument) { return result; } + /* - * switch to next or previous existing workspace + * Switch to next or previous existing workspace + * */ static void next_previous_workspace(xcb_connection_t *conn, int direction) { - Workspace *t_ws; - int i; - if (direction == 'n') { - if (c_ws->num == 9) - return; - for ( i = c_ws->num + 1; i <= 9; i++) { - t_ws = &(workspaces[i]); - if (t_ws->screen != NULL) break; - } - } else if (direction == 'p' ) { - if (c_ws->num == 0) - return; - for (i = c_ws->num - 1; i >= 0 ; i--) { - t_ws = &(workspaces[i]); - if (t_ws->screen != NULL) break; - } - } - if (t_ws->screen != NULL) - show_workspace(conn,i+1); -} + Workspace *t_ws; + int i; + if (direction == 'n') { + /* If we are on the last workspace, we cannot go any further */ + if (c_ws->num == 9) + return; + + for (i = c_ws->num + 1; i <= 9; i++) { + t_ws = &(workspaces[i]); + if (t_ws->screen != NULL) + break; + } + } else if (direction == 'p') { + if (c_ws->num == 0) + return; + for (i = c_ws->num - 1; i >= 0 ; i--) { + t_ws = &(workspaces[i]); + if (t_ws->screen != NULL) + break; + } + } + + if (t_ws->screen != NULL) + show_workspace(conn, i+1); +} /* * Parses a command, see file CMDMODE for more information @@ -1007,14 +1014,18 @@ void parse_command(xcb_connection_t *conn, const char *command) { return; } - /* Is it 'n' for next workspace (nw) */ - if (command[0] == 'n' && command[1] == 'w') { + + /* Is it 'n' or 'p' for next/previous workspace? (nw) */ + if (command[0] == 'n' && command[1] == 'w') { next_previous_workspace(conn, command[0]); - } + return; + } if (command[0] == 'p' && command[1] == 'w') { next_previous_workspace(conn, command[0]); - } + return; + } + /* It’s a normal */ char *rest = NULL; enum { ACTION_FOCUS, ACTION_MOVE, ACTION_SNAP } action = ACTION_FOCUS;