mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-22 12:11:27 -07:00
feat(subtitle-sidebar): add sidebar config surface (#28)
This commit is contained in:
42
src/renderer/overlay-mouse-ignore.ts
Normal file
42
src/renderer/overlay-mouse-ignore.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { RendererContext } from './context';
|
||||
import type { RendererState } from './state';
|
||||
|
||||
function isBlockingOverlayModalOpen(state: RendererState): boolean {
|
||||
const embeddedSidebarOpen =
|
||||
state.subtitleSidebarModalOpen && state.subtitleSidebarConfig?.layout === 'embedded';
|
||||
|
||||
return Boolean(
|
||||
state.controllerSelectModalOpen ||
|
||||
state.controllerDebugModalOpen ||
|
||||
state.jimakuModalOpen ||
|
||||
state.kikuModalOpen ||
|
||||
state.runtimeOptionsModalOpen ||
|
||||
state.subsyncModalOpen ||
|
||||
state.sessionHelpModalOpen ||
|
||||
(state.subtitleSidebarModalOpen && !embeddedSidebarOpen),
|
||||
);
|
||||
}
|
||||
|
||||
export function syncOverlayMouseIgnoreState(ctx: RendererContext): void {
|
||||
const shouldStayInteractive =
|
||||
ctx.state.isOverSubtitle ||
|
||||
ctx.state.isOverSubtitleSidebar ||
|
||||
ctx.state.yomitanPopupVisible ||
|
||||
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 });
|
||||
}
|
||||
Reference in New Issue
Block a user