mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-18 00:21:41 -07:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { applyOverlayClickThrough } from '../../core/services/overlay-click-through';
|
|
|
|
type StatsOverlayVisibilityWindow = {
|
|
isDestroyed: () => boolean;
|
|
isVisible: () => boolean;
|
|
setIgnoreMouseEvents: (ignore: boolean, options?: { forward?: boolean }) => void;
|
|
};
|
|
|
|
function makeOverlayMousePassive(window: StatsOverlayVisibilityWindow | null): void {
|
|
if (!window || window.isDestroyed() || !window.isVisible()) {
|
|
return;
|
|
}
|
|
applyOverlayClickThrough(window);
|
|
}
|
|
|
|
export function createStatsOverlayVisibilityChangeHandler(deps: {
|
|
setStatsOverlayVisibleState: (visible: boolean) => void;
|
|
resetVisibleOverlayInteraction: () => void;
|
|
getMainWindow: () => StatsOverlayVisibilityWindow | null;
|
|
updateVisibleOverlayVisibility: () => void;
|
|
}) {
|
|
return (visible: boolean): void => {
|
|
deps.setStatsOverlayVisibleState(visible);
|
|
deps.resetVisibleOverlayInteraction();
|
|
|
|
if (visible) {
|
|
makeOverlayMousePassive(deps.getMainWindow());
|
|
deps.updateVisibleOverlayVisibility();
|
|
return;
|
|
}
|
|
|
|
deps.updateVisibleOverlayVisibility();
|
|
makeOverlayMousePassive(deps.getMainWindow());
|
|
};
|
|
}
|