diff options
author | wm4 <wm4@nowhere> | 2015-03-24 21:50:35 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-03-24 21:50:35 +0100 |
commit | 81a63545a031fdb5ca9fc459e59c9f4b02992511 (patch) | |
tree | 6a2fbaf63b2cf6fec882e1709306c189cb868226 /options | |
parent | 1ad4a62336c2b6f02bc1968c91b877b6d4951c58 (diff) | |
download | mpv-81a63545a031fdb5ca9fc459e59c9f4b02992511.tar.bz2 mpv-81a63545a031fdb5ca9fc459e59c9f4b02992511.tar.xz |
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.
Diffstat (limited to 'options')
-rw-r--r-- | options/m_option.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/options/m_option.c b/options/m_option.c index e0d35e6a24..ea4b8d18b9 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -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, }; |