From 266735a7a2d57c2d8215ce7afe251f5253ce2ad3 Mon Sep 17 00:00:00 2001
From: wm4 <wm4@nowhere>
Date: Mon, 10 Aug 2015 23:51:01 +0200
Subject: [PATCH] osc: avoid annoying verbose mode log spam

enable_key_bindings()/disable_key_bindings() now prints a log message on
each call, thus we should avoid makign redundant calls.

This could probably be solved more elegantly, but since this is all
legacy/private API, don't bother.
---
 player/lua/osc.lua | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index e131127922..3301df3f36 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -79,6 +79,8 @@ local state = {
     cache_idle = false,
     idle = false,
     enabled = true,
+    input_enabled = true,
+    showhide_enabled = false,
 }
 
 
@@ -1771,9 +1773,14 @@ function render()
     for _,cords in ipairs(osc_param.areas["input"]) do
         if state.osc_visible then -- activate only when OSC is actually visible
             mp.set_mouse_area(cords.x1, cords.y1, cords.x2, cords.y2, "input")
-            mp.enable_key_bindings("input")
-        else
-            mp.disable_key_bindings("input")
+        end
+        if state.osc_visible ~= state.input_enabled then
+            if state.osc_visible then
+                mp.enable_key_bindings("input")
+            else
+                mp.disable_key_bindings("input")
+            end
+            state.input_enabled = state.osc_visible
         end
 
         if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then
@@ -1919,7 +1926,10 @@ function tick()
         ass:append("Drop files to play here.")
         mp.set_osd_ass(640, 360, ass.text)
 
-        mp.disable_key_bindings("showhide")
+        if state.showhide_enabled then
+            mp.disable_key_bindings("showhide")
+            state.showhide_enabled = false
+        end
 
 
     elseif (state.fullscreen and user_opts.showfullscreen)
@@ -1935,7 +1945,10 @@ end
 
 function do_enable_keybindings()
     if state.enabled then
-        mp.enable_key_bindings("showhide", "allow-vo-dragging+allow-hide-cursor")
+        if not state.showhide_enabled then
+            mp.enable_key_bindings("showhide", "allow-vo-dragging+allow-hide-cursor")
+        end
+        state.showhide_enabled = true
     end
 end
 
@@ -1946,7 +1959,10 @@ function enable_osc(enable)
         show_osc()
     else
         hide_osc()
-        mp.disable_key_bindings("showhide")
+        if state.showhide_enabled then
+            mp.disable_key_bindings("showhide")
+        end
+        state.showhide_enabled = false
     end
 end