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

feat: expose app accessibility transparency settings api #39631

Merged
merged 7 commits into from Sep 20, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/api/system-preferences.md
Expand Up @@ -401,6 +401,10 @@

## Properties

### `systemPreferences.accessibilityDisplayShouldReduceTransparency()` _macOS_

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)

### `systemPreferences.effectiveAppearance` _macOS_ _Readonly_

A `string` property that can be `dark`, `light` or `unknown`.
Expand Down
3 changes: 3 additions & 0 deletions shell/browser/api/electron_api_system_preferences.cc
Expand Up @@ -95,6 +95,9 @@ gin::ObjectTemplateBuilder SystemPreferences::GetObjectTemplateBuilder(
.SetMethod("isTrustedAccessibilityClient",
&SystemPreferences::IsTrustedAccessibilityClient)
.SetMethod("askForMediaAccess", &SystemPreferences::AskForMediaAccess)
.SetProperty(
"accessibilityDisplayShouldReduceTransparency",
MarshallOfSound marked this conversation as resolved.
Show resolved Hide resolved
&SystemPreferences::AccessibilityDisplayShouldReduceTransparency)
#endif
.SetMethod("getAnimationSettings",
&SystemPreferences::GetAnimationSettings);
Expand Down
1 change: 1 addition & 0 deletions shell/browser/api/electron_api_system_preferences.h
Expand Up @@ -96,6 +96,7 @@ class SystemPreferences
gin::Arguments* args);
void RemoveUserDefault(const std::string& name);
bool IsSwipeTrackingFromScrollEventsEnabled();
bool AccessibilityDisplayShouldReduceTransparency();

std::string GetSystemColor(gin_helper::ErrorThrower thrower,
const std::string& color);
Expand Down
5 changes: 5 additions & 0 deletions shell/browser/api/electron_api_system_preferences_mac.mm
Expand Up @@ -598,4 +598,9 @@ AVMediaType ParseMediaType(const std::string& media_type) {
isolate, [NSApplication sharedApplication].effectiveAppearance);
}

bool SystemPreferences::AccessibilityDisplayShouldReduceTransparency() {
return [[NSWorkspace sharedWorkspace]
accessibilityDisplayShouldReduceTransparency];
}

} // namespace electron::api
2 changes: 0 additions & 2 deletions spec/ts-smoke/electron/main.ts
Expand Up @@ -382,8 +382,6 @@ if (process.platform === 'darwin') {
// @ts-expect-error Removed API
systemPreferences.setAppLevelAppearance('dark');
// @ts-expect-error Removed API
console.log(systemPreferences.appLevelAppearance);
// @ts-expect-error Removed API
console.log(systemPreferences.getColor('alternate-selected-control-text'));
}

Expand Down