mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: Add getAccentColor on Linux (#48628)
* feat: Implement `getAccentColor` on Linux Co-authored-by: Tau Gärtli <git@tau.garden> * doc: Update OS support for accent color APIs Co-authored-by: Tau Gärtli <git@tau.garden> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Tau Gärtli <git@tau.garden>
This commit is contained in:
@@ -18,6 +18,11 @@
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/browser_observer.h"
|
||||
#endif
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
#include "ui/native_theme/native_theme_observer.h"
|
||||
#endif
|
||||
|
||||
namespace gin_helper {
|
||||
template <typename T>
|
||||
@@ -44,6 +49,9 @@ class SystemPreferences final
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
,
|
||||
public BrowserObserver
|
||||
#elif BUILDFLAG(IS_LINUX)
|
||||
,
|
||||
public ui::NativeThemeObserver
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
@@ -55,8 +63,8 @@ class SystemPreferences final
|
||||
v8::Isolate* isolate) override;
|
||||
const char* GetTypeName() override;
|
||||
|
||||
std::string GetAccentColor();
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
|
||||
static std::string GetAccentColor();
|
||||
std::string GetColor(gin_helper::ErrorThrower thrower,
|
||||
const std::string& color);
|
||||
std::string GetMediaAccessStatus(gin_helper::ErrorThrower thrower,
|
||||
@@ -117,6 +125,10 @@ class SystemPreferences final
|
||||
// TODO(MarshallOfSound): Write tests for these methods once we
|
||||
// are running tests on a Mojave machine
|
||||
v8::Local<v8::Value> GetEffectiveAppearance(v8::Isolate* isolate);
|
||||
|
||||
#elif BUILDFLAG(IS_LINUX)
|
||||
// ui::NativeThemeObserver:
|
||||
void OnNativeThemeUpdated(ui::NativeTheme* theme) override;
|
||||
#endif
|
||||
v8::Local<v8::Value> GetAnimationSettings(v8::Isolate* isolate);
|
||||
|
||||
@@ -162,6 +174,12 @@ class SystemPreferences final
|
||||
// Color/high contrast mode change observer.
|
||||
base::CallbackListSubscription hwnd_subscription_;
|
||||
#endif
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
void OnNativeThemeUpdatedOnUI();
|
||||
|
||||
raw_ptr<ui::NativeTheme> ui_theme_;
|
||||
std::string current_accent_color_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace electron::api
|
||||
|
||||
Reference in New Issue
Block a user