Skip to content

Commit

Permalink
Fix GTK native theming for non-browser windows
Browse files Browse the repository at this point in the history
This fixes a regression after [1].  We want to continue to use the
LinuxUI instance for getting the NativeTheme for all windows, not just
browser windows.

[1] https://crrev.com/c/2803073

R=sky

Bug: 1203346
Change-Id: I26cb9610e1f14927b60083ccd27ce408cafc7be9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2872864
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#879192}
  • Loading branch information
tanderson-google authored and Chromium LUCI CQ committed May 5, 2021
1 parent 239aaf3 commit 3906206
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 0 additions & 7 deletions chrome/browser/ui/views/frame/browser_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
// of lacros-chrome is complete.
#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
#include "ui/display/screen.h"
#include "ui/views/linux_ui/linux_ui.h"
#endif

namespace {
Expand Down Expand Up @@ -355,12 +354,6 @@ void BrowserFrame::SelectNativeTheme() {
}
}

#if defined(OS_LINUX) || defined(IS_CHROMEOS_LACROS)
const views::LinuxUI* linux_ui = views::LinuxUI::instance();
if (linux_ui)
native_theme = linux_ui->GetNativeTheme(GetNativeWindow());
#endif

SetNativeTheme(native_theme);
}

Expand Down
11 changes: 11 additions & 0 deletions ui/views/widget/widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
#include "ui/views/window/custom_frame_view.h"
#include "ui/views/window/dialog_delegate.h"

#if defined(OS_LINUX)
#include "ui/views/linux_ui/linux_ui.h"
#endif

namespace views {

namespace {
Expand Down Expand Up @@ -1647,6 +1651,13 @@ const ui::NativeTheme* Widget::GetNativeTheme() const {
parent_)
return parent_->GetNativeTheme();

#if defined(OS_LINUX)
if (const views::LinuxUI* linux_ui = views::LinuxUI::instance()) {
if (auto* native_theme = linux_ui->GetNativeTheme(GetNativeWindow()))
return native_theme;
}
#endif

return ui::NativeTheme::GetInstanceForNativeUi();
}

Expand Down

0 comments on commit 3906206

Please sign in to comment.