Skip to content

Commit 7c0e92f

Browse files
committed
osc.lua: add osd-margin option
Fixes: #17539
1 parent 25f0f6d commit 7c0e92f

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
add `osc-dynamic_margins` option
22
add `osc-sub-margin` option
3+
add `osc-osd-margin` option

DOCS/man/osc.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,15 @@ Configurable Options
420420
already confined to the video area and this option has no additional
421421
effect.
422422

423+
``osd_margins``
424+
Default: yes
425+
426+
Whether to adjust ``--osd-margin-y`` so that OSD text does not overlap
427+
with the OSC. The offset is derived from the top OSC margin (including
428+
window controls when present) and added on top of the current
429+
``--osd-margin-y`` value. Requires ``dynamic_margins`` or
430+
``visibility=always`` to take effect.
431+
423432
``windowcontrols``
424433
Default: auto (Show window controls if there is no window border)
425434

player/lua/osc.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ local user_opts = {
5050
boxvideo = false, -- apply osc_param.video_margins to video
5151
dynamic_margins = false, -- update margins dynamically with OSC visibility
5252
sub_margins = true, -- adjust sub-margin-y to not overlap with OSC
53+
osd_margins = true, -- adjust osd-margin-y to not overlap with OSC
5354
windowcontrols = "auto", -- whether to show window controls
5455
windowcontrols_alignment = "right", -- which side to show window controls on
5556
windowcontrols_title = "${media-title}", -- same as title but for windowcontrols
@@ -186,6 +187,7 @@ local margins_opts = {
186187
{"b", "video-margin-ratio-bottom"},
187188
}
188189
local sub_margin_opt = "file-local-options/sub-margin-y"
190+
local osd_margin_opt = "file-local-options/osd-margin-y"
189191

190192
local tick_delay = 1 / 60
191193
local audio_track_count = 0
@@ -563,6 +565,7 @@ local function reset_margins()
563565
state.using_video_margins = false
564566
end
565567
set_margin_offset(sub_margin_opt, -1)
568+
set_margin_offset(osd_margin_opt, -1)
566569
end
567570

568571
local function update_margins()
@@ -614,6 +617,8 @@ local function update_margins()
614617
end
615618
end
616619
set_margin_offset("sub-margin-y", sub_margin and sub_margin * 720 or 0)
620+
local need_osd = top_vis and user_opts.osd_margins
621+
set_margin_offset("osd-margin-y", need_osd and margins.t * 720 or 0)
617622

618623
mp.set_property_native("user-data/osc/margins", margins)
619624
end

0 commit comments

Comments
 (0)