mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-20 12:11:28 -07:00
Improve startup dictionary progress and fix overlay/plugin input handlin
- show a dedicated startup OSD "building" phase for character dictionary sync - forward bare `Tab` from visible overlay to mpv so AniSkip works while focused - fix Windows plugin env override resolution for `SUBMINER_BINARY_PATH`
This commit is contained in:
61
src/core/services/overlay-window-input.ts
Normal file
61
src/core/services/overlay-window-input.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
export type OverlayWindowKind = 'visible' | 'modal';
|
||||
|
||||
export function isTabInputForMpvForwarding(input: Electron.Input): boolean {
|
||||
if (input.type !== 'keyDown' || input.isAutoRepeat) return false;
|
||||
if (input.alt || input.control || input.meta || input.shift) return false;
|
||||
return input.code === 'Tab' || input.key === 'Tab';
|
||||
}
|
||||
|
||||
function isLookupWindowToggleInput(input: Electron.Input): boolean {
|
||||
if (input.type !== 'keyDown') return false;
|
||||
if (input.alt) return false;
|
||||
if (!input.control && !input.meta) return false;
|
||||
if (input.shift) return false;
|
||||
const normalizedKey = typeof input.key === 'string' ? input.key.toLowerCase() : '';
|
||||
return input.code === 'KeyY' || normalizedKey === 'y';
|
||||
}
|
||||
|
||||
function isKeyboardModeToggleInput(input: Electron.Input): boolean {
|
||||
if (input.type !== 'keyDown') return false;
|
||||
if (input.alt) return false;
|
||||
if (!input.control && !input.meta) return false;
|
||||
if (!input.shift) return false;
|
||||
const normalizedKey = typeof input.key === 'string' ? input.key.toLowerCase() : '';
|
||||
return input.code === 'KeyY' || normalizedKey === 'y';
|
||||
}
|
||||
|
||||
export function handleOverlayWindowBeforeInputEvent(options: {
|
||||
kind: OverlayWindowKind;
|
||||
windowVisible: boolean;
|
||||
input: Electron.Input;
|
||||
preventDefault: () => void;
|
||||
sendKeyboardModeToggleRequested: () => void;
|
||||
sendLookupWindowToggleRequested: () => void;
|
||||
tryHandleOverlayShortcutLocalFallback: (input: Electron.Input) => boolean;
|
||||
forwardTabToMpv: () => void;
|
||||
}): boolean {
|
||||
if (options.kind === 'modal') return false;
|
||||
if (!options.windowVisible) return false;
|
||||
|
||||
if (isKeyboardModeToggleInput(options.input)) {
|
||||
options.preventDefault();
|
||||
options.sendKeyboardModeToggleRequested();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isLookupWindowToggleInput(options.input)) {
|
||||
options.preventDefault();
|
||||
options.sendLookupWindowToggleRequested();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isTabInputForMpvForwarding(options.input)) {
|
||||
options.preventDefault();
|
||||
options.forwardTabToMpv();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!options.tryHandleOverlayShortcutLocalFallback(options.input)) return false;
|
||||
options.preventDefault();
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user