Merge pull request #726 from atom/dbus-checking-menu
Fix detecting global menu bar on Ubuntu
This commit is contained in:
commit
b09252f13e
5 changed files with 43 additions and 11 deletions
6
atom.gyp
6
atom.gyp
|
@ -561,6 +561,10 @@
|
|||
'-rpath \$$ORIGIN',
|
||||
# Make native module dynamic loading work.
|
||||
'-rdynamic',
|
||||
'<!@(pkg-config --libs-only-L --libs-only-other dbus-1)',
|
||||
],
|
||||
'libraries': [
|
||||
'<!@(pkg-config --libs-only-l dbus-1)',
|
||||
],
|
||||
},
|
||||
# Required settings of using breakpad.
|
||||
|
@ -568,8 +572,10 @@
|
|||
'vendor/breakpad/src',
|
||||
],
|
||||
'cflags': [
|
||||
'<!@(pkg-config --cflags dbus-1)',
|
||||
'-Wno-deprecated-register',
|
||||
'-Wno-empty-body',
|
||||
'-Wno-reserved-user-defined-literal',
|
||||
],
|
||||
'dependencies': [
|
||||
'vendor/breakpad/breakpad.gyp:breakpad_client',
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
#include "base/nix/xdg_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "chrome/browser/ui/libgtk2ui/unity_service.h"
|
||||
#include "dbus/bus.h"
|
||||
#include "dbus/object_proxy.h"
|
||||
#include "dbus/message.h"
|
||||
#include "ui/base/x/x11_util.h"
|
||||
#include "ui/gfx/x/x11_types.h"
|
||||
#include "ui/views/window/native_frame_view.h"
|
||||
|
@ -64,16 +67,38 @@ const int kMenuBarHeight = 25;
|
|||
// window role for X11.
|
||||
int kWindowsCreated = 0;
|
||||
|
||||
// Returns true if the bus name "com.canonical.AppMenu.Registrar" is available.
|
||||
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());
|
||||
bool is_unity = unity::IsRunning() &&
|
||||
base::nix::GetDesktopEnvironment(env.get()) ==
|
||||
base::nix::DESKTOP_ENVIRONMENT_UNITY;
|
||||
std::string menu_proxy;
|
||||
return is_unity && env->GetVar("UBUNTU_MENUPROXY", &menu_proxy) &&
|
||||
menu_proxy.length() > 1;
|
||||
dbus::Bus::Options options;
|
||||
scoped_refptr<dbus::Bus> bus(new dbus::Bus(options));
|
||||
|
||||
dbus::ObjectProxy* object_proxy =
|
||||
bus->GetObjectProxy(DBUS_SERVICE_DBUS, dbus::ObjectPath(DBUS_PATH_DBUS));
|
||||
dbus::MethodCall method_call(DBUS_INTERFACE_DBUS, "ListNames");
|
||||
scoped_ptr<dbus::Response> response(object_proxy->CallMethodAndBlock(
|
||||
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
|
||||
if (!response) {
|
||||
bus->ShutdownAndBlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
dbus::MessageReader reader(response.get());
|
||||
dbus::MessageReader array_reader(NULL);
|
||||
if (!reader.PopArray(&array_reader)) {
|
||||
bus->ShutdownAndBlock();
|
||||
return false;
|
||||
}
|
||||
while (array_reader.HasMoreData()) {
|
||||
std::string name;
|
||||
if (array_reader.PopString(&name) &&
|
||||
name == "com.canonical.AppMenu.Registrar") {
|
||||
bus->ShutdownAndBlock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bus->ShutdownAndBlock();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
On Ubuntu you could install the libraries via:
|
||||
|
||||
```bash
|
||||
$ sudo apt-get install build-essential clang libgtk2.0-dev libnotify-dev gcc-multilib g++-multilib
|
||||
$ sudo apt-get install build-essential clang libdbus-1-dev libgtk2.0-dev libnotify-dev gcc-multilib g++-multilib
|
||||
```
|
||||
|
||||
Latest Node.js could be installed via ppa:
|
||||
|
|
|
@ -10,6 +10,7 @@ from lib.util import execute, rm_rf, scoped_env
|
|||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
|
||||
LINUX_DEPS = [
|
||||
'libdbus-1-dev',
|
||||
'libgnome-keyring-dev',
|
||||
'libgtk2.0-dev',
|
||||
'libnotify-dev',
|
||||
|
|
|
@ -4,7 +4,7 @@ import platform
|
|||
import sys
|
||||
|
||||
BASE_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent'
|
||||
LIBCHROMIUMCONTENT_COMMIT = '9f5271d31e0f32eac5a20ef6f543e3f1d43ad645'
|
||||
LIBCHROMIUMCONTENT_COMMIT = '56984fa0e4c3c745652510f342c0fb2724d846c2'
|
||||
|
||||
ARCH = {
|
||||
'cygwin': '32bit',
|
||||
|
|
Loading…
Add table
Reference in a new issue