Move ShouldUseGlobalMenuBar to x_window_utils
This commit is contained in:
parent
58b1172025
commit
adbb909b39
3 changed files with 39 additions and 39 deletions
|
@ -43,9 +43,6 @@
|
||||||
#include "base/nix/xdg_util.h"
|
#include "base/nix/xdg_util.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "chrome/browser/ui/libgtk2ui/unity_service.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/base/x/x11_util.h"
|
||||||
#include "ui/gfx/x/x11_types.h"
|
#include "ui/gfx/x/x11_types.h"
|
||||||
#include "ui/views/window/native_frame_view.h"
|
#include "ui/views/window/native_frame_view.h"
|
||||||
|
@ -70,42 +67,6 @@ const int kMenuBarHeight = 20;
|
||||||
const int kMenuBarHeight = 25;
|
const int kMenuBarHeight = 25;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_X11)
|
|
||||||
// Returns true if the bus name "com.canonical.AppMenu.Registrar" is available.
|
|
||||||
bool ShouldUseGlobalMenuBar() {
|
|
||||||
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
|
|
||||||
|
|
||||||
bool IsAltKey(const content::NativeWebKeyboardEvent& event) {
|
bool IsAltKey(const content::NativeWebKeyboardEvent& event) {
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
// 164 and 165 represent VK_LALT and VK_RALT.
|
// 164 and 165 represent VK_LALT and VK_RALT.
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
|
#include "dbus/bus.h"
|
||||||
|
#include "dbus/object_proxy.h"
|
||||||
|
#include "dbus/message.h"
|
||||||
#include "ui/base/x/x11_util.h"
|
#include "ui/base/x/x11_util.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -46,4 +49,37 @@ void SetWindowType(::Window xwindow, const std::string& type) {
|
||||||
reinterpret_cast<unsigned char*>(&window_type), 1);
|
reinterpret_cast<unsigned char*>(&window_type), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShouldUseGlobalMenuBar() {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -22,6 +22,9 @@ void SetWMSpecState(::Window xwindow, bool enabled, ::Atom state);
|
||||||
// Sets the _NET_WM_WINDOW_TYPE of window.
|
// Sets the _NET_WM_WINDOW_TYPE of window.
|
||||||
void SetWindowType(::Window xwindow, const std::string& type);
|
void SetWindowType(::Window xwindow, const std::string& type);
|
||||||
|
|
||||||
|
// Returns true if the bus name "com.canonical.AppMenu.Registrar" is available.
|
||||||
|
bool ShouldUseGlobalMenuBar();
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
#endif // ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_
|
#endif // ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_
|
||||||
|
|
Loading…
Reference in a new issue