From d4805395fa1c7af59b5543ad4bf3fe6a531b25ca Mon Sep 17 00:00:00 2001 From: sudacode Date: Thu, 26 Feb 2026 19:29:51 -0800 Subject: [PATCH] fix: suppress mpv primary subtitles when visible overlay is enabled --- src/core/services/mpv-protocol.test.ts | 2 +- src/core/services/mpv-protocol.ts | 3 +-- src/core/services/mpv.ts | 7 ++++++- src/main.ts | 5 +---- src/main/runtime/overlay-mpv-sub-visibility.ts | 1 + 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/services/mpv-protocol.test.ts b/src/core/services/mpv-protocol.test.ts index 787f19e..3c75a48 100644 --- a/src/core/services/mpv-protocol.test.ts +++ b/src/core/services/mpv-protocol.test.ts @@ -131,7 +131,7 @@ test('dispatchMpvProtocolMessage enforces sub-visibility hidden when overlay sup ); assert.deepEqual(state.commands.pop(), { - command: ['set_property', 'sub-visibility', false], + command: ['set_property', 'sub-visibility', 'no'], }); }); diff --git a/src/core/services/mpv-protocol.ts b/src/core/services/mpv-protocol.ts index 919b2ee..c6ed542 100644 --- a/src/core/services/mpv-protocol.ts +++ b/src/core/services/mpv-protocol.ts @@ -219,11 +219,10 @@ export async function dispatchMpvProtocolMessage( }); } else if (msg.name === 'sub-visibility') { if ( - deps.shouldBindVisibleOverlayToMpvSubVisibility?.() && deps.isVisibleOverlayVisible() && asBoolean(msg.data, false) ) { - deps.sendCommand({ command: ['set_property', 'sub-visibility', false] }); + deps.sendCommand({ command: ['set_property', 'sub-visibility', 'no'] }); } } else if (msg.name === 'sub-use-margins') { deps.emitSubtitleMetricsChange({ diff --git a/src/core/services/mpv.ts b/src/core/services/mpv.ts index ec6ebc0..516cbc7 100644 --- a/src/core/services/mpv.ts +++ b/src/core/services/mpv.ts @@ -473,8 +473,13 @@ export class MpvIpcClient implements MpvClient { } setSubVisibility(visible: boolean): void { + const value = visible ? 'yes' : 'no'; this.send({ - command: ['set_property', 'sub-visibility', visible], + command: ['set_property', 'sub-visibility', value], + }); + // Compatibility write for mpv command aliases across setups. + this.send({ + command: ['set', 'sub-visibility', value], }); } diff --git a/src/main.ts b/src/main.ts index 6cdc734..f15f035 100644 --- a/src/main.ts +++ b/src/main.ts @@ -758,10 +758,7 @@ const restoreOverlayMpvSubtitles = createRestoreOverlayMpvSubtitlesHandler({ }); function shouldSuppressMpvSubtitlesForOverlay(): boolean { - return ( - overlayManager.getVisibleOverlayVisible() && - configDerivedRuntime.shouldBindVisibleOverlayToMpvSubVisibility() - ); + return overlayManager.getVisibleOverlayVisible(); } function syncOverlayMpvSubtitleSuppression(): void { diff --git a/src/main/runtime/overlay-mpv-sub-visibility.ts b/src/main/runtime/overlay-mpv-sub-visibility.ts index 1640834..ec994e6 100644 --- a/src/main/runtime/overlay-mpv-sub-visibility.ts +++ b/src/main/runtime/overlay-mpv-sub-visibility.ts @@ -25,6 +25,7 @@ function parseSubVisibility(value: unknown): boolean { return true; } + export function createEnsureOverlayMpvSubtitlesHiddenHandler(deps: { getMpvClient: () => MpvVisibilityClient | null; getSavedSubVisibility: () => boolean | null;