mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-12 16:19:26 -07:00
Honor configured controller shortcuts and clean up modal opens
This commit is contained in:
@@ -74,6 +74,7 @@ export interface MainBootServicesParams<
|
||||
getModalWindow: () => BrowserWindow | null;
|
||||
syncOverlayShortcutsForModal: (isActive: boolean) => void;
|
||||
syncOverlayVisibilityForModal: () => void;
|
||||
restoreMainWindowFocus?: () => void;
|
||||
}) => TOverlayModalInputState;
|
||||
createOverlayContentMeasurementStore: (params: {
|
||||
logger: TLogger;
|
||||
@@ -131,7 +132,7 @@ export function createMainBootServices<
|
||||
TSubtitleWebSocket,
|
||||
TLogger,
|
||||
TRuntimeRegistry,
|
||||
TOverlayManager extends { getModalWindow: () => BrowserWindow | null },
|
||||
TOverlayManager extends { getMainWindow: () => BrowserWindow | null; getModalWindow: () => BrowserWindow | null },
|
||||
TOverlayModalInputState extends OverlayModalInputStateShape,
|
||||
TOverlayContentMeasurementStore,
|
||||
TOverlayModalRuntime,
|
||||
@@ -212,6 +213,26 @@ export function createMainBootServices<
|
||||
syncOverlayVisibilityForModal: () => {
|
||||
params.getSyncOverlayVisibilityForModal()();
|
||||
},
|
||||
restoreMainWindowFocus: () => {
|
||||
const mainWindow = overlayManager.getMainWindow();
|
||||
if (!mainWindow || mainWindow.isDestroyed() || !mainWindow.isVisible()) return;
|
||||
try {
|
||||
const electron = require('electron') as {
|
||||
app?: { focus?: (options?: { steal?: boolean }) => void };
|
||||
};
|
||||
electron.app?.focus?.({ steal: true });
|
||||
} catch {
|
||||
// Ignore in non-Electron environments.
|
||||
}
|
||||
const maybeFocusable = mainWindow as typeof mainWindow & {
|
||||
setFocusable?: (focusable: boolean) => void;
|
||||
};
|
||||
maybeFocusable.setFocusable?.(true);
|
||||
mainWindow.focus();
|
||||
if (!mainWindow.webContents.isFocused()) {
|
||||
mainWindow.webContents.focus();
|
||||
}
|
||||
},
|
||||
});
|
||||
const overlayContentMeasurementStore = params.createOverlayContentMeasurementStore({
|
||||
logger,
|
||||
|
||||
Reference in New Issue
Block a user