diff options
| author | Craig Barnes <craigbarnes@protonmail.com> | 2020-11-30 02:24:38 +0000 |
|---|---|---|
| committer | Craig Barnes <craigbarnes@protonmail.com> | 2020-11-30 02:24:38 +0000 |
| commit | adde947fc5ffc3d143040a984d0907262ac279bc (patch) | |
| tree | 1b29a75414035349d6178509e5660d917484cbc0 | |
| parent | Merge branch 'base64-optimize' (diff) | |
config: replace union in config struct with simple width/height members
| -rw-r--r-- | config.c | 14 | ||||
| -rw-r--r-- | config.h | 12 | ||||
| -rw-r--r-- | main.c | 14 | ||||
| -rw-r--r-- | render.c | 8 | ||||
| -rw-r--r-- | server.c | 14 |
5 files changed, 16 insertions, 46 deletions
@@ -486,8 +486,8 @@ parse_section_main(const char *key, const char *value, struct config *conf, } conf->size.type = CONF_SIZE_PX; - conf->size.px.width = width; - conf->size.px.height = height; + conf->size.width = width; + conf->size.height = height; } else if (strcmp(key, "initial-window-size-chars") == 0) { @@ -501,8 +501,8 @@ parse_section_main(const char *key, const char *value, struct config *conf, } conf->size.type = CONF_SIZE_CELLS; - conf->size.cells.width = width; - conf->size.cells.height = height; + conf->size.width = width; + conf->size.height = height; } else if (strcmp(key, "pad") == 0) { @@ -2016,10 +2016,8 @@ config_load(struct config *conf, const char *conf_path, .word_delimiters = xwcsdup(L",│`|:\"'()[]{}<>"), .size = { .type = CONF_SIZE_PX, - .px = { - .width = 700, - .height = 500, - }, + .width = 700, + .height = 500, }, .pad_x = 2, .pad_y = 2, @@ -64,16 +64,8 @@ struct config { struct { enum conf_size_type type; - union { - struct { - unsigned width; - unsigned height; - } px; - struct { - unsigned width; - unsigned height; - } cells; - }; + unsigned width; + unsigned height; } size; unsigned pad_x; @@ -399,18 +399,8 @@ main(int argc, char *const *argv) } if (conf_width > 0 && conf_height > 0) { conf.size.type = conf_size_type; - - switch (conf_size_type) { - case CONF_SIZE_PX: - conf.size.px.width = conf_width; - conf.size.px.height = conf_height; - break; - - case CONF_SIZE_CELLS: - conf.size.cells.width = conf_width; - conf.size.cells.height = conf_height; - break; - } + conf.size.width = conf_width; + conf.size.height = conf_height; } if (conf_server_socket_path != NULL) { free(conf.server_socket_path); @@ -2180,8 +2180,8 @@ maybe_resize(struct terminal *term, int width, int height, bool force) } else { switch (term->conf->size.type) { case CONF_SIZE_PX: - width = term->conf->size.px.width; - height = term->conf->size.px.height; + width = term->conf->size.width; + height = term->conf->size.height; if (term->window->use_csd == CSD_YES) { /* Take CSD title bar into account */ @@ -2194,8 +2194,8 @@ maybe_resize(struct terminal *term, int width, int height, bool force) break; case CONF_SIZE_CELLS: - width = term->conf->size.cells.width * term->cell_width; - height = term->conf->size.cells.height * term->cell_height; + width = term->conf->size.width * term->cell_width; + height = term->conf->size.height * term->cell_height; width += 2 * term->conf->pad_x * scale; height += 2 * term->conf->pad_y * scale; @@ -265,18 +265,8 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data) 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->conf.size.width = cdata.width; + client->conf.size.height = cdata.height; } client->term = term_init( |
