From 11b9315b3fce4de1fae799d4609c66029d8cc914 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 8 Jan 2020 00:16:58 +0100 Subject: lua: use new OSD property See previous commit. A nice side-effect is that mp.get_osd_margins() is not a special Lua-only thing anymore. I didn't test whether this function still works as expected, though. --- player/lua.c | 12 ------------ player/lua/defaults.lua | 15 ++++++--------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/player/lua.c b/player/lua.c index cee4c118ad..2e5b0dec5a 100644 --- a/player/lua.c +++ b/player/lua.c @@ -998,17 +998,6 @@ static int script_raw_abort_async_command(lua_State *L) return 0; } -static int script_get_osd_margins(lua_State *L) -{ - struct MPContext *mpctx = get_mpctx(L); - struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd); - lua_pushnumber(L, vo_res.ml); - lua_pushnumber(L, vo_res.mt); - lua_pushnumber(L, vo_res.mr); - lua_pushnumber(L, vo_res.mb); - return 4; -} - static int script_get_mouse_pos(lua_State *L) { struct MPContext *mpctx = get_mpctx(L); @@ -1250,7 +1239,6 @@ static const struct fn_entry main_fns[] = { FN_ENTRY(set_property_native), FN_ENTRY(raw_observe_property), FN_ENTRY(raw_unobserve_property), - FN_ENTRY(get_osd_margins), FN_ENTRY(get_mouse_pos), FN_ENTRY(get_time), FN_ENTRY(input_set_section_mouse_area), diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua index f44d004a99..7681ca173e 100644 --- a/player/lua/defaults.lua +++ b/player/lua/defaults.lua @@ -638,17 +638,14 @@ function mp.set_osd_ass(res_x, res_y, data) end function mp.get_osd_size() - local w = mp.get_property_number("osd-width", 0) - local h = mp.get_property_number("osd-height", 0) - local par = mp.get_property_number("osd-par", 0) - if par == 0 then - par = 1 - end - - local aspect = 1.0 * w / math.max(h, 1.0) / par - return w, h, aspect + local prop = mp.get_property_native("osd-dimensions") + return prop.w, prop.h, prop.aspect end +function mp.get_osd_margins() + local prop = mp.get_property_native("osd-dimensions") + return prop.ml, prop.mt, prop.mr, prop.mb +end local mp_utils = package.loaded["mp.utils"] -- cgit v1.2.3