0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 20:03:10 +02:00

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.
This commit is contained in:
Avi Halachmi (:avih) 2016-02-14 05:20:54 +02:00 committed by ChrisK2
parent 49660bcc3e
commit 3ab6af4f59

View File

@ -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