From 899204e48e13e7a5450f1fd4f471f565d914f722 Mon Sep 17 00:00:00 2001 From: seantan22 Date: Fri, 23 Apr 2021 10:44:42 -0400 Subject: [PATCH] Electron: Add `Toggle Full Screen` Command What it does - Enables full screen toggling of Electron window. How to test - Search for `Toggle Full Screen` in the command palette and execute. - Or, use `f11` keybinding on Windows. - Or, use `ctrl+ctrlcmd+f` keybinding on MacOS. Signed-off-by: seantan22 --- .../menu/electron-menu-contribution.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/core/src/electron-browser/menu/electron-menu-contribution.ts b/packages/core/src/electron-browser/menu/electron-menu-contribution.ts index 8b4c3822a0c90..da71787d08ad4 100644 --- a/packages/core/src/electron-browser/menu/electron-menu-contribution.ts +++ b/packages/core/src/electron-browser/menu/electron-menu-contribution.ts @@ -51,6 +51,11 @@ export namespace ElectronCommands { id: 'close.window', label: 'Close Window' }; + export const TOGGLE_FULL_SCREEN: Command = { + id: 'workbench.action.toggleFullScreen', + category: 'View', + label: 'Toggle Full Screen' + }; } export namespace ElectronMenus { @@ -182,6 +187,11 @@ export class ElectronMenuContribution implements FrontendApplicationContribution registry.registerCommand(ElectronCommands.RESET_ZOOM, { execute: () => this.preferenceService.set('window.zoomLevel', ZoomLevel.DEFAULT, PreferenceScope.User) }); + registry.registerCommand(ElectronCommands.TOGGLE_FULL_SCREEN, { + isEnabled: () => currentWindow.isFullScreenable(), + isVisible: () => currentWindow.isFullScreenable(), + execute: () => currentWindow.setFullScreen(!currentWindow.isFullScreen()) + }); } registerKeybindings(registry: KeybindingRegistry): void { @@ -209,6 +219,10 @@ export class ElectronMenuContribution implements FrontendApplicationContribution { command: ElectronCommands.CLOSE_WINDOW.id, keybinding: (isOSX ? 'cmd+shift+w' : (isWindows ? 'ctrl+w' : /* Linux */ 'ctrl+q')) + }, + { + command: ElectronCommands.TOGGLE_FULL_SCREEN.id, + keybinding: isOSX ? 'ctrl+ctrlcmd+f' : 'f11' } ); }