Merge pull request #858 from atom/wm-class

Use app's name for WM_CLASS
This commit is contained in:
Cheng Zhao 2014-11-24 16:12:07 +08:00
commit 84fcfd1fac
3 changed files with 18 additions and 11 deletions

View file

@ -35,7 +35,7 @@
#include "atom/browser/ui/x/x_window_utils.h" #include "atom/browser/ui/x/x_window_utils.h"
#include "base/environment.h" #include "base/environment.h"
#include "base/nix/xdg_util.h" #include "base/nix/xdg_util.h"
#include "base/strings/stringprintf.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/bus.h"
#include "dbus/object_proxy.h" #include "dbus/object_proxy.h"
@ -63,10 +63,6 @@ const int kMenuBarHeight = 25;
#endif #endif
#if defined(USE_X11) #if defined(USE_X11)
// Counts how many window has already been created, it will be used to set the
// window role for X11.
int kWindowsCreated = 0;
// Returns true if the bus name "com.canonical.AppMenu.Registrar" is available. // Returns true if the bus name "com.canonical.AppMenu.Registrar" is available.
bool ShouldUseGlobalMenuBar() { bool ShouldUseGlobalMenuBar() {
dbus::Bus::Options options; dbus::Bus::Options options;
@ -182,13 +178,12 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
params.remove_standard_frame = !has_frame_; params.remove_standard_frame = !has_frame_;
#if defined(USE_X11) #if defined(USE_X11)
std::string name = Browser::Get()->GetName();
// Set WM_WINDOW_ROLE. // Set WM_WINDOW_ROLE.
params.wm_role_name = base::StringPrintf( params.wm_role_name = "browser-window";
"%s/%s/%d", "Atom Shell", Browser::Get()->GetName().c_str(),
++kWindowsCreated);
// Set WM_CLASS. // Set WM_CLASS.
params.wm_class_name = "atom"; params.wm_class_name = base::StringToLowerASCII(name);
params.wm_class_class = "Atom"; params.wm_class_class = name;
#endif #endif
window_->Init(params); window_->Init(params);
@ -725,6 +720,14 @@ gfx::ImageSkia NativeWindowViews::GetDevToolsWindowIcon() {
return GetWindowAppIcon(); return GetWindowAppIcon();
} }
#if defined(USE_X11)
void NativeWindowViews::GetDevToolsWindowWMClass(
std::string* name, std::string* class_name) {
*class_name = Browser::Get()->GetName();
*name = base::StringToLowerASCII(*class_name);
}
#endif
void NativeWindowViews::HandleMouseDown() { void NativeWindowViews::HandleMouseDown() {
// Hide menu bar when web view is clicked. // Hide menu bar when web view is clicked.
if (menu_bar_autohide_ && menu_bar_visible_) if (menu_bar_autohide_ && menu_bar_visible_)

View file

@ -113,6 +113,10 @@ class NativeWindowViews : public NativeWindow,
// brightray::InspectableWebContentsDelegate: // brightray::InspectableWebContentsDelegate:
gfx::ImageSkia GetDevToolsWindowIcon() override; gfx::ImageSkia GetDevToolsWindowIcon() override;
#if defined(USE_X11)
void GetDevToolsWindowWMClass(
std::string* name, std::string* class_name) override;
#endif
// content::WebContentsDelegate: // content::WebContentsDelegate:
void HandleMouseDown() override; void HandleMouseDown() override;

2
vendor/brightray vendored

@ -1 +1 @@
Subproject commit ddfebd06326a956145dfde6ed5f863396953da6d Subproject commit 313defa8a49c45250014e7c4ec2275d50dfd490d