From 35cb671529b85ce3ab3430e214b8595950f0e410 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 26 Sep 2018 10:03:33 -0700 Subject: [PATCH] fix: get background color from GtkMenuBar#menubar (#14812) --- atom/browser/ui/views/menu_bar.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/atom/browser/ui/views/menu_bar.cc b/atom/browser/ui/views/menu_bar.cc index 535af8f28031..679e9e44aaf6 100644 --- a/atom/browser/ui/views/menu_bar.cc +++ b/atom/browser/ui/views/menu_bar.cc @@ -4,12 +4,19 @@ #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" #include "ui/base/models/menu_model.h" #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 @@ -29,8 +36,8 @@ MenuBar::MenuBar(views::View* window) : background_color_(kDefaultColor), window_(window) { RefreshColorCache(); UpdateViewColors(); - SetLayoutManager(std::make_unique( - views::BoxLayout::kHorizontal)); + SetLayoutManager( + std::make_unique(views::BoxLayout::kHorizontal)); window_->GetFocusManager()->AddFocusChangeListener(this); } @@ -121,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)