From c9bc3471e7bf30c8b0a485c8d739f42a2aa071d8 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 25 Sep 2018 13:57:06 -0700 Subject: [PATCH] fix: get background color from GtkMenuBar#menubar (#14785) * fix: get background color from GtkMenuBar#menubar * expose libgtkui::GetBgColor --- atom/browser/ui/views/menu_bar.cc | 13 +++++++++++-- patches/common/chromium/libgtkui_export.patch | 9 +++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/atom/browser/ui/views/menu_bar.cc b/atom/browser/ui/views/menu_bar.cc index 31ef332c9c04..332a42b513a1 100644 --- a/atom/browser/ui/views/menu_bar.cc +++ b/atom/browser/ui/views/menu_bar.cc @@ -5,6 +5,7 @@ #include "atom/browser/ui/views/menu_bar.h" #include +#include #include "atom/browser/ui/views/menu_delegate.h" #include "atom/browser/ui/views/submenu_button.h" @@ -12,6 +13,10 @@ #include "ui/views/background.h" #include "ui/views/layout/box_layout.h" +#if defined(USE_X11) +#include "chrome/browser/ui/libgtkui/gtk_util.h" +#endif + #if defined(OS_WIN) #include "ui/gfx/color_utils.h" #endif @@ -123,13 +128,17 @@ void MenuBar::RefreshColorCache(const ui::NativeTheme* theme) { if (!theme) theme = ui::NativeTheme::GetInstanceForNativeUi(); if (theme) { - background_color_ = - theme->GetSystemColor(ui::NativeTheme::kColorId_MenuBackgroundColor); #if defined(USE_X11) + const std::string menubar_selector = "GtkMenuBar#menubar"; + background_color_ = libgtkui::GetBgColor(menubar_selector); + enabled_color_ = theme->GetSystemColor( ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); disabled_color_ = theme->GetSystemColor( ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); +#else + background_color_ = + theme->GetSystemColor(ui::NativeTheme::kColorId_MenuBackgroundColor); #endif } #if defined(OS_WIN) diff --git a/patches/common/chromium/libgtkui_export.patch b/patches/common/chromium/libgtkui_export.patch index d0aa9ec2c5cd..ed09eaadc3c4 100644 --- a/patches/common/chromium/libgtkui_export.patch +++ b/patches/common/chromium/libgtkui_export.patch @@ -74,6 +74,15 @@ index 665ec57..4ccb088 100644 // Gets the transient parent aura window for |dialog|. aura::Window* GetAuraTransientParent(GtkWidget* dialog); +@@ -190,7 +190,7 @@ void RenderBackground(const gfx::Size& size, + // Renders a background from the style context created by + // GetStyleContextFromCss(|css_selector|) into a 24x24 bitmap and + // returns the average color. +-SkColor GetBgColor(const std::string& css_selector); ++LIBGTKUI_EXPORT SkColor GetBgColor(const std::string& css_selector); + + // Renders the border from the style context created by + // GetStyleContextFromCss(|css_selector|) into a 24x24 bitmap and diff --git a/chrome/browser/ui/libgtkui/skia_utils_gtk.h b/chrome/browser/ui/libgtkui/skia_utils_gtk.h index e05fbe9..3afca9a 100644 --- a/chrome/browser/ui/libgtkui/skia_utils_gtk.h