diff --git a/src/services/windows/index.ts b/src/services/windows/index.ts index d6e9f2ad..deeee59f 100644 --- a/src/services/windows/index.ts +++ b/src/services/windows/index.ts @@ -102,7 +102,6 @@ export class Window implements IWindowService { await this.setWindowMeta(windowName, meta); const existedWindowMeta = await this.getWindowMeta(windowName); - // handle existed window, bring existed window to the front and return. if (existedWindow !== undefined) { if (recreate === true || (typeof recreate === 'function' && existedWindowMeta !== undefined && recreate(existedWindowMeta))) { existedWindow.close(); @@ -520,7 +519,6 @@ export class Window implements IWindowService { minWidth: 250, }), }); - menuBar.app.commandLine.appendSwitch('disable-backgrounding-occluded-windows', 'true'); menuBar.on('after-create-window', () => { if (menuBar.window !== undefined) { @@ -530,6 +528,11 @@ export class Window implements IWindowService { view.webContents.focus(); } }); + menuBar.window.removeAllListeners('close'); + menuBar.window.on('close', (event) => { + event.preventDefault(); + menuBar.hideWindow(); + }); } }); // https://github.com/maxogden/menubar/issues/120 diff --git a/src/services/workspacesView/index.ts b/src/services/workspacesView/index.ts index 3e4d7770..b6215adf 100644 --- a/src/services/workspacesView/index.ts +++ b/src/services/workspacesView/index.ts @@ -230,13 +230,12 @@ export class WorkspaceView implements IWorkspaceViewService { } public async setActiveWorkspaceView(workspaceID: string): Promise { - const mainWindow = this.windowService.get(WindowNames.main); const oldActiveWorkspace = await this.workspaceService.getActiveWorkspace(); const newWorkspace = await this.workspaceService.get(workspaceID); if (newWorkspace === undefined) { throw new Error(`Workspace id ${workspaceID} does not exist. When setActiveWorkspaceView().`); } - if (mainWindow !== undefined && oldActiveWorkspace !== undefined) { + if (oldActiveWorkspace !== undefined) { await this.workspaceService.setActiveWorkspace(workspaceID); await this.viewService.setActiveViewForAllBrowserViews(workspaceID); // if we are switching to a new workspace, we hibernate old view, and activate new view