diff options
author | Dudemanguy <random342@airmail.cc> | 2022-11-27 17:10:45 -0600 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-01-24 15:56:56 +0100 |
commit | 74baedffec5a8c4dfa1e603c9e2b8c03d164fb79 (patch) | |
tree | b4984e9dcfa3ae0ed2e40e81f81e32849c1dc63d | |
parent | 495206dd413f4d0b0572032c3b98c887dbb6f982 (diff) | |
download | mpv-74baedffec5a8c4dfa1e603c9e2b8c03d164fb79.tar.bz2 mpv-74baedffec5a8c4dfa1e603c9e2b8c03d164fb79.tar.xz |
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.
-rw-r--r-- | player/lua/osc.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 67b6621256..a244280a35 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -122,6 +122,7 @@ local state = { enabled = true, input_enabled = true, showhide_enabled = false, + windowcontrols_buttons = false, dmx_cache = 0, using_video_margins = false, border = true, @@ -2409,9 +2410,14 @@ function render() for _,cords in ipairs(osc_param.areas["window-controls"]) do 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") - mp.enable_key_bindings("window-controls") - else - mp.disable_key_bindings("window-controls") + end + if state.osc_visible ~= state.windowcontrols_buttons then + if state.osc_visible then + mp.enable_key_bindings("window-controls") + else + mp.disable_key_bindings("window-controls") + end + state.windowcontrols_buttons = state.osc_visible end if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then |