linux: Only use global menu bar under Unity.

Fixes atom/atom#3182.
This commit is contained in:
Cheng Zhao 2014-08-06 23:34:16 +08:00
parent 15c31ad1ba
commit a888e4b960

View file

@ -39,6 +39,8 @@
#if defined(USE_X11)
#include "atom/browser/ui/views/global_menu_bar_x11.h"
#include "atom/browser/ui/views/frameless_view.h"
#include "base/environment.h"
#include "base/nix/xdg_util.h"
#include "chrome/browser/ui/libgtk2ui/unity_service.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/views/window/native_frame_view.h"
@ -59,6 +61,16 @@ const int kMenuBarHeight = 20;
const int kMenuBarHeight = 25;
#endif
#if defined(USE_X11)
bool ShouldUseGlobalMenuBar() {
// Some DE would pretend to be Unity but don't have global application menu,
// so we can not trust unity::IsRunning().
scoped_ptr<base::Environment> env(base::Environment::Create());
return unity::IsRunning() && (base::nix::GetDesktopEnvironment(env.get()) ==
base::nix::DESKTOP_ENVIRONMENT_UNITY);
}
#endif
class NativeWindowClientView : public views::ClientView {
public:
NativeWindowClientView(views::Widget* widget,
@ -355,7 +367,7 @@ void NativeWindowViews::SetMenu(ui::MenuModel* menu_model) {
RegisterAccelerators(menu_model);
#if defined(USE_X11)
if (unity::IsRunning() && !global_menu_bar_)
if (!global_menu_bar_ && ShouldUseGlobalMenuBar())
global_menu_bar_.reset(new GlobalMenuBarX11(this));
// Use global application menu bar when possible.