mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-07 04:06:07 -05:00
config: replace union in config struct with simple width/height members
This commit is contained in:
parent
0beed9fcf6
commit
adde947fc5
5 changed files with 16 additions and 46 deletions
14
config.c
14
config.c
|
|
@ -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,
|
||||
|
|
|
|||
12
config.h
12
config.h
|
|
@ -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;
|
||||
|
|
|
|||
14
main.c
14
main.c
|
|
@ -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);
|
||||
|
|
|
|||
8
render.c
8
render.c
|
|
@ -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;
|
||||
|
|
|
|||
14
server.c
14
server.c
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue