Skip to content

Commit

Permalink
macos: fix window.titleBarStyle on macOS
Browse files Browse the repository at this point in the history
The commit fixes the `window.titleBarStyle` handling on macOS which would otherwise cause the menu to be completely removed and difficult to recover for users.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Aug 18, 2022
1 parent 8706ed8 commit 2d3a80d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
});
this.preferenceService.onPreferenceChanged(change => {
if (change.preferenceName === 'window.titleBarStyle') {
if (isOSX) {
return; // the `window.titleBarStyle` preference is a no-op on macOS.
}
if (this.titleBarStyleChangeFlag && this.titleBarStyle !== change.newValue && electronRemote.getCurrentWindow().isFocused()) {
electron.ipcRenderer.send(TitleBarStyleChanged, change.newValue);
this.handleRequiredRestart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ export class ElectronMainApplication {
app.on('window-all-closed', this.onWindowAllClosed.bind(this));

ipcMain.on(TitleBarStyleChanged, ({ sender }, titleBarStyle: string) => {
this.useNativeWindowFrame = titleBarStyle === 'native';
this.useNativeWindowFrame = isOSX || titleBarStyle === 'native';
const browserWindow = BrowserWindow.fromId(sender.id);
if (browserWindow) {
this.saveWindowState(browserWindow);
Expand Down

0 comments on commit 2d3a80d

Please sign in to comment.