mirror of https://github.com/mpv-player/mpv
osc: don't spam window-controls bindings on every render
Not sure when this actually started happening, but it's probably been like this for years. Currently, the logic for the window-controls works by simply checking if the osc is visible and then either enabling or disabling the associated keybindings. The problem is that this can just constantly spam mp.enable_keybindings/disable_key_bindings on every single render call if the user disables the border at any point in time. This does a lot of pointless work and also results in the logs being spammed with lines like "disable-section". Clearly, this should just work like the code for checking the input keybindings just above it. Keep track of an internal state variable and check when it doesn't match the osc visibility. In that case, we can then either enable or disable the key bindings and just update the variable.
This commit is contained in:
parent
7eb8f81091
commit
bca516bd2c
|
@ -122,6 +122,7 @@ local state = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
input_enabled = true,
|
input_enabled = true,
|
||||||
showhide_enabled = false,
|
showhide_enabled = false,
|
||||||
|
windowcontrols_buttons = false,
|
||||||
dmx_cache = 0,
|
dmx_cache = 0,
|
||||||
using_video_margins = false,
|
using_video_margins = false,
|
||||||
border = true,
|
border = true,
|
||||||
|
@ -2409,10 +2410,15 @@ function render()
|
||||||
for _,cords in ipairs(osc_param.areas["window-controls"]) do
|
for _,cords in ipairs(osc_param.areas["window-controls"]) do
|
||||||
if state.osc_visible then -- activate only when OSC is actually visible
|
if state.osc_visible then -- activate only when OSC is actually visible
|
||||||
set_virt_mouse_area(cords.x1, cords.y1, cords.x2, cords.y2, "window-controls")
|
set_virt_mouse_area(cords.x1, cords.y1, cords.x2, cords.y2, "window-controls")
|
||||||
|
end
|
||||||
|
if state.osc_visible ~= state.windowcontrols_buttons then
|
||||||
|
if state.osc_visible then
|
||||||
mp.enable_key_bindings("window-controls")
|
mp.enable_key_bindings("window-controls")
|
||||||
else
|
else
|
||||||
mp.disable_key_bindings("window-controls")
|
mp.disable_key_bindings("window-controls")
|
||||||
end
|
end
|
||||||
|
state.windowcontrols_buttons = state.osc_visible
|
||||||
|
end
|
||||||
|
|
||||||
if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then
|
if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then
|
||||||
mouse_over_osc = true
|
mouse_over_osc = true
|
||||||
|
|
Loading…
Reference in New Issue