chore: remove deprecated systemPreferences color scheme events (#39341)
This commit is contained in:
parent
cf658b700d
commit
d166182865
6 changed files with 21 additions and 49 deletions
|
@ -27,24 +27,6 @@ Returns:
|
|||
|
||||
* `event` Event
|
||||
|
||||
### Event: 'inverted-color-scheme-changed' _Windows_ _Deprecated_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `invertedColorScheme` boolean - `true` if an inverted color scheme (a high contrast color scheme with light text and dark backgrounds) is being used, `false` otherwise.
|
||||
|
||||
**Deprecated:** Should use the new [`updated`](native-theme.md#event-updated) event on the `nativeTheme` module.
|
||||
|
||||
### Event: 'high-contrast-color-scheme-changed' _Windows_ _Deprecated_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `highContrastColorScheme` boolean - `true` if a high contrast theme is being used, `false` otherwise.
|
||||
|
||||
**Deprecated:** Should use the new [`updated`](native-theme.md#event-updated) event on the `nativeTheme` module.
|
||||
|
||||
## Methods
|
||||
|
||||
### `systemPreferences.isSwipeTrackingFromScrollEventsEnabled()` _macOS_
|
||||
|
|
|
@ -27,6 +27,24 @@ The `ipcRenderer.sendTo()` API has been deprecated. It should be replaced by set
|
|||
|
||||
The `senderId` and `senderIsMainFrame` properties of `IpcRendererEvent` have been deprecated as well.
|
||||
|
||||
### Removed: color scheme events in `systemPreferences`
|
||||
|
||||
The following `systemPreferences` events have been removed:
|
||||
|
||||
* `inverted-color-scheme-changed`
|
||||
* `high-contrast-color-scheme-changed`
|
||||
|
||||
Use the new `updated` event on the `nativeTheme` module instead.
|
||||
|
||||
```js
|
||||
// Removed
|
||||
systemPreferences.on('inverted-color-scheme-changed', () => { /* ... */ })
|
||||
systemPreferences.on('high-contrast-color-scheme-changed', () => { /* ... */ })
|
||||
|
||||
// Replace with
|
||||
nativeTheme.on('updated', () => { /* ... */ })
|
||||
```
|
||||
|
||||
## Planned Breaking API Changes (26.0)
|
||||
|
||||
### Deprecated: `webContents.getPrinters`
|
||||
|
|
|
@ -33,16 +33,6 @@ SystemPreferences::~SystemPreferences() {
|
|||
SystemPreferences::~SystemPreferences() = default;
|
||||
#endif
|
||||
|
||||
bool SystemPreferences::IsInvertedColorScheme() {
|
||||
return ui::NativeTheme::GetInstanceForNativeUi()
|
||||
->GetPlatformHighContrastColorScheme() ==
|
||||
ui::NativeTheme::PlatformHighContrastColorScheme::kDark;
|
||||
}
|
||||
|
||||
bool SystemPreferences::IsHighContrastColorScheme() {
|
||||
return ui::NativeTheme::GetInstanceForNativeUi()->UserHasContrastPreference();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> SystemPreferences::GetAnimationSettings(
|
||||
v8::Isolate* isolate) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
|
|
|
@ -115,8 +115,6 @@ class SystemPreferences
|
|||
v8::Local<v8::Value> GetAppLevelAppearance(v8::Isolate* isolate);
|
||||
void SetAppLevelAppearance(gin::Arguments* args);
|
||||
#endif
|
||||
bool IsInvertedColorScheme();
|
||||
bool IsHighContrastColorScheme();
|
||||
v8::Local<v8::Value> GetAnimationSettings(v8::Isolate* isolate);
|
||||
|
||||
// disable copy
|
||||
|
@ -158,10 +156,6 @@ class SystemPreferences
|
|||
|
||||
std::string current_color_;
|
||||
|
||||
bool inverted_color_scheme_ = false;
|
||||
|
||||
bool high_contrast_color_scheme_ = false;
|
||||
|
||||
std::unique_ptr<gfx::ScopedSysColorChangeListener> color_change_listener_;
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -158,9 +158,6 @@ std::string SystemPreferences::GetMediaAccessStatus(
|
|||
}
|
||||
|
||||
void SystemPreferences::InitializeWindow() {
|
||||
inverted_color_scheme_ = IsInvertedColorScheme();
|
||||
high_contrast_color_scheme_ = IsHighContrastColorScheme();
|
||||
|
||||
// Wait until app is ready before creating sys color listener
|
||||
// Creating this listener before the app is ready causes global shortcuts
|
||||
// to not fire
|
||||
|
@ -216,18 +213,6 @@ LRESULT CALLBACK SystemPreferences::WndProc(HWND hwnd,
|
|||
}
|
||||
|
||||
void SystemPreferences::OnSysColorChange() {
|
||||
bool new_inverted_color_scheme = IsInvertedColorScheme();
|
||||
if (new_inverted_color_scheme != inverted_color_scheme_) {
|
||||
inverted_color_scheme_ = new_inverted_color_scheme;
|
||||
Emit("inverted-color-scheme-changed", new_inverted_color_scheme);
|
||||
}
|
||||
|
||||
bool new_high_contrast_color_scheme = IsHighContrastColorScheme();
|
||||
if (new_high_contrast_color_scheme != high_contrast_color_scheme_) {
|
||||
high_contrast_color_scheme_ = new_high_contrast_color_scheme;
|
||||
Emit("high-contrast-color-scheme-changed", new_high_contrast_color_scheme);
|
||||
}
|
||||
|
||||
Emit("color-changed");
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,10 @@ if (process.platform !== 'win32' || systemPreferences.isAeroGlassEnabled()) {
|
|||
|
||||
if (process.platform === 'win32') {
|
||||
systemPreferences.on('color-changed', () => { console.log('color changed'); });
|
||||
// @ts-expect-error Removed API
|
||||
systemPreferences.on('inverted-color-scheme-changed', (_, inverted) => console.log(inverted ? 'inverted' : 'not inverted'));
|
||||
// @ts-expect-error Removed API
|
||||
systemPreferences.on('high-contrast-color-scheme-changed', (_, highContrast) => console.log(highContrast ? 'high contrast' : 'not high contrast'));
|
||||
console.log('Color for menu is', systemPreferences.getColor('menu'));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue