From 60bd20872cb3540cf20b2f39d4d43d805aec0f7a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 24 Nov 2014 15:23:02 +0800 Subject: [PATCH 1/3] linux: Set WM_WINDOW_ROLE correctly WM_WINDOW_ROLE is used to specify the "role" of the window, and all browser windows in atom-shell should have the same role. --- atom/browser/native_window_views.cc | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index eb5f31d459..7136efccbd 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -35,7 +35,6 @@ #include "atom/browser/ui/x/x_window_utils.h" #include "base/environment.h" #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" @@ -63,10 +62,6 @@ const int kMenuBarHeight = 25; #endif #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. bool ShouldUseGlobalMenuBar() { dbus::Bus::Options options; @@ -183,9 +178,7 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents, #if defined(USE_X11) // Set WM_WINDOW_ROLE. - params.wm_role_name = base::StringPrintf( - "%s/%s/%d", "Atom Shell", Browser::Get()->GetName().c_str(), - ++kWindowsCreated); + params.wm_role_name = "atom-shell app"; // Set WM_CLASS. params.wm_class_name = "atom"; params.wm_class_class = "Atom"; From 172c55d194166423415b6437ecaf35779fae9267 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 24 Nov 2014 15:27:36 +0800 Subject: [PATCH 2/3] linux: Use app's name for WM_CLASS --- atom/browser/native_window_views.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 7136efccbd..f9dcd3a4c8 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -35,6 +35,7 @@ #include "atom/browser/ui/x/x_window_utils.h" #include "base/environment.h" #include "base/nix/xdg_util.h" +#include "base/strings/string_util.h" #include "chrome/browser/ui/libgtk2ui/unity_service.h" #include "dbus/bus.h" #include "dbus/object_proxy.h" @@ -177,11 +178,12 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents, params.remove_standard_frame = !has_frame_; #if defined(USE_X11) + std::string name = Browser::Get()->GetName(); // Set WM_WINDOW_ROLE. - params.wm_role_name = "atom-shell app"; + params.wm_role_name = "browser-window"; // Set WM_CLASS. - params.wm_class_name = "atom"; - params.wm_class_class = "Atom"; + params.wm_class_name = base::StringToLowerASCII(name); + params.wm_class_class = name; #endif window_->Init(params); From cd5007cfa1797c89667509242525e41a222acc27 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 24 Nov 2014 16:04:41 +0800 Subject: [PATCH 3/3] linux: Set WM_CLASS for devtools window --- atom/browser/native_window_views.cc | 8 ++++++++ atom/browser/native_window_views.h | 4 ++++ vendor/brightray | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index f9dcd3a4c8..05a72fbe55 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -720,6 +720,14 @@ gfx::ImageSkia NativeWindowViews::GetDevToolsWindowIcon() { 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() { // Hide menu bar when web view is clicked. if (menu_bar_autohide_ && menu_bar_visible_) diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index fe7df26917..97baa2a463 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -113,6 +113,10 @@ class NativeWindowViews : public NativeWindow, // brightray::InspectableWebContentsDelegate: gfx::ImageSkia GetDevToolsWindowIcon() override; +#if defined(USE_X11) + void GetDevToolsWindowWMClass( + std::string* name, std::string* class_name) override; +#endif // content::WebContentsDelegate: void HandleMouseDown() override; diff --git a/vendor/brightray b/vendor/brightray index ddfebd0632..313defa8a4 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit ddfebd06326a956145dfde6ed5f863396953da6d +Subproject commit 313defa8a49c45250014e7c4ec2275d50dfd490d