fix(overlay): honor mpv subtitle binding config and tidy modal close

This commit is contained in:
2026-02-27 00:45:15 -08:00
parent 77c698e00b
commit dde51f8634
4 changed files with 24 additions and 8 deletions

View File

@@ -135,6 +135,20 @@ test('dispatchMpvProtocolMessage enforces sub-visibility hidden when overlay sup
}); });
}); });
test('dispatchMpvProtocolMessage skips sub-visibility suppression when overlay binding is disabled', async () => {
const { deps, state } = createDeps({
shouldBindVisibleOverlayToMpvSubVisibility: () => false,
isVisibleOverlayVisible: () => true,
});
await dispatchMpvProtocolMessage(
{ event: 'property-change', name: 'sub-visibility', data: 'yes' },
deps,
);
assert.equal(state.commands.length, 0);
});
test('dispatchMpvProtocolMessage sets secondary subtitle track based on track list response', async () => { test('dispatchMpvProtocolMessage sets secondary subtitle track based on track list response', async () => {
const { deps, state } = createDeps(); const { deps, state } = createDeps();

View File

@@ -220,7 +220,8 @@ export async function dispatchMpvProtocolMessage(
} else if (msg.name === 'sub-visibility') { } else if (msg.name === 'sub-visibility') {
if ( if (
deps.isVisibleOverlayVisible() && deps.isVisibleOverlayVisible() &&
asBoolean(msg.data, false) asBoolean(msg.data, false) &&
(deps.shouldBindVisibleOverlayToMpvSubVisibility?.() ?? true)
) { ) {
deps.sendCommand({ command: ['set_property', 'sub-visibility', 'no'] }); deps.sendCommand({ command: ['set_property', 'sub-visibility', 'no'] });
} }

View File

@@ -758,7 +758,10 @@ const restoreOverlayMpvSubtitles = createRestoreOverlayMpvSubtitlesHandler({
}); });
function shouldSuppressMpvSubtitlesForOverlay(): boolean { function shouldSuppressMpvSubtitlesForOverlay(): boolean {
return overlayManager.getVisibleOverlayVisible(); return (
overlayManager.getVisibleOverlayVisible() &&
configDerivedRuntime.shouldBindVisibleOverlayToMpvSubVisibility()
);
} }
function syncOverlayMpvSubtitleSuppression(): void { function syncOverlayMpvSubtitleSuppression(): void {

View File

@@ -232,16 +232,14 @@ export function createOverlayModalRuntimeService(
const handleOverlayModalClosed = (modal: OverlayHostedModal): void => { const handleOverlayModalClosed = (modal: OverlayHostedModal): void => {
if (!restoreVisibleOverlayOnModalClose.has(modal)) return; if (!restoreVisibleOverlayOnModalClose.has(modal)) return;
restoreVisibleOverlayOnModalClose.delete(modal); restoreVisibleOverlayOnModalClose.delete(modal);
const modalWindow = deps.getModalWindow();
if (restoreVisibleOverlayOnModalClose.size === 0) { if (restoreVisibleOverlayOnModalClose.size === 0) {
clearPendingModalWindowReveal(); clearPendingModalWindowReveal();
notifyModalStateChange(false); notifyModalStateChange(false);
} if (modalWindow && !modalWindow.isDestroyed()) {
const modalWindow = deps.getModalWindow();
if (!modalWindow || modalWindow.isDestroyed()) return;
if (restoreVisibleOverlayOnModalClose.size === 0) {
modalWindow.hide(); modalWindow.hide();
} }
}
}; };
const notifyOverlayModalOpened = (modal: OverlayHostedModal): void => { const notifyOverlayModalOpened = (modal: OverlayHostedModal): void => {