feat: default gtk darkTheme option to nativeTheme.shouldUseDarkColors for better platform support (#20138)

* feat: default gtk darkTheme option to nativeTheme.shouldUseDarkColors for better platform support

* chore: update syntax for PR feedback

* refactor: only define SetGTKDarkThemeEnabled when needed

Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
This commit is contained in:
Samuel Attard 2020-03-29 23:02:16 -07:00 committed by GitHub
parent a3e28788ce
commit 6ecf729487
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 36 deletions

View file

@ -10,6 +10,8 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "gin/handle.h"
#include "shell/browser/native_window_views.h"
#include "shell/browser/window_list.h"
#include "shell/common/gin_converters/std_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
@ -47,8 +49,13 @@ void NativeTheme::SetThemeSource(ui::NativeTheme::ThemeSource override) {
// Update the macOS appearance setting for this new override value
UpdateMacOSAppearanceForOverrideValue(override);
#endif
// TODO(MarshallOfSound): Update all existing browsers windows to use GTK dark
// theme
#if defined(USE_X11)
const bool dark_enabled = ShouldUseDarkColors();
for (auto* window : WindowList::GetWindows()) {
static_cast<NativeWindowViews*>(window)->SetGTKDarkThemeEnabled(
dark_enabled);
}
#endif
}
ui::NativeTheme::ThemeSource NativeTheme::GetThemeSource() const {