feat: enable dark mode on GTK UIs (#38977)

feat: port DarkModeManagerLinux

This is needed after https://bugs.chromium.org/p/chromium/issues/detail?id=998903
and replaces the previous workaround to detect dark mode on GTK.
Detect system dark theme preference via xdg settings portal:
https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.portal.Settings

Closes: https://github.com/electron/electron/issues/38961
Closes: https://github.com/electron/electron/issues/28838

Signed-off-by: Robert Günzler <r@gnzler.io>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
Robert Günzler 2023-09-27 20:17:40 +02:00 committed by GitHub
parent a0ae691a9c
commit 480f48b2fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 48 deletions

View file

@ -43,7 +43,8 @@ class Environment;
namespace ui {
class LinuxUiGetter;
}
class DarkModeManagerLinux;
} // namespace ui
namespace electron {
@ -65,10 +66,6 @@ class ViewsDelegate;
class ViewsDelegateMac;
#endif
#if BUILDFLAG(IS_LINUX)
class DarkThemeObserver;
#endif
class ElectronBrowserMainParts : public content::BrowserMainParts {
public:
ElectronBrowserMainParts();
@ -145,9 +142,7 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
#endif
#if BUILDFLAG(IS_LINUX)
// Used to notify the native theme of changes to dark mode.
std::unique_ptr<DarkThemeObserver> dark_theme_observer_;
std::unique_ptr<ui::DarkModeManagerLinux> dark_mode_manager_;
std::unique_ptr<ui::LinuxUiGetter> linux_ui_getter_;
#endif