aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2020-11-22 00:12:23 +0000
committerCraig Barnes <craigbarnes@protonmail.com>2020-11-22 18:52:28 +0000
commit748f98e0c0e5629b24b7bb9db6baa0e40fc325b9 (patch)
treee4bfdbfa7ecfe2af60dcbc0cb0df226a3d5ba7bc
parentMerge branch 'pgo' (diff)
client: add "--window-size-pixels" and "--window-size-chars" options
-rw-r--r--client-protocol.h3
-rw-r--r--client.c50
-rw-r--r--server.c16
3 files changed, 56 insertions, 13 deletions
diff --git a/client-protocol.h b/client-protocol.h
index cf99c1d9..a99d4ecf 100644
--- a/client-protocol.h
+++ b/client-protocol.h
@@ -10,6 +10,9 @@ struct client_argv {
};
struct client_data {
+ unsigned width;
+ unsigned height;
+ uint8_t size_type:1; // Values correspond to enum conf_size_type
uint8_t maximized:1;
uint8_t fullscreen:1;
uint8_t hold:1;
diff --git a/client.c b/client.c
index a9d823c7..8eb969d6 100644
--- a/client.c
+++ b/client.c
@@ -54,23 +54,28 @@ main(int argc, char *const *argv)
const char *const prog_name = argv[0];
static const struct option longopts[] = {
- {"term", required_argument, NULL, 't'},
- {"title", required_argument, NULL, 'T'},
- {"app-id", required_argument, NULL, 'a'},
- {"maximized", no_argument, NULL, 'm'},
- {"fullscreen", no_argument, NULL, 'F'},
- {"login-shell", no_argument, NULL, 'L'},
- {"server-socket", required_argument, NULL, 's'},
- {"hold", no_argument, NULL, 'H'},
- {"log-colorize", optional_argument, NULL, 'l'},
- {"version", no_argument, NULL, 'v'},
- {"help", no_argument, NULL, 'h'},
- {NULL, no_argument, NULL, 0},
+ {"term", required_argument, NULL, 't'},
+ {"title", required_argument, NULL, 'T'},
+ {"app-id", required_argument, NULL, 'a'},
+ {"window-size-pixels", required_argument, NULL, 'w'},
+ {"window-size-chars", required_argument, NULL, 'W'},
+ {"maximized", no_argument, NULL, 'm'},
+ {"fullscreen", no_argument, NULL, 'F'},
+ {"login-shell", no_argument, NULL, 'L'},
+ {"server-socket", required_argument, NULL, 's'},
+ {"hold", no_argument, NULL, 'H'},
+ {"log-colorize", optional_argument, NULL, 'l'},
+ {"version", no_argument, NULL, 'v'},
+ {"help", no_argument, NULL, 'h'},
+ {NULL, no_argument, NULL, 0},
};
const char *term = "";
const char *title = "";
const char *app_id = "";
+ unsigned size_type = 0; // enum conf_size_type (without pulling in tllist/fcft via config.h)
+ unsigned width = 0;
+ unsigned height = 0;
const char *server_socket_path = NULL;
enum log_colorize log_colorize = LOG_COLORIZE_AUTO;
bool login_shell = false;
@@ -79,7 +84,7 @@ main(int argc, char *const *argv)
bool hold = false;
while (true) {
- int c = getopt_long(argc, argv, "+t:T:a:mFLs:Hl::vh", longopts, NULL);
+ int c = getopt_long(argc, argv, "+t:T:a:w:W:mFLs:Hl::vh", longopts, NULL);
if (c == -1)
break;
@@ -100,6 +105,22 @@ main(int argc, char *const *argv)
login_shell = true;
break;
+ case 'w':
+ if (sscanf(optarg, "%ux%u", &width, &height) != 2 || width == 0 || height == 0) {
+ fprintf(stderr, "error: invalid window-size-pixels: %s\n", optarg);
+ return EXIT_FAILURE;
+ }
+ size_type = 0; // CONF_SIZE_PX
+ break;
+
+ case 'W':
+ if (sscanf(optarg, "%ux%u", &width, &height) != 2 || width == 0 || height == 0) {
+ fprintf(stderr, "error: invalid window-size-chars: %s\n", optarg);
+ return EXIT_FAILURE;
+ }
+ size_type = 1; // CONF_SIZE_CELLS
+ break;
+
case 'm':
maximized = true;
fullscreen = false;
@@ -215,6 +236,9 @@ main(int argc, char *const *argv)
const size_t app_id_len = strlen(app_id) + 1;
const struct client_data data = {
+ .width = width,
+ .height = height,
+ .size_type = size_type,
.maximized = maximized,
.fullscreen = fullscreen,
.hold = hold,
diff --git a/server.c b/server.c
index 464fc1f1..6e2f514f 100644
--- a/server.c
+++ b/server.c
@@ -263,6 +263,22 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
else if (cdata.fullscreen)
client->conf.startup_mode = STARTUP_FULLSCREEN;
+ if (cdata.width > 0 && cdata.height > 0) {
+ client->conf.size.type = cdata.size_type;
+
+ switch (cdata.size_type) {
+ case CONF_SIZE_PX:
+ client->conf.size.px.width = cdata.width;
+ client->conf.size.px.height = cdata.height;
+ break;
+
+ case CONF_SIZE_CELLS:
+ client->conf.size.cells.width = cdata.width;
+ client->conf.size.cells.height = cdata.height;
+ break;
+ }
+ }
+
client->term = term_init(
&client->conf, server->fdm, server->reaper, server->wayl,
"footclient", cwd, cdata.argc, argv, &term_shutdown_handler, client);