Merge pull request #1122 from atom/window-type

Add "type" option to change window type of BrowserWindow
This commit is contained in:
Cheng Zhao 2015-02-11 12:31:44 +08:00
commit 564c0b41df
6 changed files with 32 additions and 0 deletions

View 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.

View 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

View 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_

View 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";

View 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[];

View file

@ -68,6 +68,9 @@ You can also create a window without chrome by using
no matter whether node integration is turned on for the window, and the path
of `preload` script has to be absolute path.
* `transparent` Boolean - Makes the window [transparent](frameless-window.md)
* `type` String - Specifies the type of the window, possible types are
`desktop`, `dock`, `toolbar`, `splash`, `notification`. This only works on
Linux.
* `web-preferences` Object - Settings of web page's features
* `javascript` Boolean
* `web-security` Boolean