From a655ded0cdb0f07a954c3db394916d4bfa8acd3b Mon Sep 17 00:00:00 2001 From: Geir Sagberg Date: Fri, 16 Dec 2016 14:53:46 +0100 Subject: [PATCH 1/2] Make high contrast detection configurable --- src/vs/platform/windows/common/windows.ts | 1 + .../electron-browser/main.contribution.ts | 8 ++++++++ src/vs/workbench/electron-browser/window.ts | 20 ++++++++++++------- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts index 1ad77ba3744a4..f978e32945f38 100644 --- a/src/vs/platform/windows/common/windows.ts +++ b/src/vs/platform/windows/common/windows.ts @@ -93,4 +93,5 @@ export interface IWindowSettings { fullScreenZenMode: boolean; zoomLevel: number; titleBarStyle: 'native' | 'custom'; + autoDetectHighContrast: boolean; } diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index cebf0abbf8014..fffc1c90666dc 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -203,6 +203,14 @@ let properties: { [path: string]: IJSONSchema; } = { } }; +if (platform.isWindows) { + properties['window.autoDetectHighContrast'] = { + 'type': 'boolean', + 'default': true, + 'description': nls.localize('autoDetectHighContrast', "If enabled, will automatically change to high contrast theme if Windows is using a high contrast theme.") + } +} + if (platform.isMacintosh) { properties['window.titleBarStyle'] = { 'type': 'string', diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index 0068121280560..7e54ad60f4188 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -26,7 +26,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IMessageService } from 'vs/platform/message/common/message'; import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration'; -import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows'; +import { IWindowsService, IWindowService, IWindowSettings } from 'vs/platform/windows/common/windows'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; @@ -258,15 +258,21 @@ export class ElectronWindow { // High Contrast Events ipc.on('vscode:enterHighContrast', (event) => { - this.partService.joinCreation().then(() => { - this.themeService.setColorTheme(VS_HC_THEME, false); - }); + const windowConfig = this.configurationService.getConfiguration('window'); + if (windowConfig.autoDetectHighContrast) { + this.partService.joinCreation().then(() => { + this.themeService.setColorTheme(VS_HC_THEME, false); + }); + } }); ipc.on('vscode:leaveHighContrast', (event) => { - this.partService.joinCreation().then(() => { - this.themeService.setColorTheme(VS_DARK_THEME, false); - }); + const windowConfig = this.configurationService.getConfiguration('window'); + if (windowConfig.autoDetectHighContrast) { + this.partService.joinCreation().then(() => { + this.themeService.setColorTheme(VS_DARK_THEME, false); + }); + } }); // Configuration changes From 80d3c9bb37337e71ee8592dbe3856ee86e76cb29 Mon Sep 17 00:00:00 2001 From: Geir Sagberg Date: Fri, 16 Dec 2016 15:30:36 +0100 Subject: [PATCH 2/2] Fix trailing comma, better description and null check --- src/vs/workbench/electron-browser/main.contribution.ts | 4 ++-- src/vs/workbench/electron-browser/window.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index fffc1c90666dc..53fd98f68819f 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -207,8 +207,8 @@ if (platform.isWindows) { properties['window.autoDetectHighContrast'] = { 'type': 'boolean', 'default': true, - 'description': nls.localize('autoDetectHighContrast', "If enabled, will automatically change to high contrast theme if Windows is using a high contrast theme.") - } + '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."), + }; } if (platform.isMacintosh) { diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index 7e54ad60f4188..9970da1440b76 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -259,7 +259,7 @@ export class ElectronWindow { // High Contrast Events ipc.on('vscode:enterHighContrast', (event) => { const windowConfig = this.configurationService.getConfiguration('window'); - if (windowConfig.autoDetectHighContrast) { + if (windowConfig && windowConfig.autoDetectHighContrast) { this.partService.joinCreation().then(() => { this.themeService.setColorTheme(VS_HC_THEME, false); }); @@ -268,7 +268,7 @@ export class ElectronWindow { ipc.on('vscode:leaveHighContrast', (event) => { const windowConfig = this.configurationService.getConfiguration('window'); - if (windowConfig.autoDetectHighContrast) { + if (windowConfig && windowConfig.autoDetectHighContrast) { this.partService.joinCreation().then(() => { this.themeService.setColorTheme(VS_DARK_THEME, false); });