mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-13 20:12:54 -07:00
Windows update (#49)
This commit is contained in:
@@ -23,7 +23,7 @@ test('createMainBootServices builds boot-phase service bundle', () => {
|
||||
{ kind: string },
|
||||
{ scope: string; warn: () => void; info: () => void; error: () => void },
|
||||
{ registry: boolean },
|
||||
{ getModalWindow: () => null },
|
||||
{ getMainWindow: () => null; getModalWindow: () => null },
|
||||
{
|
||||
inputState: boolean;
|
||||
getModalInputExclusive: () => boolean;
|
||||
@@ -82,6 +82,7 @@ test('createMainBootServices builds boot-phase service bundle', () => {
|
||||
}) as const,
|
||||
createMainRuntimeRegistry: () => ({ registry: true }),
|
||||
createOverlayManager: () => ({
|
||||
getMainWindow: () => null,
|
||||
getModalWindow: () => null,
|
||||
}),
|
||||
createOverlayModalInputState: () => ({
|
||||
|
||||
@@ -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