Skip to content

Commit 1ce2463

Browse files
core: respect visible menu for fullscreen
The commit updates the handling of `toggle full screen` to respect `menuBarVisibility` properly. If the `menuBarVisibility` is set to `visible` the menu should be visible when the app is in fullscreen. Signed-off-by: vince-fugnitto <[email protected]>
1 parent cd33db1 commit 1ce2463

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

packages/core/src/electron-browser/menu/electron-menu-contribution.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
120120
this.shell.bottomPanel.onDidToggleMaximized(() => {
121121
this.handleToggleMaximized();
122122
});
123+
this.attachMenuBarVisibilityListener();
123124
}
124125

125126
protected attachWindowFocusListener(app: FrontendApplication): void {
@@ -132,6 +133,15 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
132133
window.addEventListener('unload', () => targetWindow.off('focus', callback));
133134
}
134135

136+
protected attachMenuBarVisibilityListener(): void {
137+
this.preferenceService.onPreferenceChanged(e => {
138+
if (e.preferenceName === 'window.menuBarVisibility') {
139+
const targetWindow = electronRemote.getCurrentWindow();
140+
this.handleFullScreen(targetWindow, e.newValue);
141+
}
142+
});
143+
}
144+
135145
handleTitleBarStyling(app: FrontendApplication): void {
136146
this.hideTopPanel(app);
137147
electron.ipcRenderer.on(TitleBarStyleAtStartup, (_event, style: string) => {
@@ -309,7 +319,7 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
309319
registry.registerCommand(ElectronCommands.TOGGLE_FULL_SCREEN, {
310320
isEnabled: () => currentWindow.isFullScreenable(),
311321
isVisible: () => currentWindow.isFullScreenable(),
312-
execute: () => currentWindow.setFullScreen(!currentWindow.isFullScreen())
322+
execute: () => this.toggleFullScreen(currentWindow)
313323
});
314324
}
315325

@@ -377,4 +387,27 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
377387
order: '0'
378388
});
379389
}
390+
391+
protected toggleFullScreen(currentWindow: electron.BrowserWindow): void {
392+
currentWindow.setFullScreen(!currentWindow.isFullScreen());
393+
const menuBarVisibility = this.preferenceService.get('window.menuBarVisibility', 'classic');
394+
this.handleFullScreen(currentWindow, menuBarVisibility);
395+
}
396+
397+
protected handleFullScreen(currentWindow: electron.BrowserWindow, menuBarVisibility: string): void {
398+
if (currentWindow.isFullScreen()) {
399+
if (this.titleBarStyle === 'custom') {
400+
return menuBarVisibility === 'visible' ? this.shell.topPanel.show() : this.shell.topPanel.hide();
401+
} else {
402+
currentWindow.menuBarVisible = menuBarVisibility === 'visible';
403+
}
404+
} else {
405+
if (this.titleBarStyle === 'custom') {
406+
this.shell.topPanel.show();
407+
} else {
408+
currentWindow.menuBarVisible = true;
409+
}
410+
}
411+
}
412+
380413
}

0 commit comments

Comments
 (0)