Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for titleBarStyle: 'hidden' on OS X 10.9 #6848

Merged
merged 1 commit into from Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions atom/browser/native_window_mac.h
Expand Up @@ -127,6 +127,8 @@ class NativeWindowMac : public NativeWindow,
void UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) override;

void ShowWindowButton(NSWindowButton button);

void InstallView();
void UninstallView();

Expand Down
24 changes: 19 additions & 5 deletions atom/browser/native_window_mac.mm
Expand Up @@ -416,7 +416,11 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
*out = atom::NativeWindowMac::HIDDEN;
} else if (title_bar_style == "hidden-inset" || // Deprecate this after 2.0
title_bar_style == "hiddenInset") {
*out = atom::NativeWindowMac::HIDDEN_INSET;
if (base::mac::IsOSYosemiteOrLater()) {
*out = atom::NativeWindowMac::HIDDEN_INSET;
} else {
*out = atom::NativeWindowMac::HIDDEN;
}
} else {
return false;
}
Expand Down Expand Up @@ -460,9 +464,7 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
bool closable = true;
options.Get(options::kClosable, &closable);

// New title bar styles are available in Yosemite or newer
if (base::mac::IsOSYosemiteOrLater())
options.Get(options::kTitleBarStyle, &title_bar_style_);
options.Get(options::kTitleBarStyle, &title_bar_style_);

std::string windowType;
options.Get(options::kType, &windowType);
Expand Down Expand Up @@ -1099,6 +1101,11 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
UpdateDraggableRegionViews(regions);
}

void NativeWindowMac::ShowWindowButton(NSWindowButton button) {
auto view = [window_ standardWindowButton:button];
[view.superview addSubview:view positioned:NSWindowAbove relativeTo:nil];
}

void NativeWindowMac::InstallView() {
// Make sure the bottom corner is rounded: http://crbug.com/396264.
// But do not enable it on OS X 10.9 for transparent window, otherwise a
Expand Down Expand Up @@ -1127,8 +1134,15 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
// The fullscreen button should always be hidden for frameless window.
[[window_ standardWindowButton:NSWindowFullScreenButton] setHidden:YES];

if (title_bar_style_ != NORMAL)
if (title_bar_style_ != NORMAL) {
if (base::mac::IsOSMavericks()) {
ShowWindowButton(NSWindowZoomButton);
ShowWindowButton(NSWindowMiniaturizeButton);
ShowWindowButton(NSWindowCloseButton);
}

return;
}

// Hide the window buttons.
[[window_ standardWindowButton:NSWindowZoomButton] setHidden:YES];
Expand Down
3 changes: 2 additions & 1 deletion docs/api/browser-window.md
Expand Up @@ -208,7 +208,7 @@ Possible values are:
input sparingly.
* On Windows, possible type is `toolbar`.

The `titleBarStyle` option is only supported on macOS 10.10 Yosemite and newer.
The `titleBarStyle` option.
Possible values are:

* `default` or not specified, results in the standard gray opaque Mac title
Expand All @@ -218,6 +218,7 @@ Possible values are:
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.
It is not supported on macOS 10.9 Mavericks, where it falls back to `hidden`.

The `webPreferences` option is an object that can have the following properties:

Expand Down