[codex] Make Windows mpv shortcut self-contained (#40)

This commit is contained in:
2026-04-03 21:35:18 -07:00
committed by GitHub
parent d6c72806bb
commit 7514985feb
131 changed files with 3367 additions and 716 deletions

View File

@@ -38,6 +38,7 @@ export function createKeyboardHandlers(
let pendingSelectionAnchorAfterSubtitleSeek: 'start' | 'end' | null = null;
let pendingLookupRefreshAfterSubtitleSeek = false;
let resetSelectionToStartOnNextSubtitleSync = false;
let lookupScanFallbackTimer: ReturnType<typeof setTimeout> | null = null;
const CHORD_MAP = new Map<
string,
@@ -358,12 +359,10 @@ export function createKeyboardHandlers(
});
}
function isSubtitleSeekCommand(command: (string | number)[] | undefined): command is [string, number] {
return (
Array.isArray(command) &&
command[0] === 'sub-seek' &&
typeof command[1] === 'number'
);
function isSubtitleSeekCommand(
command: (string | number)[] | undefined,
): command is [string, number] {
return Array.isArray(command) && command[0] === 'sub-seek' && typeof command[1] === 'number';
}
function dispatchConfiguredMpvCommand(command: (string | number)[]): void {
@@ -485,7 +484,9 @@ export function createKeyboardHandlers(
});
}
// Fallback only if the explicit scan path did not open popup quickly.
setTimeout(() => {
if (lookupScanFallbackTimer !== null) clearTimeout(lookupScanFallbackTimer);
lookupScanFallbackTimer = setTimeout(() => {
lookupScanFallbackTimer = null;
if (ctx.state.yomitanPopupVisible || isYomitanPopupVisible(document)) {
return;
}
@@ -525,6 +526,10 @@ export function createKeyboardHandlers(
return false;
}
if (lookupScanFallbackTimer !== null) {
clearTimeout(lookupScanFallbackTimer);
lookupScanFallbackTimer = null;
}
dispatchYomitanPopupVisibility(false);
dispatchYomitanFrontendClearActiveTextSource();
clearNativeSubtitleSelection();