]> khamidou — GitHub mirrors - electron.git/commitdiff
Add "type" option to change window type
authorCheng Zhao <zcbenz@gmail.com>
Wed, 11 Feb 2015 04:12:22 +0000 (12:12 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 11 Feb 2015 04:19:39 +0000 (12:19 +0800)
atom/browser/native_window_views.cc
atom/browser/ui/x/x_window_utils.cc
atom/browser/ui/x/x_window_utils.h
atom/common/options_switches.cc
atom/common/options_switches.h

index af0c1520c0981700338c6e489bea2eca3a02a88d..8d34180c99177770fe3ec849f31463ed7f81bdd8 100644 (file)
@@ -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.
index 6184672fc2c5b06f3336d915153da1ea9436715e..eaef5475b7778d0dee2d0a6a40431f62599e9d7f 100644 (file)
@@ -4,6 +4,9 @@
 
 #include "atom/browser/ui/x/x_window_utils.h"
 
+#include <X11/Xatom.h>
+
+#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<unsigned char*>(&window_type), 1);
+}
+
 }  // namespace atom
index f0931b9f90b0b5d3a50d8571f063eb05548e4f4a..ccf56d1eb9cf67a5d6e8d020d3b234c441a93804 100644 (file)
@@ -9,6 +9,8 @@
 #include <X11/extensions/Xrandr.h>
 #include <X11/Xlib.h>
 
+#include <string>
+
 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_
index 76cfad3319a6bbea5066a86544dfc8dd0c489f5a..f67a6456964cc378f66bac53f64a0dc038981781 100644 (file)
@@ -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";
index a2cfb574dfcc13c6c0fbdbbcd84d96da2cd7440f..967f626387335939218c08871f23392dca2ac06d 100644 (file)
@@ -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[];