Use XDG_CURRENT_DESKTOP to determine if the desktop environment is Unity

https://chromium-review.googlesource.com/682615
This commit is contained in:
Aleksei Kuzmin 2017-12-21 01:02:49 +03:00
parent e35b128fa3
commit fa3d9d32ae

View file

@ -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<base::Environment> 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