mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-09 04:19:27 -07:00
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import type { RendererContext } from './context';
|
|
import type { RendererState } from './state';
|
|
import { isYomitanPopupVisible } from './yomitan-popup.js';
|
|
|
|
function isBlockingOverlayModalOpen(state: RendererState): boolean {
|
|
return Boolean(
|
|
state.controllerSelectModalOpen ||
|
|
state.controllerDebugModalOpen ||
|
|
state.jimakuModalOpen ||
|
|
state.youtubePickerModalOpen ||
|
|
state.kikuModalOpen ||
|
|
state.runtimeOptionsModalOpen ||
|
|
state.subsyncModalOpen ||
|
|
state.sessionHelpModalOpen,
|
|
);
|
|
}
|
|
|
|
function isYomitanPopupInteractionActive(state: RendererState): boolean {
|
|
if (state.yomitanPopupVisible) {
|
|
return true;
|
|
}
|
|
if (typeof document === 'undefined') {
|
|
return false;
|
|
}
|
|
return isYomitanPopupVisible(document);
|
|
}
|
|
|
|
export function syncOverlayMouseIgnoreState(ctx: RendererContext): void {
|
|
const shouldStayInteractive =
|
|
ctx.state.isOverSubtitle ||
|
|
ctx.state.isOverSubtitleSidebar ||
|
|
isYomitanPopupInteractionActive(ctx.state) ||
|
|
isBlockingOverlayModalOpen(ctx.state);
|
|
|
|
if (shouldStayInteractive) {
|
|
ctx.dom.overlay.classList.add('interactive');
|
|
} else {
|
|
ctx.dom.overlay.classList.remove('interactive');
|
|
}
|
|
if (!ctx.platform?.shouldToggleMouseIgnore) {
|
|
return;
|
|
}
|
|
|
|
if (shouldStayInteractive) {
|
|
window.electronAPI.setIgnoreMouseEvents(false);
|
|
return;
|
|
}
|
|
|
|
window.electronAPI.setIgnoreMouseEvents(true, { forward: true });
|
|
}
|