mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-18 12:18:29 -07:00
fix(overlay): restore mpv focus and pointer state on macOS (#104)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
type RefreshableWindowTracker = {
|
||||
refreshNow: () => Promise<void>;
|
||||
};
|
||||
|
||||
export type MacOSModalFocusHandoffDeps = {
|
||||
platform: NodeJS.Platform;
|
||||
focusMpv: () => Promise<void>;
|
||||
getWindowTracker: () => RefreshableWindowTracker | null;
|
||||
updateVisibleOverlayVisibility: () => void;
|
||||
warn: (message: string, details?: unknown) => void;
|
||||
};
|
||||
|
||||
export async function restoreMacOSMpvFocusAfterModalClose(
|
||||
deps: MacOSModalFocusHandoffDeps,
|
||||
): Promise<void> {
|
||||
if (deps.platform !== 'darwin') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await deps.focusMpv();
|
||||
} catch (error) {
|
||||
deps.warn('Failed to focus mpv after macOS modal close', error);
|
||||
}
|
||||
|
||||
try {
|
||||
await deps.getWindowTracker()?.refreshNow();
|
||||
} catch (error) {
|
||||
deps.warn('Failed to refresh macOS mpv focus after modal close', error);
|
||||
}
|
||||
|
||||
deps.updateVisibleOverlayVisibility();
|
||||
}
|
||||
Reference in New Issue
Block a user