Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make high contrast detection configurable #17394

Merged
merged 2 commits into from
Dec 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can ignore the setting in this case because leaving HC on Windows you want to switch back to dark theme. Or otherwise the setting should be clearer that it prevents switching in both ways, not just from normal to HC theme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have expanded the setting description. I feel if this settings is disabled, nothing should happen automatically when changing to/from windows HC theme.

if (windowConfig && windowConfig.autoDetectHighContrast) {
this.partService.joinCreation().then(() => {
this.themeService.setColorTheme(VS_DARK_THEME, false);
});
}
});

// Configuration changes
Expand Down