Merge pull request #1122 from atom/window-type
Add "type" option to change window type of BrowserWindow
This commit is contained in:
commit
564c0b41df
6 changed files with 32 additions and 0 deletions
|
@ -225,6 +225,11 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
|
||||||
ui::SetAtomArrayProperty(GetAcceleratedWidget(), "_NET_WM_STATE", "ATOM",
|
ui::SetAtomArrayProperty(GetAcceleratedWidget(), "_NET_WM_STATE", "ATOM",
|
||||||
state_atom_list);
|
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
|
#endif
|
||||||
|
|
||||||
// Add web view.
|
// Add web view.
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
|
|
||||||
#include "atom/browser/ui/x/x_window_utils.h"
|
#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"
|
#include "ui/base/x/x11_util.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -31,4 +34,16 @@ void SetWMSpecState(::Window xwindow, bool enabled, ::Atom state) {
|
||||||
&xclient);
|
&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
|
} // namespace atom
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include <X11/extensions/Xrandr.h>
|
#include <X11/extensions/Xrandr.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
::Atom GetAtom(const char* name);
|
::Atom GetAtom(const char* name);
|
||||||
|
@ -17,6 +19,9 @@ namespace atom {
|
||||||
// for _NET_WM_STATE.
|
// for _NET_WM_STATE.
|
||||||
void SetWMSpecState(::Window xwindow, bool enabled, ::Atom 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
|
} // namespace atom
|
||||||
|
|
||||||
#endif // ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_
|
#endif // ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_
|
||||||
|
|
|
@ -72,6 +72,9 @@ const char kPreloadScript[] = "preload";
|
||||||
// Whether the window should be transparent.
|
// Whether the window should be transparent.
|
||||||
const char kTransparent[] = "transparent";
|
const char kTransparent[] = "transparent";
|
||||||
|
|
||||||
|
// Window type hint.
|
||||||
|
const char kType[] = "type";
|
||||||
|
|
||||||
// Web runtime features.
|
// Web runtime features.
|
||||||
const char kExperimentalFeatures[] = "experimental-features";
|
const char kExperimentalFeatures[] = "experimental-features";
|
||||||
const char kExperimentalCanvasFeatures[] = "experimental-canvas-features";
|
const char kExperimentalCanvasFeatures[] = "experimental-canvas-features";
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern const char kEnablePlugins[];
|
||||||
extern const char kGuestInstanceID[];
|
extern const char kGuestInstanceID[];
|
||||||
extern const char kPreloadScript[];
|
extern const char kPreloadScript[];
|
||||||
extern const char kTransparent[];
|
extern const char kTransparent[];
|
||||||
|
extern const char kType[];
|
||||||
|
|
||||||
extern const char kExperimentalFeatures[];
|
extern const char kExperimentalFeatures[];
|
||||||
extern const char kExperimentalCanvasFeatures[];
|
extern const char kExperimentalCanvasFeatures[];
|
||||||
|
|
|
@ -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
|
no matter whether node integration is turned on for the window, and the path
|
||||||
of `preload` script has to be absolute path.
|
of `preload` script has to be absolute path.
|
||||||
* `transparent` Boolean - Makes the window [transparent](frameless-window.md)
|
* `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
|
* `web-preferences` Object - Settings of web page's features
|
||||||
* `javascript` Boolean
|
* `javascript` Boolean
|
||||||
* `web-security` Boolean
|
* `web-security` Boolean
|
||||||
|
|
Loading…
Reference in a new issue