From fd756a150b43d319d08ac4117f34edef9e0438c4 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 27 Aug 2021 17:15:57 +0000 Subject: Allow control mode clients to set a hard limit on the window width and height, GitHub issue 2594. --- server-client.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index ac9a7475..062e72d4 100644 --- a/server-client.c +++ b/server-client.c @@ -2443,7 +2443,7 @@ server_client_get_flags(struct client *c) } /* Get client window. */ -static struct client_window * +struct client_window * server_client_get_client_window(struct client *c, u_int id) { struct client_window cw = { .window = id }; @@ -2451,6 +2451,21 @@ server_client_get_client_window(struct client *c, u_int id) return (RB_FIND(client_windows, &c->windows, &cw)); } +/* Add client window. */ +struct client_window * +server_client_add_client_window(struct client *c, u_int id) +{ + struct client_window *cw; + + cw = server_client_get_client_window(c, id); + if (cw == NULL) { + cw = xcalloc(1, sizeof *cw); + cw->window = id; + RB_INSERT(client_windows, &c->windows, cw); + } + return cw; +} + /* Get client active pane. */ struct window_pane * server_client_get_pane(struct client *c) @@ -2479,12 +2494,7 @@ server_client_set_pane(struct client *c, struct window_pane *wp) if (s == NULL) return; - cw = server_client_get_client_window(c, s->curw->window->id); - if (cw == NULL) { - cw = xcalloc(1, sizeof *cw); - cw->window = s->curw->window->id; - RB_INSERT(client_windows, &c->windows, cw); - } + cw = server_client_add_client_window(c, s->curw->window->id); cw->pane = wp; log_debug("%s pane now %%%u", c->name, wp->id); } -- cgit From daec63e5e6eb3390d53f4bf7f8a327df77e46c95 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 27 Aug 2021 17:25:55 +0000 Subject: Replace %% in command lists (by copying them) for template arguments , this means they can be used with {} as well. Also make argument processing from an existing vector preserve commands. GitHub issue 2858. --- server-client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 062e72d4..a7cad0a5 100644 --- a/server-client.c +++ b/server-client.c @@ -2124,6 +2124,7 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg) int argc; char **argv, *cause; struct cmd_parse_result *pr; + struct args_value *values; if (c->flags & CLIENT_EXIT) return; @@ -2149,7 +2150,8 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg) *argv = xstrdup("new-session"); } - pr = cmd_parse_from_arguments(argc, argv, NULL); + values = args_from_vector(argc, argv); + pr = cmd_parse_from_arguments(values, argc, NULL); switch (pr->status) { case CMD_PARSE_ERROR: cause = pr->error; @@ -2157,6 +2159,8 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg) case CMD_PARSE_SUCCESS: break; } + args_free_values(values, argc); + free(values); cmd_free_argv(argc, argv); cmdq_append(c, cmdq_get_command(pr->cmdlist, NULL)); -- cgit