summaryrefslogtreecommitdiffstats
path: root/cmd-select-layout.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-07-11 07:10:15 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-07-11 07:10:15 +0000
commitede8312d59c5d08990f83f38682c26434823525b (patch)
treebdf66e80ca1d71548a554804f4ab6656a828a821 /cmd-select-layout.c
parentdf912e3540968a2a0b266e523ecc08bb2dc0ca20 (diff)
Make command exec functions return an enum rather than -1/0/1 values and
add a new value to mean "leave client running but don't attach" to fix problems with using some commands in a command sequence. Most of the work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
Diffstat (limited to 'cmd-select-layout.c')
-rw-r--r--cmd-select-layout.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/cmd-select-layout.c b/cmd-select-layout.c
index c79e8c7e..982c0b27 100644
--- a/cmd-select-layout.c
+++ b/cmd-select-layout.c
@@ -24,8 +24,8 @@
* Switch window to selected layout.
*/
-void cmd_select_layout_key_binding(struct cmd *, int);
-int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
+void cmd_select_layout_key_binding(struct cmd *, int);
+enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_select_layout_entry = {
"select-layout", "selectl",
@@ -90,7 +90,7 @@ cmd_select_layout_key_binding(struct cmd *self, int key)
}
}
-int
+enum cmd_retval
cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct args *args = self->args;
@@ -100,7 +100,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
int next, previous, layout;
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
- return (-1);
+ return (CMD_RETURN_ERROR);
w = wl->window;
next = self->entry == &cmd_next_layout_entry;
@@ -114,13 +114,13 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
if (args_has(self->args, 'U')) {
if ((layoutname = layout_list_redo(w)) == NULL) {
ctx->info(ctx, "no more layout history");
- return (-1);
+ return (CMD_RETURN_ERROR);
}
goto set_layout;
} else if (args_has(self->args, 'u')) {
if ((layoutname = layout_list_undo(w)) == NULL) {
ctx->info(ctx, "no more layout history");
- return (-1);
+ return (CMD_RETURN_ERROR);
}
goto set_layout;
}
@@ -132,7 +132,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
layout = layout_set_previous(wl->window);
server_redraw_window(wl->window);
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
- return (0);
+ return (CMD_RETURN_NORMAL);
}
if (args->argc == 0)
@@ -143,19 +143,19 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
layout = layout_set_select(wl->window, layout);
server_redraw_window(wl->window);
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
- return (0);
+ return (CMD_RETURN_NORMAL);
}
if (args->argc == 0)
- return (0);
+ return (CMD_RETURN_NORMAL);
layoutname = args->argv[0];
set_layout:
if (layout_parse(wl->window, layoutname) == -1) {
ctx->error(ctx, "can't set layout: %s", layoutname);
- return (-1);
+ return (CMD_RETURN_ERROR);
}
server_redraw_window(wl->window);
ctx->info(ctx, "arranging in: %s", layoutname);
- return (0);
+ return (CMD_RETURN_NORMAL);
}