Add support for accent color on windows border (fix #242980) (#252473)

This commit is contained in:
Benjamin Pasero 2025-06-27 14:27:46 +02:00 committed by GitHub
parent 4b9aeee961
commit f8a5608556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 2 deletions

View File

@ -210,6 +210,7 @@ export interface IWindowSettings {
readonly clickThroughInactive: boolean;
readonly newWindowProfile: string;
readonly density: IDensitySettings;
readonly border: 'off' | 'default' | string /* color in RGB or other formats */;
}
export interface IDensitySettings {

View File

@ -133,7 +133,7 @@ export function defaultBrowserWindowOptions(accessor: ServicesAccessor, windowSt
const windowSettings = configurationService.getValue<IWindowSettings | undefined>('window');
const options: electron.BrowserWindowConstructorOptions & { experimentalDarkMode: boolean } = {
const options: electron.BrowserWindowConstructorOptions & { experimentalDarkMode: boolean; accentColor?: boolean | string } = {
backgroundColor: themeMainService.getBackgroundColor(),
minWidth: WindowMinimumSize.WIDTH,
minHeight: WindowMinimumSize.HEIGHT,
@ -160,6 +160,17 @@ export function defaultBrowserWindowOptions(accessor: ServicesAccessor, windowSt
experimentalDarkMode: true
};
if (isWindows) {
const borderSetting = windowSettings?.border ?? 'default';
if (borderSetting !== 'default') {
if (borderSetting === 'off') {
options.accentColor = false;
} else if (typeof borderSetting === 'string') {
options.accentColor = borderSetting;
}
}
}
if (isLinux) {
options.icon = join(environmentMainService.appRoot, 'resources/linux/code.png'); // always on Linux
} else if (isWindows && !environmentMainService.isBuilt) {

View File

@ -5,7 +5,7 @@
import { RunOnceScheduler } from '../../../../base/common/async.js';
import { Disposable, dispose, IDisposable, toDisposable } from '../../../../base/common/lifecycle.js';
import { isLinux, isMacintosh, isNative } from '../../../../base/common/platform.js';
import { isLinux, isMacintosh, isNative, isWindows } from '../../../../base/common/platform.js';
import { isEqual } from '../../../../base/common/resources.js';
import { URI } from '../../../../base/common/uri.js';
import { localize } from '../../../../nls.js';
@ -46,6 +46,7 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
'window.nativeFullScreen',
'window.clickThroughInactive',
'window.controlsStyle',
'window.border',
'update.mode',
'editor.accessibilitySupport',
'security.workspace.trust.enabled',
@ -62,6 +63,7 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
private readonly nativeTabs = new ChangeObserver('boolean');
private readonly nativeFullScreen = new ChangeObserver('boolean');
private readonly clickThroughInactive = new ChangeObserver('boolean');
private readonly border = new ChangeObserver('string');
private readonly controlsStyle = new ChangeObserver('string');
private readonly updateMode = new ChangeObserver('string');
private accessibilitySupport: 'on' | 'off' | 'auto' | undefined;
@ -131,6 +133,9 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
// macOS: Click through (accept first mouse)
processChanged(isMacintosh && this.clickThroughInactive.handleChange(config.window?.clickThroughInactive));
// Windows: border
processChanged(isWindows && this.border.handleChange(config.window?.border));
// Windows/Linux: Window controls style
processChanged(!isMacintosh && this.controlsStyle.handleChange(config.window?.controlsStyle));

View File

@ -308,6 +308,13 @@ import { registerWorkbenchContribution2, WorkbenchPhase } from '../common/contri
'scope': ConfigurationScope.APPLICATION,
'description': localize('window.clickThroughInactive', "If enabled, clicking on an inactive window will both activate the window and trigger the element under the mouse if it is clickable. If disabled, clicking anywhere on an inactive window will activate it only and a second click is required on the element."),
'included': isMacintosh
},
'window.border': {
'type': 'string',
'scope': ConfigurationScope.APPLICATION,
'default': 'default',
'markdownDescription': localize('window.border', "Controls the border color of the window. Set to `off` to disable or to a specific color in Hex, RGB, RGBA, HSL, HSLA format. This requires Windows to have the 'Show accent color on title bars and window borders' enabled and is ignored when {0} is set to {1}.", '`#window.titleBarStyle#`', '`native`'),
'included': isWindows
}
}
});