Skip to content

Commit

Permalink
Fix window revealing when navigating with multiple windows (#13561)
Browse files Browse the repository at this point in the history
Fixes: #13559

Contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
  • Loading branch information
tsmaeder authored Apr 4, 2024
1 parent 86bac3e commit 5d653b2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/electron-browser/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const api: TheiaCoreAPI = {
ipcRenderer.send(CHANNEL_SET_MENU, mainMenuId, convertMenu(menu, handlers));
},
getSecurityToken: () => ipcRenderer.sendSync(CHANNEL_GET_SECURITY_TOKEN),
focusWindow: (name: string) => ipcRenderer.send(CHANNEL_FOCUS_WINDOW, name),
focusWindow: (name?: string) => ipcRenderer.send(CHANNEL_FOCUS_WINDOW, name),
showItemInFolder: fsPath => {
ipcRenderer.send(CHANNEL_SHOW_ITEM_IN_FOLDER, fsPath);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ElectronWindowService extends DefaultWindowService {
}

override focus(): void {
window.electronTheiaCore.focusWindow(window.name);
window.electronTheiaCore.focusWindow();
}
@postConstruct()
protected init(): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/electron-common/electron-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface TheiaCoreAPI {
popup(menu: MenuDto[], x: number, y: number, onClosed: () => void, windowName?: string): Promise<number>;
closePopup(handle: number): void;

focusWindow(name: string): void;
focusWindow(name?: string): void;

showItemInFolder(fsPath: string): void;

Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/electron-main/electron-api-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ export class TheiaMainApi implements ElectronMainApplicationContribution {

// focus windows for secondary window support
ipcMain.on(CHANNEL_FOCUS_WINDOW, (event, windowName) => {
const electronWindow = BrowserWindow.getAllWindows().find(win => win.webContents.mainFrame.name === windowName);
const electronWindow = windowName
? BrowserWindow.getAllWindows().find(win => win.webContents.mainFrame.name === windowName)
: BrowserWindow.fromWebContents(event.sender);
if (electronWindow) {
if (electronWindow.isMinimized()) {
electronWindow.restore();
Expand Down

0 comments on commit 5d653b2

Please sign in to comment.