diff --git a/cfg.c b/cfg.c index 7acc08bd..57b70b5b 100644 --- a/cfg.c +++ b/cfg.c @@ -92,7 +92,7 @@ load_cfg(const char *path, struct cmd_ctx *ctx, struct causelist *causes) if (ctx != NULL) cmd_ref_ctx(ctx); else { - ctx = cmd_get_ctx(); + ctx = cmd_get_ctx(NULL, NULL); ctx->error = cfg_error; ctx->print = cfg_print; ctx->info = cfg_print; diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index c18f9ad0..e1db3dd4 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -184,8 +184,7 @@ cmd_command_prompt_callback(void *data, const char *s) return (0); } - ctx = cmd_get_ctx(); - ctx->curclient = c; + ctx = cmd_get_ctx(NULL, c); ctx->error = key_bindings_error; ctx->print = key_bindings_print; ctx->info = key_bindings_info; diff --git a/cmd-confirm-before.c b/cmd-confirm-before.c index 067b5e7a..0b41592b 100644 --- a/cmd-confirm-before.c +++ b/cmd-confirm-before.c @@ -125,8 +125,7 @@ cmd_confirm_before_callback(void *data, const char *s) return (0); } - ctx = cmd_get_ctx(); - ctx->curclient = c; + ctx = cmd_get_ctx(NULL, c); ctx->error = key_bindings_error; ctx->print = key_bindings_print; ctx->info = key_bindings_info; diff --git a/cmd.c b/cmd.c index 23e86cff..5c02314f 100644 --- a/cmd.c +++ b/cmd.c @@ -133,13 +133,16 @@ int cmd_find_index_offset(const char *, struct session *, int *); struct window_pane *cmd_find_pane_offset(const char *, struct winlink *); struct cmd_ctx * -cmd_get_ctx(void) +cmd_get_ctx(struct client *cmdclient, struct client *curclient) { struct cmd_ctx *ctx; ctx = xcalloc(1, sizeof *ctx); ctx->references = 0; + ctx->cmdclient = cmdclient; + ctx->curclient = curclient; + cmd_ref_ctx(ctx); return (ctx); } diff --git a/control.c b/control.c index 8e3c4e87..b0368df1 100644 --- a/control.c +++ b/control.c @@ -108,8 +108,7 @@ control_callback(struct client *c, int closed, unused void *data) break; } - ctx = cmd_get_ctx(); - ctx->curclient = c; + ctx = cmd_get_ctx(NULL, c); ctx->error = control_msg_error; ctx->print = control_msg_print; ctx->info = control_msg_info; diff --git a/key-bindings.c b/key-bindings.c index f510ba68..9e5a729a 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -266,8 +266,7 @@ key_bindings_dispatch(struct key_binding *bd, struct client *c) struct cmd *cmd; int readonly; - ctx = cmd_get_ctx(); - ctx->curclient = c; + ctx = cmd_get_ctx(NULL, c); ctx->error = key_bindings_error; ctx->print = key_bindings_print; ctx->info = key_bindings_info; diff --git a/server-client.c b/server-client.c index 47a84bc0..56dd3797 100644 --- a/server-client.c +++ b/server-client.c @@ -869,9 +869,8 @@ server_client_msg_command(struct client *c, struct msg_command_data *data) int argc; char **argv, *cause; - ctx = cmd_get_ctx(); + ctx = cmd_get_ctx(c, NULL); ctx->msgdata = data; - ctx->cmdclient = c; ctx->error = server_client_msg_error; ctx->print = server_client_msg_print; ctx->info = server_client_msg_info; diff --git a/server-fn.c b/server-fn.c index c09f1b7e..26f93d95 100644 --- a/server-fn.c +++ b/server-fn.c @@ -239,7 +239,7 @@ server_lock_client(struct client *c) size_t cmdlen; struct msg_lock_data lockdata; - if (!(c->flags & CLIENT_CONTROL)) + if (c->flags & CLIENT_CONTROL) return; if (c->flags & CLIENT_SUSPENDED) diff --git a/tmux.h b/tmux.h index f5691e91..8772175a 100644 --- a/tmux.h +++ b/tmux.h @@ -1714,7 +1714,7 @@ long long args_strtonum( struct args *, u_char, long long, long long, char **); /* cmd.c */ -struct cmd_ctx *cmd_get_ctx(void); +struct cmd_ctx *cmd_get_ctx(struct client *, struct client *); void cmd_free_ctx(struct cmd_ctx *); void cmd_ref_ctx(struct cmd_ctx *); int cmd_pack_argv(int, char **, char *, size_t); diff --git a/window-choose.c b/window-choose.c index 366c65d3..ae471847 100644 --- a/window-choose.c +++ b/window-choose.c @@ -220,8 +220,7 @@ window_choose_data_run(struct window_choose_data *cdata) return; } - ctx = cmd_get_ctx(); - ctx->curclient = cdata->start_client; + ctx = cmd_get_ctx(NULL, cdata->start_client); ctx->error = key_bindings_error; ctx->print = key_bindings_print; ctx->info = key_bindings_info;