Skip to content

Commit 1d622dc

Browse files
committed
Add command line switch --no-native-window-frame
This patch adds a command line switch `--no-native-window-frame` that prevents the app loader from using native menus in electron. We need this functionality for testing menu actions using electron playwright. When initialized with --no-native-window-frame, the app loader enforces the rendering of HTML menus that playwright can access. Contributed on behalf of STMicroelectronics Signed-off-by: Olaf Lessenich <[email protected]>
1 parent aba60c2 commit 1d622dc

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

examples/playwright/src/theia-app-loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class ElectronLaunchOptions {
104104
constructor(
105105
protected readonly electronAppPath: string,
106106
protected readonly pluginsPath?: string,
107-
protected readonly additionalArgs: string[] = ['--no-cluster']
107+
protected readonly additionalArgs: string[] = ['--no-cluster', '--no-native-window-frame']
108108
) { }
109109

110110
playwrightOptions(workspace?: TheiaWorkspace): object {

packages/core/src/electron-main/electron-main-application.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ export class ElectronMainApplication {
197197
}
198198

199199
async start(config: FrontendApplicationConfig): Promise<void> {
200-
this.useNativeWindowFrame = this.getTitleBarStyle(config) === 'native';
200+
const args = this.processArgv.getProcessArgvWithoutBin(process.argv);
201+
this.useNativeWindowFrame = this.getTitleBarStyle(config) === 'native' && !args.includes('--no-native-window-frame');
201202
this._config = config;
202203
this.hookApplicationEvents();
203204
const port = await this.startBackend();
@@ -207,7 +208,7 @@ export class ElectronMainApplication {
207208
await this.startContributions();
208209
await this.launch({
209210
secondInstance: false,
210-
argv: this.processArgv.getProcessArgvWithoutBin(process.argv),
211+
argv: args,
211212
cwd: process.cwd()
212213
});
213214
}
@@ -305,13 +306,19 @@ export class ElectronMainApplication {
305306

306307
async openDefaultWindow(): Promise<BrowserWindow> {
307308
const [uri, electronWindow] = await Promise.all([this.createWindowUri(), this.createWindow()]);
309+
if (!this.useNativeWindowFrame) {
310+
electronWindow.setMenuBarVisibility(false);
311+
}
308312
electronWindow.loadURL(uri.withFragment(DEFAULT_WINDOW_HASH).toString(true));
309313
return electronWindow;
310314
}
311315

312316
protected async openWindowWithWorkspace(workspacePath: string): Promise<BrowserWindow> {
313317
const options = await this.getLastWindowOptions();
314318
const [uri, electronWindow] = await Promise.all([this.createWindowUri(), this.createWindow(options)]);
319+
if (!this.useNativeWindowFrame) {
320+
electronWindow.setMenuBarVisibility(false);
321+
}
315322
electronWindow.loadURL(uri.withFragment(encodeURI(workspacePath)).toString(true));
316323
return electronWindow;
317324
}

0 commit comments

Comments
 (0)