diff options
author | wm4 <wm4@nowhere> | 2019-12-19 22:43:22 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-12-19 22:43:22 +0100 |
commit | 99cc13e3d1788a5605e0ce0e174d942237da5319 (patch) | |
tree | 15c935337bc702e416617706c4fce89c1a11b497 /player/lua | |
parent | 69fb2ddbc7b8ccec31348be4b7357ad9a8d48896 (diff) | |
download | mpv-99cc13e3d1788a5605e0ce0e174d942237da5319.tar.bz2 mpv-99cc13e3d1788a5605e0ce0e174d942237da5319.tar.xz |
osc: fade out if paused and mouse position is outside of OSC
This broke with the recent changes since tick() is not called regularly
anymore in paused mode. Add an explicit timer for this.
Diffstat (limited to 'player/lua')
-rw-r--r-- | player/lua/osc.lua | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 54909593f6..12d1781a83 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -128,6 +128,7 @@ local state = { fullscreen = false, tick_timer = nil, tick_last_time = 0, -- when the last tick() was run + hide_timer = nil, cache_state = nil, idle = false, enabled = true, @@ -2297,11 +2298,23 @@ function render() end -- autohide - if not (state.showtime == nil) and (user_opts.hidetimeout >= 0) - and (state.showtime + (user_opts.hidetimeout/1000) < now) - and (state.active_element == nil) and not (mouse_over_osc) then - - hide_osc() + if not (state.showtime == nil) and (user_opts.hidetimeout >= 0) then + local timeout = state.showtime + (user_opts.hidetimeout/1000) - now + if timeout <= 0 then + if (state.active_element == nil) and not (mouse_over_osc) then + hide_osc() + end + else + -- the timer is only used to recheck the state and to possibly run + -- the code below again + if not state.hide_timer then + state.hide_timer = mp.add_timeout(0, tick) + end + state.hide_timer.timeout = timeout + -- re-arm + state.hide_timer:kill() + state.hide_timer:resume() + end end |