From 758fd9fd58b25ab285868db7f36afdf9378df733 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 27 Mar 2020 21:14:49 +0100 Subject: client: add --maximized and --fullscreen We now create a copy of the config for each client, and updates it with the values passed from the client. Since we're not actually cloning it (and e.g. strdup() all strings etc) we can't call conf_destroy() to free it, but need to free just the strings we've replaced. --- server.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'server.c') diff --git a/server.c b/server.c index 710e7e9d..42116f27 100644 --- a/server.c +++ b/server.c @@ -42,6 +42,7 @@ struct client { size_t idx; } buffer; + struct config conf; struct terminal *term; }; @@ -69,6 +70,11 @@ client_destroy(struct client *client) } free(client->buffer.data); + + /* TODO: clone server conf completely, so that we can just call + * conf_destroy() here */ + free(client->conf.term); + free(client); } @@ -218,6 +224,12 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data) goto shutdown; } + CHECK_BUF(sizeof(uint8_t)); + const uint8_t maximized = *(const uint8_t *)p; p += sizeof(maximized); + + CHECK_BUF(sizeof(uint8_t)); + const uint8_t fullscreen = *(const uint8_t *)p; p += sizeof(fullscreen); + CHECK_BUF(sizeof(uint8_t)); const uint8_t login_shell = *(const uint8_t *)p; p += sizeof(login_shell); @@ -244,9 +256,18 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data) #undef CHECK_BUF + client->conf = *server->conf; + client->conf.term = strlen(term_env) > 0 + ? strdup(term_env) : strdup(server->conf->term); + client->conf.login_shell = login_shell; + + if (maximized) + client->conf.startup_mode = STARTUP_MAXIMIZED; + else if (fullscreen) + client->conf.startup_mode = STARTUP_FULLSCREEN; + client->term = term_init( - server->conf, server->fdm, server->wayl, - strlen(term_env) > 0 ? term_env : server->conf->term, login_shell, + &client->conf, server->fdm, server->wayl, "footclient", cwd, argc, argv, &term_shutdown_handler, client); if (client->term == NULL) { -- cgit v1.3