diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-19 00:38:02 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-19 00:38:30 -0800 |
| commit | c244b3cd08a48a28d5a31ba5ddf86ee1669bd996 (patch) | |
| tree | 4fe9e4c71d520d38cf0f3592f1c0b7193251687d | |
| parent | 0790f4366bcd46e21792ae233f1b1c6d29e7d150 (diff) | |
| download | mpv-iptv-menu-c244b3cd08a48a28d5a31ba5ddf86ee1669bd996.tar.gz mpv-iptv-menu-c244b3cd08a48a28d5a31ba5ddf86ee1669bd996.tar.xz | |
reset mouse state on window resize
| -rw-r--r-- | main.lua | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -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() |
