From f0924df68ab078b2cd35b9127a84c3165db9a40a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 11 Feb 2015 12:12:22 +0800 Subject: [PATCH] Add "type" option to change window type --- atom/browser/native_window_views.cc | 5 +++++ atom/browser/ui/x/x_window_utils.cc | 15 +++++++++++++++ atom/browser/ui/x/x_window_utils.h | 5 +++++ atom/common/options_switches.cc | 3 +++ atom/common/options_switches.h | 1 + 5 files changed, 29 insertions(+) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index af0c1520c09..8d34180c991 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -225,6 +225,11 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents, ui::SetAtomArrayProperty(GetAcceleratedWidget(), "_NET_WM_STATE", "ATOM", state_atom_list); } + + // Set the _NET_WM_WINDOW_TYPE. + std::string window_type; + if (options.Get(switches::kType, &window_type)) + SetWindowType(GetAcceleratedWidget(), window_type); #endif // Add web view. diff --git a/atom/browser/ui/x/x_window_utils.cc b/atom/browser/ui/x/x_window_utils.cc index 6184672fc2c..eaef5475b77 100644 --- a/atom/browser/ui/x/x_window_utils.cc +++ b/atom/browser/ui/x/x_window_utils.cc @@ -4,6 +4,9 @@ #include "atom/browser/ui/x/x_window_utils.h" +#include + +#include "base/strings/string_util.h" #include "ui/base/x/x11_util.h" namespace atom { @@ -31,4 +34,16 @@ void SetWMSpecState(::Window xwindow, bool enabled, ::Atom state) { &xclient); } +void SetWindowType(::Window xwindow, const std::string& type) { + XDisplay* xdisplay = gfx::GetXDisplay(); + std::string type_prefix = "_NET_WM_WINDOW_TYPE_"; + ::Atom window_type = XInternAtom( + xdisplay, (type_prefix + StringToUpperASCII(type)).c_str(), False); + XChangeProperty(xdisplay, xwindow, + XInternAtom(xdisplay, "_NET_WM_WINDOW_TYPE", False), + XA_ATOM, + 32, PropModeReplace, + reinterpret_cast(&window_type), 1); +} + } // namespace atom diff --git a/atom/browser/ui/x/x_window_utils.h b/atom/browser/ui/x/x_window_utils.h index f0931b9f90b..ccf56d1eb9c 100644 --- a/atom/browser/ui/x/x_window_utils.h +++ b/atom/browser/ui/x/x_window_utils.h @@ -9,6 +9,8 @@ #include #include +#include + namespace atom { ::Atom GetAtom(const char* name); @@ -17,6 +19,9 @@ namespace atom { // for _NET_WM_STATE. void SetWMSpecState(::Window xwindow, bool enabled, ::Atom state); +// Sets the _NET_WM_WINDOW_TYPE of window. +void SetWindowType(::Window xwindow, const std::string& type); + } // namespace atom #endif // ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_ diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index 76cfad3319a..f67a6456964 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -72,6 +72,9 @@ const char kPreloadScript[] = "preload"; // Whether the window should be transparent. const char kTransparent[] = "transparent"; +// Window type hint. +const char kType[] = "type"; + // Web runtime features. const char kExperimentalFeatures[] = "experimental-features"; const char kExperimentalCanvasFeatures[] = "experimental-canvas-features"; diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index a2cfb574dfc..967f6263873 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -40,6 +40,7 @@ extern const char kEnablePlugins[]; extern const char kGuestInstanceID[]; extern const char kPreloadScript[]; extern const char kTransparent[]; +extern const char kType[]; extern const char kExperimentalFeatures[]; extern const char kExperimentalCanvasFeatures[];