Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
4 changes: 4 additions & 0 deletions 4 docs/api/native-theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ or is being instructed to use an inverted color scheme.

A `boolean` indicating whether Chromium is in forced colors mode, controlled by system accessibility settings.
Currently, Windows high contrast is the only system setting that triggers forced colors mode.

### `nativeTheme.prefersReducedTransparency` _Readonly_

A `boolean` that indicates the whether the user has chosen via system accessibility settings to reduce transparency at the OS level.
4 changes: 3 additions & 1 deletion 4 docs/api/system-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,12 @@ Returns an object with system animation settings.

## Properties

### `systemPreferences.accessibilityDisplayShouldReduceTransparency()` _macOS_
### `systemPreferences.accessibilityDisplayShouldReduceTransparency` _macOS_ _Deprecated_

A `boolean` property which determines whether the app avoids using semitransparent backgrounds. This maps to [NSWorkspace.accessibilityDisplayShouldReduceTransparency](https://developer.apple.com/documentation/appkit/nsworkspace/1533006-accessibilitydisplayshouldreduce)

**Deprecated:** Use the new [`nativeTheme.prefersReducedTransparency`](native-theme.md#nativethemeprefersreducedtransparency-readonly) API.

### `systemPreferences.effectiveAppearance` _macOS_ _Readonly_

A `string` property that can be `dark`, `light` or `unknown`.
Expand Down
14 changes: 14 additions & 0 deletions 14 docs/breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ This document uses the following convention to categorize breaking changes:
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
* **Removed:** An API or feature was removed, and is no longer supported by Electron.

## Planned Breaking API Changes (33.0)

### Deprecated: `systemPreferences.accessibilityDisplayShouldReduceTransparency`

The `systemPreferences.accessibilityDisplayShouldReduceTransparency` property is now deprecated in favor of the new `nativeTheme.prefersReducedTransparency`, which provides identical information and works cross-platform.

```js
// Deprecated
const shouldReduceTransparency = systemPreferences.accessibilityDisplayShouldReduceTransparency

// Replace with:
const prefersReducedTransparency = nativeTheme.prefersReducedTransparency
```

## Planned Breaking API Changes (32.0)

### Removed: `File.path`
Expand Down
1 change: 1 addition & 0 deletions 1 filenames.auto.gni
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ auto_filenames = {
"lib/browser/message-port-main.ts",
"lib/common/api/net-client-request.ts",
"lib/common/define-properties.ts",
"lib/common/deprecate.ts",
"lib/common/init.ts",
"lib/common/webpack-globals-provider.ts",
"lib/utility/api/exports/electron.ts",
Expand Down
12 changes: 12 additions & 0 deletions 12 lib/browser/api/system-preferences.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as deprecate from '@electron/internal/common/deprecate';
const { systemPreferences } = process._linkedBinding('electron_browser_system_preferences');

if ('getEffectiveAppearance' in systemPreferences) {
Expand All @@ -7,4 +8,15 @@ if ('getEffectiveAppearance' in systemPreferences) {
});
}

if ('accessibilityDisplayShouldReduceTransparency' in systemPreferences) {
const reduceTransparencyDeprecated = deprecate.warnOnce('systemPreferences.accessibilityDisplayShouldReduceTransparency', 'nativeTheme.prefersReducedTransparency');
const nativeReduceTransparency = systemPreferences.accessibilityDisplayShouldReduceTransparency;
Object.defineProperty(systemPreferences, 'accessibilityDisplayShouldReduceTransparency', {
get: () => {
reduceTransparencyDeprecated();
return nativeReduceTransparency;
}
});
}

export default systemPreferences;
8 changes: 7 additions & 1 deletion 8 shell/browser/api/electron_api_native_theme.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ bool NativeTheme::InForcedColorsMode() {
return ui_theme_->InForcedColorsMode();
}

bool NativeTheme::GetPrefersReducedTransparency() {
return ui_theme_->GetPrefersReducedTransparency();
}

#if BUILDFLAG(IS_MAC)
const CFStringRef WhiteOnBlack = CFSTR("whiteOnBlack");
const CFStringRef UniversalAccessDomain = CFSTR("com.apple.universalaccess");
Expand Down Expand Up @@ -107,7 +111,9 @@ gin::ObjectTemplateBuilder NativeTheme::GetObjectTemplateBuilder(
&NativeTheme::ShouldUseHighContrastColors)
.SetProperty("shouldUseInvertedColorScheme",
&NativeTheme::ShouldUseInvertedColorScheme)
.SetProperty("inForcedColorsMode", &NativeTheme::InForcedColorsMode);
.SetProperty("inForcedColorsMode", &NativeTheme::InForcedColorsMode)
.SetProperty("prefersReducedTransparency",
&NativeTheme::GetPrefersReducedTransparency);
}

const char* NativeTheme::GetTypeName() {
Expand Down
1 change: 1 addition & 0 deletions 1 shell/browser/api/electron_api_native_theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class NativeTheme : public gin::Wrappable<NativeTheme>,
bool ShouldUseHighContrastColors();
bool ShouldUseInvertedColorScheme();
bool InForcedColorsMode();
bool GetPrefersReducedTransparency();

// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* theme) override;
Expand Down
6 changes: 6 additions & 0 deletions 6 spec/api-native-theme-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,10 @@ describe('nativeTheme module', () => {
expect(nativeTheme.inForcedColorsMode).to.be.a('boolean');
});
});

describe('nativeTheme.prefersReducesTransparency', () => {
it('returns a boolean', () => {
expect(nativeTheme.prefersReducedTransparency).to.be.a('boolean');
});
});
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.