fix: address claude review feedback on overlay refactor

This commit is contained in:
2026-02-26 18:47:51 -08:00
parent fa0cb00f70
commit 337e3268f1
28 changed files with 95 additions and 197 deletions

View File

@@ -212,10 +212,6 @@ export function registerIpcHandlers(deps: IpcServiceDeps, ipc: IpcMainRegistrar
deps.toggleDevTools();
});
ipc.handle(IPC_CHANNELS.request.getOverlayVisibility, () => {
return deps.getVisibleOverlayVisibility();
});
ipc.on(IPC_CHANNELS.command.toggleOverlay, () => {
deps.toggleVisibleOverlay();
});

View File

@@ -131,23 +131,7 @@ test('dispatchMpvProtocolMessage enforces sub-visibility hidden when overlay sup
);
assert.deepEqual(state.commands.pop(), {
command: ['set_property', 'sub-visibility', 'no'],
});
});
test('dispatchMpvProtocolMessage enforces secondary sub-visibility hidden when overlay suppression is enabled', async () => {
const { deps, state } = createDeps({
shouldBindVisibleOverlayToMpvSubVisibility: () => true,
isVisibleOverlayVisible: () => true,
});
await dispatchMpvProtocolMessage(
{ event: 'property-change', name: 'secondary-sub-visibility', data: 'yes' },
deps,
);
assert.deepEqual(state.commands.pop(), {
command: ['set_property', 'secondary-sub-visibility', 'no'],
command: ['set_property', 'sub-visibility', false],
});
});

View File

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

View File

@@ -474,7 +474,7 @@ export class MpvIpcClient implements MpvClient {
setSubVisibility(visible: boolean): void {
this.send({
command: ['set_property', 'sub-visibility', visible ? 'yes' : 'no'],
command: ['set_property', 'sub-visibility', visible],
});
}

View File

@@ -15,7 +15,7 @@ export function updateVisibleOverlayVisibility(args: {
syncOverlayShortcuts: () => void;
isMacOSPlatform?: boolean;
showOverlayLoadingOsd?: (message: string) => void;
resolveFallbackBounds: () => WindowGeometry;
resolveFallbackBounds?: () => WindowGeometry;
}): void {
if (!args.mainWindow || args.mainWindow.isDestroyed()) {
return;
@@ -78,7 +78,9 @@ export function updateVisibleOverlayVisibility(args: {
return;
}
const fallbackBounds = args.resolveFallbackBounds();
const fallbackBounds = args.resolveFallbackBounds?.();
if (!fallbackBounds) return;
args.updateVisibleOverlayBounds(fallbackBounds);
args.syncPrimaryOverlayWindowLayer('visible');
args.mainWindow.setIgnoreMouseEvents(false);