New API supported on Yosemite 10.10 and newer.
styleMask |= NSTexturedBackgroundWindowMask;
}
+ std::string titleBarStyle = "default";
+ options.Get(switches::kTitleBarStyle, &titleBarStyle);
+
+ if (base::mac::IsOSYosemiteOrLater()) {
+ // New title bar styles are available in Yosemite or newer
+ if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) {
+ styleMask |= NSFullSizeContentViewWindowMask;
+ styleMask |= NSUnifiedTitleAndToolbarWindowMask;
+ }
+ }
+
window_.reset([[AtomNSWindow alloc]
initWithContentRect:cocoa_bounds
styleMask:styleMask
// We will manage window's lifetime ourselves.
[window_ setReleasedWhenClosed:NO];
+ // Configure title bar look on Yosemite or newer
+ if (base::mac::IsOSYosemiteOrLater()) {
+ if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) {
+ [window_ setTitlebarAppearsTransparent:YES];
+ [window_ setTitleVisibility:NSWindowTitleHidden];
+ if (titleBarStyle == "hidden-inset") {
+ NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"];
+ toolbar.showsBaselineSeparator = NO;
+ [window_ setToolbar:toolbar];
+ [toolbar release];
+ }
+ }
+ }
+
// On OS X the initial window size doesn't include window frame.
bool use_content_size = false;
options.Get(switches::kUseContentSize, &use_content_size);
// Whether window size should include window frame.
const char kUseContentSize[] = "use-content-size";
+// The requested title bar style for the window
+const char kTitleBarStyle[] = "title-bar-style";
+
// The WebPreferences.
const char kWebPreferences[] = "web-preferences";
extern const char kNodeIntegration[];
extern const char kAcceptFirstMouse[];
extern const char kUseContentSize[];
+extern const char kTitleBarStyle[];
extern const char kWebPreferences[];
extern const char kZoomFactor[];
extern const char kAutoHideMenuBar[];
Linux.
* `standard-window` Boolean - Uses the OS X's standard window instead of the
textured window. Defaults to `true`.
+* `title-bar-style` String, OS X - specifies the style of window title bar.
+ This option is supported on OS X 10.10 Yosemite and newer. There are three
+ possible values:
+ * `default` or not specified results in the standard gray opaque Mac title
+ bar.
+ * `hidden` results in a hidden title bar and a full size content window, yet
+ the title bar still has the standard window controls ("traffic lights") in
+ the top left.
+ * `hidden-inset` results in a hidden title bar with an alternative look
+ where the traffic light buttons are slightly more inset from the window edge.
* `web-preferences` Object - Settings of web page's features, properties:
* `node-integration` Boolean - Whether node integration is enabled. Default
is `true`.
var win = new BrowserWindow({ width: 800, height: 600, frame: false });
```
+### Alternatives on Mac
+
+On Mac OS X 10.10 Yosemite and newer, there's an alternative way to specify
+a chromeless window. Instead of setting `frame` to `false` which disables
+both the titlebar and window controls, you may want to have the title bar
+hidden and your content extend to the full window size, yet still preserve
+the window controls ("traffic lights") for standard window actions.
+You can do so by specifying the new `title-bar-style` option:
+
+```javascript
+var BrowserWindow = require('browser-window');
+var win = new BrowserWindow({ width: 800, height: 600, 'title-bar-style': 'hidden' });
+```
+
## Transparent window
By setting the `transparent` option to `true`, you can also make the frameless
remote = require 'remote'
http = require 'http'
url = require 'url'
+os = require 'os'
BrowserWindow = remote.require 'browser-window'
assert.equal size[0], 400
assert.equal size[1], 400
+ describe '"title-bar-style" option', ->
+ return if process.platform isnt 'darwin'
+ return if parseInt(os.release().split('.')[0]) < 14 # only run these tests on Yosemite or newer
+
+ it 'creates browser window with hidden title bar', ->
+ w.destroy()
+ w = new BrowserWindow(show: false, width: 400, height: 400, 'title-bar-style': 'hidden')
+ contentSize = w.getContentSize()
+ assert.equal contentSize[1], 400
+
+ it 'creates browser window with hidden inset title bar', ->
+ w.destroy()
+ w = new BrowserWindow(show: false, width: 400, height: 400, 'title-bar-style': 'hidden-inset')
+ contentSize = w.getContentSize()
+ assert.equal contentSize[1], 400
+
describe '"enable-larger-than-screen" option', ->
return if process.platform is 'linux'