diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-10 17:32:58 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-10 17:32:58 +0000 |
commit | 4d382ae8e6c71c5414dc41053223c05400d923f8 (patch) | |
tree | 7b2f3526edeec9fb799a1228df00bd3b34439675 /cmd-find-window.c | |
parent | 418ba99078a2712ece398e17a5a9bc1f6600126b (diff) | |
download | rtmux-4d382ae8e6c71c5414dc41053223c05400d923f8.tar.gz rtmux-4d382ae8e6c71c5414dc41053223c05400d923f8.tar.bz2 rtmux-4d382ae8e6c71c5414dc41053223c05400d923f8.zip |
Miscellaneous tidying of choose API, including:
- rename client and session to start_client and start_session in
window_choose_data struct. also add TREE_OTHER define and reorder the
struct
- rename window_choose_ctx to window_choose_data_run
- don't pass a cmd_ctx into window_choose_create (will let it use a
different client later). instead take type, session, client
- add window_choose_data_free and use it to dispose of wcd rather than
each cmd-*.c doing it individually
- change so ref counting is done by wcd_add and wcd_free rather than
callers. this means 1 ref for each item but what of it :-)
- also add a ref to tree_session - not sure if this is needed?
- all the callbacks except choose-client and find-window are the same so
remove them and add window_choose_default_callback
- reorder/rename some other bits and pieces for tidyness
Diffstat (limited to 'cmd-find-window.c')
-rw-r--r-- | cmd-find-window.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/cmd-find-window.c b/cmd-find-window.c index 9a0a8a42..5c1b2133 100644 --- a/cmd-find-window.c +++ b/cmd-find-window.c @@ -31,7 +31,6 @@ enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmd_ctx *); void cmd_find_window_callback(struct window_choose_data *); -void cmd_find_window_free(struct window_choose_data *); /* Flags for determining matching behavior. */ #define CMD_FIND_WINDOW_BY_TITLE 0x1 @@ -131,6 +130,7 @@ enum cmd_retval cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; + struct client *c; struct window_choose_data *cdata; struct session *s; struct winlink *wl, *wm; @@ -143,7 +143,8 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) ctx->error(ctx, "must be run interactively"); return (CMD_RETURN_ERROR); } - s = ctx->curclient->session; + c = ctx->curclient; + s = c->session; if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) return (CMD_RETURN_ERROR); @@ -180,9 +181,8 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) for (i = 0; i < ARRAY_LENGTH(&find_list); i++) { wm = ARRAY_ITEM(&find_list, i).wl; - cdata = window_choose_data_create(ctx); + cdata = window_choose_data_create(TREE_OTHER, c, c->session); cdata->idx = wm->idx; - cdata->client->references++; cdata->wl = wm; cdata->ft_template = xstrdup(template); @@ -198,8 +198,8 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) window_choose_add(wl->window->active, cdata); } - window_choose_ready(wl->window->active, - 0, cmd_find_window_callback, cmd_find_window_free); + window_choose_ready(wl->window->active, 0, cmd_find_window_callback, + NULL); out: ARRAY_FREE(&find_list); @@ -215,7 +215,7 @@ cmd_find_window_callback(struct window_choose_data *cdata) if (cdata == NULL) return; - s = cdata->session; + s = cdata->start_session; if (!session_alive(s)) return; @@ -228,16 +228,3 @@ cmd_find_window_callback(struct window_choose_data *cdata) recalculate_sizes(); } } - -void -cmd_find_window_free(struct window_choose_data *cdata) -{ - if (cdata == NULL) - return; - - cdata->session->references--; - - free(cdata->ft_template); - format_free(cdata->ft); - free(cdata); -} |