1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 00:07:33 +00:00

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.
This commit is contained in:
wm4 2020-03-14 15:15:44 +01:00
parent ea13ec6d98
commit cb2b5553bf

View File

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