diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index efadac5c46bd..b38711ebd88a 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -150,6 +150,19 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents, window_->Init(params); +#if defined(USE_X11) + bool use_dark_theme = false; + if (options.Get(switches::kDarkTheme, &use_dark_theme) && use_dark_theme) { + XDisplay* xdisplay = gfx::GetXDisplay(); + XChangeProperty(xdisplay, GetAcceleratedWidget(), + XInternAtom(xdisplay, "_GTK_THEME_VARIANT", False), + XInternAtom(xdisplay, "UTF8_STRING", False), + 8, PropModeReplace, + reinterpret_cast("dark"), + 4); + } +#endif + // Add web view. SetLayoutManager(new MenuLayout(kMenuBarHeight)); set_background(views::Background::CreateStandardPanelBackground()); diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index cfde597a9be1..e322c2230f09 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -54,6 +54,9 @@ const char kAutoHideMenuBar[] = "auto-hide-menu-bar"; // Enable window to be resized larger than screen. const char kEnableLargerThanScreen[] = "enable-larger-than-screen"; +// Forces to use dark theme on Linux. +const char kDarkTheme[] = "dark-theme"; + } // namespace switches } // namespace atom diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index 8c6cd072df46..f571e3f431d1 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -34,6 +34,7 @@ extern const char kWebPreferences[]; extern const char kZoomFactor[]; extern const char kAutoHideMenuBar[]; extern const char kEnableLargerThanScreen[]; +extern const char kDarkTheme[]; } // namespace switches diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index dc85eac1d58a..a912dc6ef51c 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -63,6 +63,8 @@ normal browsers, see [Web Security](web-security.md) for more. key is pressed. * `enable-larger-than-screen` Boolean - Enable the window to be resized larger than screen. + * `dark-theme` Boolean - Forces using dark theme for the window, only works on + some GTK+3 desktop environments. * `web-preferences` Object - Settings of web page's features * `javascript` Boolean * `web-security` Boolean