fix: cmd+w closed window cannot restore

https://github.com/keybase/client/pull/3317/files

https://github.com/maxogden/menubar/pull/101
This commit is contained in:
林一二 2021-10-28 01:01:14 +08:00
parent 14642e07cf
commit d4a000c99c
2 changed files with 6 additions and 4 deletions

View file

@ -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

View file

@ -230,13 +230,12 @@ export class WorkspaceView implements IWorkspaceViewService {
}
public async setActiveWorkspaceView(workspaceID: string): Promise<void> {
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