summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.lua24
1 files changed, 17 insertions, 7 deletions
diff --git a/main.lua b/main.lua
index bf853b6..19a40f3 100644
--- a/main.lua
+++ b/main.lua
@@ -1286,7 +1286,6 @@ local mouse_over_button_area = false
local mouse_over_toggle_button = false
local mouse_timer; mouse_timer = mp.add_periodic_timer(0.1, function()
if mouse_pos_time and
- not mouse_over_toggle_button and
mp.get_time() - mouse_pos_time >
config.toggle_button_timeout then
osd:show_toggle_button(false)
@@ -1314,12 +1313,6 @@ mp.observe_property('mouse-pos', 'native', function(_, mpos)
osd:show_toggle_button(true)
end
- if mouse_over_button_area then
- mouse_timer:resume()
- else
- mouse_timer:kill()
- end
-
local is_over = osd:mouse_over_toggle_button(mpos)
if is_over ~= mouse_over_toggle_button then
mouse_over_toggle_button = is_over
@@ -1329,6 +1322,12 @@ mp.observe_property('mouse-pos', 'native', function(_, mpos)
mp.disable_key_bindings('toggle_button')
end
end
+
+ if mouse_over_button_area and not mouse_over_toggle_button then
+ mouse_timer:resume()
+ else
+ mouse_timer:kill()
+ end
end)
mp.observe_property('user-data/osc/visibility', 'native', function(_, val)
@@ -1340,6 +1339,17 @@ end)
mp.observe_property('osd-dimensions', 'native', function(_, val)
osd:resize(val.w, val.h)
osd:redraw(state)
+
+ -- after a resize, mpv does not update the mouse coordinates until the
+ -- mouse is moved. if the mouse was previously over the button and we
+ -- do nothing, a click would trigger the button regardless of mouse
+ -- position. since we cannot get the new mouse position, we instead
+ -- treat all resizes as moving the mouse off the button.
+ osd:show_toggle_button(false)
+ mouse_over_button_area = false
+ mouse_over_toggle_button = false
+ mp.disable_key_bindings('toggle_button')
+ mouse_timer:kill()
end)
mp.register_event('start-file', function()