Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DOCS/interface-changes/osc-wc.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
add `osc-windowcontrols_independent` script-opt
change ``osc-windowcontrols=auto`` to enable window controls in fullscreen
add ``osc-windowcontrols=auto-windowed`` to restore the previous behavior
add ``osc-windowcontrols_deadzonesize`` script-opt
add ``osc-windowcontrols_bar`` script-opt
28 changes: 27 additions & 1 deletion DOCS/man/osc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ Configurable Options
take effect. Uses ``--osd-margin-y-offset`` to apply the adjustment.

``windowcontrols``
Default: auto (Show window controls if there is no window border/title-bar)
Default: auto

Whether to show window management controls over the video, and if so,
which side of the window to place them. This may be desirable when the
Expand All @@ -440,6 +440,14 @@ Configurable Options
and ``quit``. Not all platforms implement ``minimize`` and ``maximize``,
but ``quit`` will always work.

Possible values are:
``no``: never show window controls
``yes``: always show window controls
``auto-windowed``: show window controls when ``--title-bar`` or ``--border``
is ``no``
``auto``: show window controls when ``--title-bar`` or ``--border`` is
``no``, or when in fullscreen on platforms other than macOS

``windowcontrols_independent``
Default: yes

Expand All @@ -462,6 +470,24 @@ Configurable Options
windowcontrols title.
ASS tags are escaped, and newlines and trailing slashes are stripped.

``windowcontrols_deadzonesize``
Default: 1

Size of the deadzone. The deadzone is an area that makes the mouse act like
leaving the window. Movement there won't make the window controls show up
and it will hide immediately if the mouse enters it. The deadzone starts at
the window border opposite to the window controls and the size controls how
much of the window it will span. Values between 0.0 and 1.0, where 0 means
the window controls will always popup with mouse movement in the window, and
1 means the window controls will only show up when the mouse hovers it.

``windowcontrols_bar``
Default: auto

Whether to draw a bar and ``windowcontrols_title`` next to the buttons. Can
be ``yes``, ``no``, or ``auto``. ``auto`` draws them only when the title is
not already printed in the rest of the OSC.

``floatingtitle``
Default: yes

Expand Down
32 changes: 22 additions & 10 deletions player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ local user_opts = {
windowcontrols_alignment = "right", -- which side to show window controls on
windowcontrols_title = "${media-title}", -- same as title but for windowcontrols
windowcontrols_independent = true, -- show window controls and bottom bar independently
windowcontrols_deadzonesize = 1, -- size of the window controls deadzone
windowcontrols_bar = "auto", -- whether to draw the window controls bar
floatingtitle = true, -- show title in the floating layout?
floatingwidth = 700, -- width of the floating layout
floatingalpha = 130, -- alpha of the floating layout background
Expand Down Expand Up @@ -230,6 +232,7 @@ local margins_opts = {
{"b", "video-margin-ratio-bottom"},
}

local platform = mp.get_property("platform")
local tick_delay = 1 / 60
local window_control_box_width = 80
local layouts = {}
Expand Down Expand Up @@ -717,12 +720,16 @@ end

-- WindowControl helpers
local function window_controls_enabled()
local val = user_opts.windowcontrols
if val == "auto" then
return not (state.border and state.title_bar)
else
return val ~= "no"
if user_opts.windowcontrols == "auto" then
return not state.border or not state.title_bar or
(state.fullscreen and platform ~= "darwin")
end

if user_opts.windowcontrols == "auto-windowed" then
return not state.border or not state.title_bar
end

return user_opts.windowcontrols == "yes"
end

local function window_controls_alignment()
Expand Down Expand Up @@ -1288,8 +1295,10 @@ local function window_controls(topbar)
get_hitbox_coords(controlbox_left, wc_geo.y, wc_geo.an,
controlbox_w, wc_geo.h))

local floating_buttons_only = user_opts.layout == "floating"
and user_opts.floatingtitle
local floating_buttons_only = user_opts.windowcontrols_bar == "no" or
(user_opts.windowcontrols_bar == "auto" and
(user_opts.layout ~= "slimbox" and
(user_opts.layout ~= "floating" or user_opts.floatingtitle)))

local lo

Expand All @@ -1300,9 +1309,12 @@ local function window_controls(topbar)
lo.layer = 10
if floating_buttons_only then
-- Compact background behind buttons only
lo.alpha[1] = user_opts.floatingalpha
lo.alpha[1] = user_opts[user_opts.layout == "floating" and "floatingalpha" or "boxalpha"]
local blur_extend = 4
local r = 10
local r = 0
if user_opts.layout == "floating" or user_opts.layout == "box" then
r = 10
end
lo.geometry = {
x = controlbox_left - blur_extend,
y = wc_geo.y,
Expand Down Expand Up @@ -1384,7 +1396,7 @@ local function window_controls(topbar)
-- deadzone below window controls
local sh_area_y0, sh_area_y1
sh_area_y0 = user_opts.barmargin
sh_area_y1 = wc_geo.y + get_align(1 - (2 * user_opts.deadzonesize),
sh_area_y1 = wc_geo.y + get_align(1 - (2 * user_opts.windowcontrols_deadzonesize),
osc_param.playresy - wc_geo.y, 0, 0)
add_area("showhide_wc", wc_geo.x, sh_area_y0, wc_geo.w, sh_area_y1)
if topbar then
Expand Down
Loading