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

Adding background transparency support for MacOS #151678

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion src/vs/platform/theme/electron-main/themeMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class ThemeMainService extends Disposable implements IThemeMainService {

private updateBackgroundColor(windowId: number, splash: IPartsSplash): void {
for (const window of BrowserWindow.getAllWindows()) {
if (window.id === windowId) {
if (window.id === windowId && this.configurationService.getValue('workbench.transparency') === false) {
window.setBackgroundColor(splash.colorInfo.background);
break;
}
Expand Down
6 changes: 5 additions & 1 deletion src/vs/platform/windows/electron-main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {

const windowSettings = this.configurationService.getValue<IWindowSettings | undefined>('window');

const workbenchTransparency = this.configurationService.getValue('workbench.transparency');

let useSandbox = false;
if (typeof windowSettings?.experimental?.useSandbox === 'boolean') {
useSandbox = windowSettings.experimental.useSandbox;
Expand All @@ -201,11 +203,13 @@ export class CodeWindow extends Disposable implements ICodeWindow {
height: this.windowState.height,
x: this.windowState.x,
y: this.windowState.y,
backgroundColor: this.themeMainService.getBackgroundColor(),
backgroundColor: workbenchTransparency ? '#00000000' : this.themeMainService.getBackgroundColor(),
minWidth: WindowMinimumSize.WIDTH,
minHeight: WindowMinimumSize.HEIGHT,
show: !isFullscreenOrMaximized, // reduce flicker by showing later
title: this.productService.nameLong,
frame: workbenchTransparency ? false : undefined,
transparent: workbenchTransparency ? true : undefined,
webPreferences: {
preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-browser/preload.js', require).fsPath,
additionalArguments: [`--vscode-window-config=${this.configObjectUrl.resource.toString()}`],
Expand Down
8 changes: 8 additions & 0 deletions src/vs/workbench/services/themes/common/themeConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ const preferredLightThemeSettingSchema: IConfigurationPropertySchema = {
enumItemLabels: colorThemeSettingEnumItemLabels,
errorMessage: nls.localize('colorThemeError', "Theme is unknown or not installed."),
};

const transparencySettingSchema: IConfigurationPropertySchema = {
type: 'boolean',
markdownDescription: nls.localize('transparencySetting', 'If set, the background of the application will become transparent. (Requires Restart)'),
default: false
};

const preferredHCDarkThemeSettingSchema: IConfigurationPropertySchema = {
type: 'string',
markdownDescription: nls.localize({ key: 'preferredHCDarkColorTheme', comment: ['`#{0}#` will become a link to an other setting. Do not remove backtick or #'] }, 'Specifies the preferred color theme used in high contrast dark mode when `#{0}#` is enabled.', ThemeSettings.DETECT_HC),
Expand Down Expand Up @@ -125,6 +132,7 @@ const themeSettingsConfiguration: IConfigurationNode = {
type: 'object',
properties: {
[ThemeSettings.COLOR_THEME]: colorThemeSettingSchema,
[ThemeSettings.TRANSPARENCY]: transparencySettingSchema,
[ThemeSettings.PREFERRED_DARK_THEME]: preferredDarkThemeSettingSchema,
[ThemeSettings.PREFERRED_LIGHT_THEME]: preferredLightThemeSettingSchema,
[ThemeSettings.PREFERRED_HC_DARK_THEME]: preferredHCDarkThemeSettingSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const themeScopeRegex = /\[(.+?)\]/g;

export enum ThemeSettings {
COLOR_THEME = 'workbench.colorTheme',
TRANSPARENCY = 'workbench.transparency',
FILE_ICON_THEME = 'workbench.iconTheme',
PRODUCT_ICON_THEME = 'workbench.productIconTheme',
COLOR_CUSTOMIZATIONS = 'workbench.colorCustomizations',
Expand Down