From d838bd64202464e392e330ed3240307c34f2c4bf Mon Sep 17 00:00:00 2001 From: Marcoen Hirschberg Date: Thu, 29 May 2014 23:37:47 +0200 Subject: osc: keep track of the "fullscreen" state when it changes This avoids having to poll the "fullscreen" property in the tick callback. --- player/lua/osc.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'player') diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 02044698ca..1fc3522230 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -72,6 +72,7 @@ local state = { last_mouseX, last_mouseY, -- last mouse position, to detect siginificant mouse movement message_text, message_timeout, + fullscreen = false, } @@ -587,7 +588,7 @@ function osc_init() if (mp.get_property("video") == "no") then -- dummy/forced window scale = user_opts.scaleforcedwindow - elseif (mp.get_property("fullscreen") == "yes") then + elseif state.fullscreen then scale = user_opts.scalefullscreen else scale = user_opts.scalewindowed @@ -820,7 +821,7 @@ function osc_init() --toggle FS local contentF = function (ass) - if mp.get_property("fullscreen") == "yes" then + if state.fullscreen then ass:append("\238\132\137") else ass:append("\238\132\136") @@ -1171,7 +1172,7 @@ end -- called by mpv on every frame function tick() - if (mp.get_property("fullscreen") == "yes" and user_opts.showfullscreen) or (mp.get_property("fullscreen") == "no" and user_opts.showwindowed) then + if (state.fullscreen and user_opts.showfullscreen) or (not state.fullscreen and user_opts.showwindowed) then render() else mp.set_osd_ass(osc_param.playresy, osc_param.playresy, "") @@ -1195,6 +1196,8 @@ mp.register_event("tracks-changed", request_init) mp.register_script_message("enable-osc", function() enable_osc(true) end) mp.register_script_message("disable-osc", function() enable_osc(false) end) +mp.observe_property("fullscreen", "bool", function(name, val) state.fullscreen = val end) + -- mouse show/hide bindings mp.set_key_bindings({ {"mouse_move", function(e) process_event("mouse_move", nil) end}, -- cgit v1.2.3