summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-03-14 15:15:44 +0100
committerwm4 <wm4@nowhere>2020-03-14 15:15:44 +0100
commitcb2b5553bfd87ef4a91f946b4ef123f9e0b522d1 (patch)
treee95fedf5be406e748dd45c91247055ef3a754d2c
parentea13ec6d985112dfb9611cd49bced369185a6494 (diff)
downloadmpv-cb2b5553bfd87ef4a91f946b4ef123f9e0b522d1.tar.bz2
mpv-cb2b5553bfd87ef4a91f946b4ef123f9e0b522d1.tar.xz
osc: fix updating message when paused
The message_timeout field was basically polled. But ever since the OSC was changed to work more event based, this didn't quite work. It was quite visible when switching subtitle or audio tracks while paused (and with caching disabled, since the cache update triggered some extra redrawing). Fix by using a proper timer. I noticed that changing tracks with the message call commented didn't redraw properly either, but, uh, I guess the message is always triggered anyway, and happens to take care of this.
-rw-r--r--player/lua/osc.lua17
1 files changed, 12 insertions, 5 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index e7b027cfb7..e689e8aeb4 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -103,7 +103,7 @@ local state = {
initREQ = false, -- is a re-init request pending?
last_mouseX, last_mouseY, -- last mouse position, to detect significant mouse movement
message_text,
- message_timeout,
+ message_hide_timer,
fullscreen = false,
tick_timer = nil,
tick_last_time = 0, -- when the last tick() was run
@@ -907,12 +907,20 @@ function show_message(text, duration)
text = string.gsub(text, "\n", "\\N")
state.message_text = text
- state.message_timeout = mp.get_time() + duration
+
+ if not state.message_hide_timer then
+ state.message_hide_timer = mp.add_timeout(0, request_tick)
+ end
+ state.message_hide_timer:kill()
+ state.message_hide_timer.timeout = duration
+ state.message_hide_timer:resume()
+ request_tick()
end
function render_message(ass)
- if not(state.message_timeout == nil) and not(state.message_text == nil)
- and state.message_timeout > mp.get_time() then
+ if state.message_hide_timer and state.message_hide_timer:is_enabled() and
+ state.message_text
+ then
local _, lines = string.gsub(state.message_text, "\\N", "")
local fontsize = tonumber(mp.get_property("options/osd-font-size"))
@@ -930,7 +938,6 @@ function render_message(ass)
ass:append(style .. state.message_text)
else
state.message_text = nil
- state.message_timeout = nil
end
end