@@ -49,6 +49,7 @@ local user_opts = {
4949 boxmaxchars = 80 , -- title crop threshold for box layout
5050 boxvideo = false , -- apply osc_param.video_margins to video
5151 dynamic_margins = false , -- update margins dynamically with OSC visibility
52+ sub_margins = true , -- adjust sub-margin-y to not overlap with OSC
5253 windowcontrols = " auto" , -- whether to show window controls
5354 windowcontrols_alignment = " right" , -- which side to show window controls on
5455 windowcontrols_title = " ${media-title}" , -- same as title but for windowcontrols
@@ -184,6 +185,7 @@ local margins_opts = {
184185 {" t" , " video-margin-ratio-top" },
185186 {" b" , " video-margin-ratio-bottom" },
186187}
188+ local sub_margin_opt = " file-local-options/sub-margin-y"
187189
188190local tick_delay = 1 / 60
189191local audio_track_count = 0
@@ -541,13 +543,26 @@ local function cache_enabled()
541543 return state .cache_state and # state .cache_state [" seekable-ranges" ] > 0
542544end
543545
546+ local function set_margin_offset (prop , offset )
547+ if offset > 0 then
548+ if not state [prop ] then
549+ state [prop ] = mp .get_property_number (prop )
550+ end
551+ mp .set_property_number (prop , state [prop ] + offset )
552+ elseif state [prop ] then
553+ mp .set_property_number (prop , state [prop ])
554+ state [prop ] = nil
555+ end
556+ end
557+
544558local function reset_margins ()
545559 if state .using_video_margins then
546560 for _ , mopt in ipairs (margins_opts ) do
547561 mp .set_property_number (mopt [2 ], 0.0 )
548562 end
549563 state .using_video_margins = false
550564 end
565+ set_margin_offset (sub_margin_opt , 0 )
551566end
552567
553568local function update_margins ()
@@ -586,6 +601,23 @@ local function update_margins()
586601 reset_margins ()
587602 end
588603
604+ local function get_margin (ent )
605+ local margin = 0
606+ if user_opts [ent .. " _margins" ] then
607+ local align = mp .get_property (ent .. " -align-y" )
608+ if align == " top" and top_vis then
609+ margin = margins .t
610+ elseif align == " bottom" and bottom_vis then
611+ margin = margins .b
612+ end
613+ end
614+ if ent == " sub" and user_opts .boxvideo and mp .get_property_bool (" sub-use-margins" ) then
615+ margin = 0
616+ end
617+ return margin * osc_param .playresy
618+ end
619+ set_margin_offset (" sub-margin-y" , get_margin (" sub" ))
620+
589621 mp .set_property_native (" user-data/osc/margins" , margins )
590622end
591623
0 commit comments