From 3ab6af4f59dd21e3c9c514a25be380f883d608fe Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Sun, 14 Feb 2016 05:20:54 +0200 Subject: osc: fix runtime enable_osc(true/false) There were few issues: - When it's disabled and then enabled, it was displaying the osc briefly and then autohide right away. Don't do that. - When it's enabled and then disabled, it was not removing the osc from screen if called while the osc is visible (because tick() is responsible for the hide but it doesn't render() the empty osc when the osc is disabled). - Due to delayed/async unbinding of mouse events it was possible to show_osc() after it got disabled e.g. from mouse_move. Prevent this. --- player/lua/osc.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 993c103f3f..9643a0aa35 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -1607,6 +1607,9 @@ end function show_osc() + -- show when disabled can happen (e.g. mouse_move) due to async/delayed unbinding + if not state.enabled then return end + msg.debug("show_osc") --remember last time of invocation (mouse move) state.showtime = mp.get_time() @@ -1616,12 +1619,17 @@ function show_osc() if (user_opts.fadeduration > 0) then state.anitype = nil end - end function hide_osc() msg.debug("hide_osc") - if (user_opts.fadeduration > 0) then + if not state.enabled then + -- typically hide happens at render() from tick(), but now tick() is + -- no-op and won't render again to remove the osc, so do that manually. + state.osc_visible = false + timer_stop() + render() -- state.osc_visible == false -> remove the osc from screen + elseif (user_opts.fadeduration > 0) then if not(state.osc_visible == false) then state.anitype = "out" control_timer() @@ -1958,9 +1966,8 @@ function enable_osc(enable) state.enabled = enable if enable then do_enable_keybindings() - show_osc() else - hide_osc() + hide_osc() -- acts immediately when state.enabled == false if state.showhide_enabled then mp.disable_key_bindings("showhide") end -- cgit v1.2.3