Skip to content

Commit ec7de42

Browse files
author
seantan22
committed
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 `ctrlcmd + shift + f` keybinding on MacOS. Signed-off-by: seantan22 <[email protected]>
1 parent 88caf97 commit ec7de42

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export namespace ElectronCommands {
5151
id: 'close.window',
5252
label: 'Close Window'
5353
};
54+
export const TOGGLE_FULL_SCREEN: Command = {
55+
id: 'workbench.action.toggleFullScreen',
56+
category: 'View',
57+
label: 'Toggle Full Screen'
58+
};
5459
}
5560

5661
export namespace ElectronMenus {
@@ -182,6 +187,11 @@ export class ElectronMenuContribution implements FrontendApplicationContribution
182187
registry.registerCommand(ElectronCommands.RESET_ZOOM, {
183188
execute: () => this.preferenceService.set('window.zoomLevel', ZoomLevel.DEFAULT, PreferenceScope.User)
184189
});
190+
registry.registerCommand(ElectronCommands.TOGGLE_FULL_SCREEN, {
191+
isEnabled: () => currentWindow.isFullScreenable(),
192+
isVisible: () => currentWindow.isFullScreenable(),
193+
execute: () => currentWindow.setFullScreen(!currentWindow.isFullScreen())
194+
});
185195
}
186196

187197
registerKeybindings(registry: KeybindingRegistry): void {
@@ -209,6 +219,10 @@ export class ElectronMenuContribution implements FrontendApplicationContribution
209219
{
210220
command: ElectronCommands.CLOSE_WINDOW.id,
211221
keybinding: (isOSX ? 'cmd+shift+w' : (isWindows ? 'ctrl+w' : /* Linux */ 'ctrl+q'))
222+
},
223+
{
224+
command: ElectronCommands.TOGGLE_FULL_SCREEN.id,
225+
keybinding: isOSX ? 'ctrlcmd+shift+f' : 'f11'
212226
}
213227
);
214228
}

0 commit comments

Comments
 (0)