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.
This commit is contained in:
Daniel Eklöf 2020-03-27 21:14:49 +01:00
parent 728e23863c
commit 758fd9fd58
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 69 additions and 9 deletions

View file

@ -33,6 +33,8 @@ print_usage(const char *prog_name)
printf("\n");
printf("Options:\n");
printf(" -t,--term=TERM value to set the environment variable TERM to (foot)\n"
" --maximized start in maximized mode\n"
" --fullscreen start in fullscreen mode\n"
" --login-shell start shell as a login shell\n"
" -s,--server-socket=PATH path to the server UNIX domain socket (default=$XDG_RUNTIME_DIR/foot-$XDG_SESSION_ID.sock)\n"
" -l,--log-colorize=[never|always|auto] enable/disable colorization of log output on stderr\n"
@ -48,6 +50,8 @@ main(int argc, char *const *argv)
static const struct option longopts[] = {
{"term", required_argument, 0, 't'},
{"maximized", no_argument, 0, 'm'},
{"fullscreen", no_argument, 0, 'F'},
{"login-shell", no_argument, 0, 'L'},
{"server-socket", required_argument, 0, 's'},
{"log-colorize", optional_argument, NULL, 'l'},
@ -60,6 +64,8 @@ main(int argc, char *const *argv)
const char *server_socket_path = NULL;
enum log_colorize log_colorize = LOG_COLORIZE_AUTO;
bool login_shell = false;
bool maximized = false;
bool fullscreen = false;
while (true) {
int c = getopt_long(argc, argv, ":t:s:l::hv", longopts, NULL);
@ -75,6 +81,16 @@ main(int argc, char *const *argv)
login_shell = true;
break;
case ',':
maximized = true;
fullscreen = false;
break;
case 'F':
fullscreen = true;
maximized = false;
break;
case 's':
server_socket_path = optarg;
break;
@ -177,6 +193,8 @@ main(int argc, char *const *argv)
/* Calculate total length */
total_len += sizeof(cwd_len) + cwd_len;
total_len += sizeof(term_len) + term_len;
total_len += sizeof(uint8_t); /* maximized */
total_len += sizeof(uint8_t); /* fullscreen */
total_len += sizeof(uint8_t); /* login_shell */
total_len += sizeof(argc);
@ -207,6 +225,16 @@ main(int argc, char *const *argv)
goto err;
}
if (send(fd, &(uint8_t){maximized}, sizeof(uint8_t), 0) != sizeof(uint8_t)) {
LOG_ERRNO("failed to send maximized");
goto err;
}
if (send(fd, &(uint8_t){fullscreen}, sizeof(uint8_t), 0) != sizeof(uint8_t)) {
LOG_ERRNO("failed to send fullscreen");
goto err;
}
if (send(fd, &(uint8_t){login_shell}, sizeof(uint8_t), 0) != sizeof(uint8_t)) {
LOG_ERRNO("failed to send login-shell");
goto err;