From 0d384592c57771a0371399783238c490def1b231 Mon Sep 17 00:00:00 2001 From: ossifrage <82336322+ossifrage@users.noreply.github.com> Date: Thu, 15 Apr 2021 09:44:23 -0700 Subject: osc: reset margins when using boxvideo with showfullscreen/showwindowed This fixes a bug where using boxvideo with showfullscreen=no or showwindowed=no resulted in the margins not resetting when the OSC wasn't visible. For example, using: script-opts=osc-visibility=always,osc-boxvideo=yes,osc-showfullscreen=no and then going fullscreen would make the OSC disappear but the video margins would remain. This is because boxvideo was missing a dependence on the showfullscreen and showwindowed user options. This is fixed by adding the corresponding conditions to update_margins() and setting state.marginsREQ on fullscreen changes. update_margins() is called on tick() if there's a margins update pending, which guarantees the boxvideo margins are reset appropriately. --- player/lua/osc.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'player/lua') diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 9e1978bfc3..bea95e1323 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -101,6 +101,7 @@ local state = { tc_ms = user_opts.timems, -- Should the timecodes display their time with milliseconds mp_screen_sizeX, mp_screen_sizeY, -- last screen-resolution, to detect resolution changes to issue reINITs initREQ = false, -- is a re-init request pending? + marginsREQ = false, -- is a margins update pending? last_mouseX, last_mouseY, -- last mouse position, to detect significant mouse movement mouse_in_window = false, message_text, @@ -2099,7 +2100,10 @@ function update_margins() local margins = osc_param.video_margins -- Don't use margins if it's visible only temporarily. - if (not state.osc_visible) or (get_hidetimeout() >= 0) then + if (not state.osc_visible) or (get_hidetimeout() >= 0) or + (state.fullscreen and not user_opts.showfullscreen) or + (not state.fullscreen and not user_opts.showwindowed) + then margins = {l = 0, r = 0, t = 0, b = 0} end @@ -2505,6 +2509,11 @@ local santa_hat_lines = { -- called by mpv on every frame function tick() + if state.marginsREQ == true then + update_margins() + state.marginsREQ = false + end + if (not state.enabled) then return end if (state.idle) then @@ -2608,6 +2617,7 @@ end) mp.observe_property("fullscreen", "bool", function(name, val) state.fullscreen = val + state.marginsREQ = true request_init_resize() end ) -- cgit v1.2.3