提交 baef0ae2 编写于 作者: M Martin Aeschlimann

high contrast switching in browser

上级 7b93ed00
......@@ -9,7 +9,7 @@ import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
import { isLinux, isMacintosh } from 'vs/base/common/platform';
import { ToggleDevToolsAction, ConfigureRuntimeArgumentsAction } from 'vs/workbench/electron-sandbox/actions/developerActions';
import { ZoomResetAction, ZoomOutAction, ZoomInAction, CloseCurrentWindowAction, SwitchWindow, QuickSwitchWindow, ReloadWindowWithExtensionsDisabledAction, NewWindowTabHandler, ShowPreviousWindowTabHandler, ShowNextWindowTabHandler, MoveWindowTabToNewWindowHandler, MergeWindowTabsHandlerHandler, ToggleWindowTabsBarHandler } from 'vs/workbench/electron-sandbox/actions/windowActions';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
......@@ -255,13 +255,6 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
'default': false,
'description': nls.localize('closeWhenEmpty', "Controls whether closing the last editor should also close the window. This setting only applies for windows that do not show folders.")
},
'window.autoDetectHighContrast': {
'type': 'boolean',
'default': true,
'description': nls.localize('autoDetectHighContrast', "If enabled, will automatically change to high contrast theme if the OS is using a high contrast theme, and to dark theme when switching away from a high contrast theme."),
'scope': ConfigurationScope.APPLICATION,
'included': isWindows || isMacintosh
},
'window.doubleClickIconToClose': {
'type': 'boolean',
'default': false,
......
......@@ -29,6 +29,9 @@ export class BrowserHostColorSchemeService extends Disposable implements IHostCo
window.matchMedia('(prefers-color-scheme: dark)').addListener(() => {
this._onDidSchemeChangeEvent.fire();
});
window.matchMedia('(forced-colors: active)').addListener(() => {
this._onDidSchemeChangeEvent.fire();
});
}
get onDidChangeColorScheme(): Event<void> {
......@@ -36,7 +39,9 @@ export class BrowserHostColorSchemeService extends Disposable implements IHostCo
}
get colorScheme(): ColorScheme {
if (window.matchMedia(`(prefers-color-scheme: light)`).matches) {
if (window.matchMedia(`(forced-colors: active)`).matches) {
return ColorScheme.HIGH_CONTRAST;
} else if (window.matchMedia(`(prefers-color-scheme: light)`).matches) {
return ColorScheme.LIGHT;
} else if (window.matchMedia(`(prefers-color-scheme: dark)`).matches) {
return ColorScheme.DARK;
......
......@@ -438,6 +438,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
}
}
};
ruleCollector.addRule(`.monaco-workbench { forced-color-adjust: none; }`);
themingRegistry.getThemingParticipants().forEach(p => p(themeData, ruleCollector, this.environmentService));
_applyRules([...cssRules].join('\n'), colorThemeRulesClassName);
}
......
......@@ -6,7 +6,7 @@
import * as nls from 'vs/nls';
import * as types from 'vs/base/common/types';
import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, IConfigurationPropertySchema, IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, IConfigurationPropertySchema, IConfigurationNode, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { textmateColorsSchemaId, textmateColorGroupSchemaId } from 'vs/workbench/services/themes/common/colorThemeSchema';
......@@ -96,6 +96,13 @@ const productIconThemeSettingSchema: IConfigurationPropertySchema = {
errorMessage: nls.localize('productIconThemeError', "Product icon theme is unknown or not installed.")
};
const detectHCSchemeSettingSchema: IConfigurationPropertySchema = {
type: 'boolean',
default: true,
description: nls.localize('autoDetectHighContrast', "If enabled, will automatically change to high contrast theme if the OS is using a high contrast theme."),
scope: ConfigurationScope.APPLICATION
};
const themeSettingsConfiguration: IConfigurationNode = {
id: 'workbench',
order: 7.1,
......@@ -105,7 +112,6 @@ const themeSettingsConfiguration: IConfigurationNode = {
[ThemeSettings.PREFERRED_DARK_THEME]: preferredDarkThemeSettingSchema,
[ThemeSettings.PREFERRED_LIGHT_THEME]: preferredLightThemeSettingSchema,
[ThemeSettings.PREFERRED_HC_THEME]: preferredHCThemeSettingSchema,
[ThemeSettings.DETECT_COLOR_SCHEME]: detectColorSchemeSettingSchema,
[ThemeSettings.FILE_ICON_THEME]: fileIconThemeSettingSchema,
[ThemeSettings.COLOR_CUSTOMIZATIONS]: colorCustomizationsSchema,
[ThemeSettings.PRODUCT_ICON_THEME]: productIconThemeSettingSchema
......@@ -113,6 +119,17 @@ const themeSettingsConfiguration: IConfigurationNode = {
};
configurationRegistry.registerConfiguration(themeSettingsConfiguration);
const themeSettingsWindowConfiguration: IConfigurationNode = {
id: 'window',
order: 8.1,
type: 'object',
properties: {
[ThemeSettings.DETECT_HC]: detectHCSchemeSettingSchema,
[ThemeSettings.DETECT_COLOR_SCHEME]: detectColorSchemeSettingSchema,
}
};
configurationRegistry.registerConfiguration(themeSettingsWindowConfiguration);
function tokenGroupSettings(description: string): IJSONSchema {
return {
description,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册