Skip to content

Commit

Permalink
Merge pull request #17394 from geirsagberg/17279_disable_highContrast
Browse files Browse the repository at this point in the history
Make high contrast detection configurable
  • Loading branch information
bpasero committed Dec 16, 2016
2 parents ebc1790 + 80d3c9b commit a0f4983
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/vs/platform/windows/common/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ export interface IWindowSettings {
fullScreenZenMode: boolean;
zoomLevel: number;
titleBarStyle: 'native' | 'custom';
autoDetectHighContrast: boolean;
}
8 changes: 8 additions & 0 deletions src/vs/workbench/electron-browser/main.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, and to dark theme when switching away from a Windows high contrast theme."),
};
}

if (platform.isMacintosh) {
properties['window.titleBarStyle'] = {
'type': 'string',
Expand Down
20 changes: 13 additions & 7 deletions src/vs/workbench/electron-browser/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<IWindowSettings>('window');
if (windowConfig && 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<IWindowSettings>('window');
if (windowConfig && windowConfig.autoDetectHighContrast) {
this.partService.joinCreation().then(() => {
this.themeService.setColorTheme(VS_DARK_THEME, false);
});
}
});

// Configuration changes
Expand Down

0 comments on commit a0f4983

Please sign in to comment.