diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index 02b6eeaea2248d57e2740b08f725086a71c048b9..928faef3c9ae1888a278752df6a37fc46b9fc5ff 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts @@ -107,6 +107,12 @@ export class TitlebarPart extends Part implements ITitleService { if (event.affectsConfiguration('window.title')) { this.doUpdateTitle(); } + + if (event.affectsConfiguration('window.doubleClickIconToClose')) { + if (this.appIcon) { + this.onUpdateAppIconDragBehavior(); + } + } } private onMenubarVisibilityChanged(visible: boolean) { @@ -285,6 +291,11 @@ export class TitlebarPart extends Part implements ITitleService { // App Icon (Windows/Linux) if (!isMacintosh) { this.appIcon = append(this.titleContainer, $('div.window-appicon')); + this.onUpdateAppIconDragBehavior(); + + this._register(addDisposableListener(this.appIcon, EventType.DBLCLICK, (e => { + this.windowService.closeWindow(); + }))); } // Menubar: the menubar part which is responsible for populating both the custom and native menubars @@ -444,6 +455,16 @@ export class TitlebarPart extends Part implements ITitleService { this.windowService.onWindowTitleDoubleClick(); } + private onUpdateAppIconDragBehavior() { + const setting = this.configurationService.getValue('window.doubleClickIconToClose'); + if (setting) { + this.appIcon.style['-webkit-app-region'] = 'no-drag'; + } + else { + this.appIcon.style['-webkit-app-region'] = 'drag'; + } + } + private onContextMenu(e: MouseEvent): void { // Find target anchor diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index ac9ea4f21b1e9dc8106fcc023c0908d819c4bae5..d25eedac271502ecdd9990889abb297431db63bf 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -806,6 +806,12 @@ configurationRegistry.registerConfiguration({ 'description': nls.localize('autoDetectHighContrast', "If enabled, will automatically change to high contrast theme if Windows is using a high contrast theme, and to dark theme when switching away from a Windows high contrast theme."), 'included': isWindows }, + 'window.doubleClickIconToClose': { + 'type': 'boolean', + 'default': false, + 'scope': ConfigurationScope.APPLICATION, + 'description': nls.localize('window.doubleClickIconToClose', "If enabled, double clicking the application icon in the title bar will close the window and the window cannot be dragged by the icon. This setting only has an effect when 'window.titleBarStyle' is set to 'custom'.") + }, 'window.titleBarStyle': { 'type': 'string', 'enum': ['native', 'custom'],