mirror of
https://github.com/mpv-player/mpv
synced 2025-01-30 19:52:14 +00:00
options: add conversion to string for geometry option types
Pretty messy, which is why it wasn't done at first. (Also, I'd really like to have simpler syntax and semantics for this damn option, but who knows when this will happen.) Fixes #1705.
This commit is contained in:
parent
1ad4a62336
commit
81a63545a0
@ -1990,6 +1990,35 @@ error:
|
||||
#undef READ_NUM
|
||||
#undef READ_SIGN
|
||||
|
||||
#define APPEND_PER(F, F_PER) \
|
||||
res = talloc_asprintf_append(res, "%d%s", gm->F, gm->F_PER ? "%" : "")
|
||||
|
||||
static char *print_geometry(const m_option_t *opt, const void *val)
|
||||
{
|
||||
const struct m_geometry *gm = val;
|
||||
char *res = talloc_strdup(NULL, "");
|
||||
if (gm->wh_valid || gm->xy_valid) {
|
||||
if (gm->wh_valid) {
|
||||
APPEND_PER(w, w_per);
|
||||
res = talloc_asprintf_append(res, "x");
|
||||
APPEND_PER(h, h_per);
|
||||
}
|
||||
if (gm->xy_valid) {
|
||||
res = talloc_asprintf_append(res, "+");
|
||||
if (gm->x_sign)
|
||||
res = talloc_asprintf_append(res, "-");
|
||||
APPEND_PER(x, x_per);
|
||||
res = talloc_asprintf_append(res, "+");
|
||||
if (gm->y_sign)
|
||||
res = talloc_asprintf_append(res, "-");
|
||||
APPEND_PER(y, y_per);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef APPEND_PER
|
||||
|
||||
// xpos,ypos: position of the left upper corner
|
||||
// widw,widh: width and height of the window
|
||||
// scrw,scrh: width and height of the current screen
|
||||
@ -2053,6 +2082,7 @@ const m_option_type_t m_option_type_geometry = {
|
||||
.name = "Window geometry",
|
||||
.size = sizeof(struct m_geometry),
|
||||
.parse = parse_geometry,
|
||||
.print = print_geometry,
|
||||
.copy = copy_opt,
|
||||
};
|
||||
|
||||
@ -2082,6 +2112,7 @@ const m_option_type_t m_option_type_size_box = {
|
||||
.name = "Window size",
|
||||
.size = sizeof(struct m_geometry),
|
||||
.parse = parse_size_box,
|
||||
.print = print_geometry,
|
||||
.copy = copy_opt,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user