summaryrefslogtreecommitdiffstats
path: root/player/lua/osc.lua
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2022-11-27 17:10:45 -0600
committerDudemanguy <random342@airmail.cc>2022-11-29 16:40:36 +0000
commitbca516bd2c282670aa2c92663329e7d5ddf978e0 (patch)
treee453fdf80fbc9f285280c7ea10c698af317db820 /player/lua/osc.lua
parent7eb8f81091008d4e90dfc758df27342a541327f3 (diff)
downloadmpv-bca516bd2c282670aa2c92663329e7d5ddf978e0.tar.bz2
mpv-bca516bd2c282670aa2c92663329e7d5ddf978e0.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.
Diffstat (limited to 'player/lua/osc.lua')
-rw-r--r--player/lua/osc.lua12
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