diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-25 00:24:18 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-25 00:25:00 -0800 |
| commit | 1d2c82bfb4dcfd71045f2948bb320a94013971a5 (patch) | |
| tree | 33282ef00974badcfdeba14d4a7f78efcf6920e0 | |
| parent | 6c9ad9a77dd67145b9015bb13018534025e33a49 (diff) | |
| download | mpv-iptv-menu-1d2c82bfb4dcfd71045f2948bb320a94013971a5.tar.gz mpv-iptv-menu-1d2c82bfb4dcfd71045f2948bb320a94013971a5.tar.xz | |
more explicit activation of key handler
| -rw-r--r-- | input.lua | 25 | ||||
| -rw-r--r-- | main.lua | 4 | ||||
| -rw-r--r-- | osd.lua | 2 | ||||
| -rw-r--r-- | rt.lua | 10 |
4 files changed, 21 insertions, 20 deletions
@@ -154,28 +154,27 @@ end -- -- nonexistent `nodrag' section is enabled to disable VO dragging while the -- menu is open. -function input.set_key_bindings() - if osd:is_hidden() then - if mapping_bound then - mp.remove_key_binding('mouse_move') - mp.remove_key_binding('unmapped') - mp.command_native({'disable-section', 'nodrag'}) - mp.command_native({ - 'enable-section', 'default', - 'allow-hide-cursor+allow-vo-dragging'}) - mapping_bound = false - end +function input.activate(bool) + if mapping_bound == bool then return end - if not mapping_bound then + if bool then mp.command_native({'disable-section', 'default'}) mp.command_native({'enable-section', 'nodrag'}) mp.add_forced_key_binding('MOUSE_MOVE', 'mouse_move') -- noisy mp.add_forced_key_binding( 'UNMAPPED', 'unmapped', handle_key, {complex = true}) - mapping_bound = true + else + mp.remove_key_binding('mouse_move') + mp.remove_key_binding('unmapped') + mp.command_native({'disable-section', 'nodrag'}) + mp.command_native({ + 'enable-section', 'default', + 'allow-hide-cursor+allow-vo-dragging'}) end + + mapping_bound = bool end local function bind_click(f) @@ -113,7 +113,7 @@ state:push_menu({title = 'mpv-iptv-menu'}) state.saved_osc_visibility = mp.get_property_native( 'user-data/osc/visibility', 'auto') -rt.set_osc_visibility() +rt.set_osc_visibility(false) mp.add_forced_key_binding('TAB', 'toggle-menu', rt.toggle_menu) @@ -191,7 +191,7 @@ input.define_mapping('SEARCH', { ['Ctrl+e'] = {rt.search_cursor_end}, }) input.set_mapping('MENU') -input.set_key_bindings() +input.activate(true) mp.add_timeout(0, function() rt.load_data() @@ -639,6 +639,8 @@ function mt:toggle_hidden() else self:draw_img() end + + return hidden end function mt:is_hidden() @@ -1025,19 +1025,19 @@ function rt.reload_data() rt.push_group_menu(ctx.catalogue:get('root')) end -function rt.set_osc_visibility() - local v = osd:is_hidden() and state.saved_osc_visibility or 'never' +function rt.set_osc_visibility(osd_hidden) + local v = osd_hidden and state.saved_osc_visibility or 'never' mp.command_native({'script-message', 'osc-visibility', v, ''}) end function rt.toggle_menu() - osd:toggle_hidden() + local hidden = osd:toggle_hidden() if state.saved_osc_visibility ~= 'never' then - rt.set_osc_visibility() + rt.set_osc_visibility(hidden) end - input.set_key_bindings() + input.activate(not hidden) end return rt |
