From 9b1dfe90f4cb99c28c6dc8c36e7325fa884aaa4c Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 31 Jul 2025 14:29:43 +0200 Subject: [PATCH] fix: dark mode on Linux default themeing (#47919) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- .../ui/electron_desktop_window_tree_host_linux.cc | 11 +++++++++++ .../ui/electron_desktop_window_tree_host_linux.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc index fa05aedcb0..4502f132c7 100644 --- a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc +++ b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc @@ -26,6 +26,7 @@ #include "ui/linux/linux_ui.h" #include "ui/ozone/public/ozone_platform.h" #include "ui/platform_window/platform_window.h" +#include "ui/platform_window/platform_window_init_properties.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h" @@ -293,4 +294,14 @@ void ElectronDesktopWindowTreeHostLinux::DispatchEvent(ui::Event* event) { views::DesktopWindowTreeHostLinux::DispatchEvent(event); } +void ElectronDesktopWindowTreeHostLinux::AddAdditionalInitProperties( + const views::Widget::InitParams& params, + ui::PlatformWindowInitProperties* properties) { + views::DesktopWindowTreeHostLinux::AddAdditionalInitProperties(params, + properties); + const auto* linux_ui_theme = ui::LinuxUiTheme::GetForProfile(nullptr); + properties->prefer_dark_theme = + linux_ui_theme && linux_ui_theme->PreferDarkTheme(); +} + } // namespace electron diff --git a/shell/browser/ui/electron_desktop_window_tree_host_linux.h b/shell/browser/ui/electron_desktop_window_tree_host_linux.h index cfd22c0892..560a76b22f 100644 --- a/shell/browser/ui/electron_desktop_window_tree_host_linux.h +++ b/shell/browser/ui/electron_desktop_window_tree_host_linux.h @@ -62,6 +62,9 @@ class ElectronDesktopWindowTreeHostLinux // views::DesktopWindowTreeHostLinux: void UpdateFrameHints() override; void DispatchEvent(ui::Event* event) override; + void AddAdditionalInitProperties( + const views::Widget::InitParams& params, + ui::PlatformWindowInitProperties* properties) override; private: void UpdateWindowState(ui::PlatformWindowState new_state);