This commit is contained in:
2026-03-23 21:47:25 -07:00
parent 23a73a94e6
commit 96f327e4dc
6 changed files with 166 additions and 81 deletions

View File

@@ -5993,16 +5993,23 @@ mp.add_timeout(0, function()
_lua_log('lyric-helper auto-start raised: ' .. tostring(lyric_err))
end
-- Try to re-register right-click after UOSC loads (might override its binding)
mp.add_timeout(1.0, function()
_lua_log('[KEY] attempting to re-register mbtn_right after UOSC loaded')
pcall(function()
mp.add_key_binding("mbtn_right", "medios-menu-right-click-late", function()
_lua_log('[KEY] mbtn_right pressed (late registration attempt)')
-- Force-claim mbtn_right so the Medios menu fires reliably regardless of
-- whether uosc has a cursor zone active at the click position.
-- mp.add_forced_key_binding has higher priority than uosc's force-group.
-- Use complex=true to get the event type and fire only on button release.
local ok_rclick, rclick_err = pcall(function()
mp.add_forced_key_binding('mbtn_right', 'medios-mbtn-right-forced', function(e)
if e and e.event == 'up' then
_lua_log('[KEY] mbtn_right up -> show_menu')
M.show_menu()
end, {repeatable=false})
end)
end
end, {complex = true, repeatable = false})
end)
if ok_rclick then
_lua_log('[KEY] registered forced mbtn_right binding')
else
_lua_log('[KEY] forced mbtn_right failed: ' .. tostring(rclick_err) .. ' (falling back to input.conf)')
end
end)
return M

View File

@@ -1166,11 +1166,6 @@ class MPVIPCClient:
rid = request["request_id"]
payload = json.dumps(request) + "\n"
# Debug: log the command being sent
from SYS.logger import debug as _debug
_debug(f"[IPC] Sending: {payload.strip()}")
# Send command
self._write_payload(payload)
@@ -1199,11 +1194,6 @@ class MPVIPCClient:
continue
resp = json.loads(line)
# Debug: log responses
from SYS.logger import debug as _debug
_debug(f"[IPC] Received: {line}")
# Check if this is the response to our request
if resp.get("request_id") == request.get("request_id"):
return resp

View File

@@ -1766,27 +1766,35 @@ def main(argv: Optional[list[str]] = None) -> int:
# Keep trying.
time.sleep(0.10)
command_client = MPVIPCClient(socket_path=str(args.ipc), timeout=0.75, silent=True)
use_shared_ipc_client = platform.system() == "Windows"
command_client = None if use_shared_ipc_client else MPVIPCClient(socket_path=str(args.ipc), timeout=0.75, silent=True)
def _send_helper_command(command: Any, label: str = "") -> bool:
with command_client_lock:
target_client = client if use_shared_ipc_client else command_client
if target_client is None:
return False
try:
if command_client.sock is None:
if not command_client.connect():
if target_client.sock is None:
if use_shared_ipc_client:
if note_ipc_unavailable is not None:
note_ipc_unavailable(f"helper-command-connect:{label or '?'}")
return False
if not target_client.connect():
_append_helper_log(
f"[helper-ipc] connect failed label={label or '?'}"
)
_note_ipc_unavailable(f"helper-command-connect:{label or '?' }")
return False
_mark_ipc_alive(f"helper-command-connect:{label or '?'}")
rid = command_client.send_command_no_wait(command)
rid = target_client.send_command_no_wait(command)
if rid is None:
_append_helper_log(
f"[helper-ipc] send failed label={label or '?'}"
)
_note_ipc_unavailable(f"helper-command-send:{label or '?'}")
try:
command_client.disconnect()
target_client.disconnect()
except Exception:
pass
return False
@@ -1798,7 +1806,7 @@ def main(argv: Optional[list[str]] = None) -> int:
)
_note_ipc_unavailable(f"helper-command-exception:{label or '?'}")
try:
command_client.disconnect()
target_client.disconnect()
except Exception:
pass
return False
@@ -1906,19 +1914,24 @@ def main(argv: Optional[list[str]] = None) -> int:
except Exception:
pass
_start_ready_heartbeat(
str(args.ipc),
stop_event,
_mark_ipc_alive,
_note_ipc_unavailable,
)
_start_request_poll_loop(
str(args.ipc),
stop_event,
_process_request,
_mark_ipc_alive,
_note_ipc_unavailable,
)
if use_shared_ipc_client:
_append_helper_log(
"[helper] Windows single-client IPC mode enabled; auxiliary heartbeat/poll disabled"
)
else:
_start_ready_heartbeat(
str(args.ipc),
stop_event,
_mark_ipc_alive,
_note_ipc_unavailable,
)
_start_request_poll_loop(
str(args.ipc),
stop_event,
_process_request,
_mark_ipc_alive,
_note_ipc_unavailable,
)
# Pre-compute store choices at startup and publish to a cached property so Lua
# can read immediately without waiting for a request/response cycle (which may timeout).
@@ -2075,10 +2088,11 @@ def main(argv: Optional[list[str]] = None) -> int:
_append_helper_log(f"[helper] exiting reason={shutdown_reason}")
except Exception:
pass
try:
command_client.disconnect()
except Exception:
pass
if command_client is not None:
try:
command_client.disconnect()
except Exception:
pass
try:
client.disconnect()
except Exception:

View File

@@ -68,7 +68,7 @@ loop-file
# Enable the screensaver when images are kept open forever.
[screensaver]
profile-cond=p['current-tracks/video'].image and image_display_duration == math.huge
profile-cond=get('current-tracks/video', {}).image and image_display_duration == math.huge
profile-restore=copy
stop-screensaver=no

View File

@@ -249,7 +249,7 @@ function TopBar:render()
local button_fg = is_hover and (button.hover_fg or bg) or fg
local button_bg = is_hover and (button.hover_bg or fg) or bg
cursor:zone('primary_down', rect, button.command)
cursor:zone('primary_click', rect, button.command)
local bg_size = self.size - margin
local bg_ax, bg_ay = rect.ax + (is_left and margin or 0), rect.ay + margin
@@ -302,7 +302,7 @@ function TopBar:render()
if left_aligned then title_bx = rect.ax - margin else title_ax = rect.bx + margin end
-- Click action
cursor:zone('primary_down', rect, function() mp.command('script-binding uosc/playlist') end)
cursor:zone('primary_click', rect, function() mp.command('script-binding uosc/playlist') end)
end
-- Skip rendering titles if there's not enough horizontal space
@@ -325,7 +325,7 @@ function TopBar:render()
local title_rect = {ax = ax, ay = title_ay, bx = ax + rect_width, by = by}
if options.top_bar_alt_title_place == 'toggle' then
cursor:zone('primary_down', title_rect, function() self:toggle_title() end)
cursor:zone('primary_click', title_rect, function() self:toggle_title() end)
end
ass:rect(title_rect.ax, title_rect.ay, title_rect.bx, title_rect.by, {
@@ -415,7 +415,7 @@ function TopBar:render()
-- Click action
rect.bx = time_bx
cursor:zone('primary_down', rect, function() mp.command('script-binding uosc/chapters') end)
cursor:zone('primary_click', rect, function() mp.command('script-binding uosc/chapters') end)
title_ay = rect.by + self.title_spacing
end