diff --git a/player/javascript.c b/player/javascript.c index fa3b09c7f3..8d0e7715f1 100644 --- a/player/javascript.c +++ b/player/javascript.c @@ -743,15 +743,6 @@ static void push_nums_obj(js_State *J, const char * const names[], } } -// args: none, return: object with properties top, bottom, left, right -static void script_get_osd_margins(js_State *J) -{ - struct mp_osd_res r = osd_get_vo_res(jctx(J)->mpctx->osd); - const char * const names[] = {"left", "top", "right", "bottom", NULL}; - const double vals[] = {r.ml, r.mt, r.mr, r.mb}; - push_nums_obj(J, names, vals); -} - // args: none, return: object with properties x, y static void script_get_mouse_pos(js_State *J) { @@ -1237,7 +1228,6 @@ static const struct fn_entry main_fns[] = { FN_ENTRY(get_wakeup_pipe, 0), FN_ENTRY(_hook_add, 3), FN_ENTRY(_hook_continue, 1), - FN_ENTRY(get_osd_margins, 0), FN_ENTRY(get_mouse_pos, 0), FN_ENTRY(input_set_section_mouse_area, 5), FN_ENTRY(last_error, 0), diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js index 18edab35b7..0a1c99bcef 100644 --- a/player/javascript/defaults.js +++ b/player/javascript/defaults.js @@ -238,11 +238,14 @@ mp.set_osd_ass = function set_osd_ass(res_x, res_y, data) { return mp._legacy_overlay.update(); } +// the following return undefined on error, null passthrough, or legacy object mp.get_osd_size = function get_osd_size() { - var w = mp.get_property_number("osd-width", 0), - h = mp.get_property_number("osd-height", 0), - par = mp.get_property_number("osd-par", 0); - return {width: w, height: h, aspect: w / (h || 1) / (par || 1)}; + var d = mp.get_property_native("osd-dimensions"); + return d && {width: d.w, height: d.h, aspect: d.aspect}; +} +mp.get_osd_margins = function get_osd_margins() { + var d = mp.get_property_native("osd-dimensions"); + return d && {left: d.ml, right: d.mr, top: d.mt, bottom: d.mb}; } /**********************************************************************