From fa3d9d32aee14a3e083e75d255461a8ed28ecae3 Mon Sep 17 00:00:00 2001 From: Aleksei Kuzmin Date: Thu, 21 Dec 2017 01:02:49 +0300 Subject: [PATCH] Use XDG_CURRENT_DESKTOP to determine if the desktop environment is Unity https://chromium-review.googlesource.com/682615 --- brightray/browser/views/views_delegate.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/brightray/browser/views/views_delegate.cc b/brightray/browser/views/views_delegate.cc index 750af7ef271..0546026abd9 100644 --- a/brightray/browser/views/views_delegate.cc +++ b/brightray/browser/views/views_delegate.cc @@ -8,9 +8,22 @@ #include "ui/views/widget/native_widget_aura.h" #if defined(OS_LINUX) +#include "base/environment.h" +#include "base/nix/xdg_util.h" #include "ui/views/linux_ui/linux_ui.h" #endif +namespace { + +bool IsDesktopEnvironmentUnity() { + std::unique_ptr env(base::Environment::Create()); + base::nix::DesktopEnvironment desktop_env = + base::nix::GetDesktopEnvironment(env.get()); + return desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY; +} + +} // namespace + namespace brightray { ViewsDelegate::ViewsDelegate() { @@ -104,8 +117,10 @@ bool ViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) { #if defined(OS_LINUX) // On Ubuntu Unity, the system always provides a title bar for maximized // windows. - views::LinuxUI* ui = views::LinuxUI::instance(); - return maximized && ui && ui->UnityIsRunning(); + if (!maximized) + return false; + static bool is_desktop_environment_unity = IsDesktopEnvironmentUnity(); + return is_desktop_environment_unity; #else return false; #endif