Skip to content

Commit 7d10bf2

Browse files
committed
Switch to titleBarStyle for custom window buttons on hover
1 parent 566e04f commit 7d10bf2

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

atom/browser/native_window_mac.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,12 @@ class NativeWindowMac : public NativeWindow,
127127
NORMAL,
128128
HIDDEN,
129129
HIDDEN_INSET,
130+
CUSTOM_BUTTONS_ON_HOVER,
130131
};
131132
TitleBarStyle title_bar_style() const { return title_bar_style_; }
132133

133134
bool zoom_to_page_width() const { return zoom_to_page_width_; }
134135

135-
bool custom_window_buttons() const { return custom_window_buttons_; }
136-
137136
protected:
138137
// Return a vector of non-draggable regions that fill a window of size
139138
// |width| by |height|, but leave gaps where the window should be draggable.
@@ -178,8 +177,6 @@ class NativeWindowMac : public NativeWindow,
178177

179178
bool zoom_to_page_width_;
180179

181-
bool custom_window_buttons_;
182-
183180
NSInteger attention_request_id_; // identifier from requestUserAttention
184181

185182
// The presentation options before entering kiosk mode.

atom/browser/native_window_mac.mm

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -701,14 +701,14 @@ - (void)previewFileAtPath:(NSString*)path withName:(NSString*) fileName {
701701
// Custom window button methods
702702

703703
- (void)performClose:(id)sender {
704-
if (shell_->custom_window_buttons())
704+
if (shell_->title_bar_style() == atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER)
705705
[[self delegate] windowShouldClose:self];
706706
else
707707
[super performClose:sender];
708708
}
709709

710710
- (void)performMiniaturize:(id)sender {
711-
if (shell_->custom_window_buttons())
711+
if (shell_->title_bar_style() == atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER)
712712
[self miniaturize:self];
713713
else
714714
[super performMiniaturize:sender];
@@ -782,6 +782,8 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
782782
} else if (title_bar_style == "hidden-inset" || // Deprecate this after 2.0
783783
title_bar_style == "hiddenInset") {
784784
*out = atom::NativeWindowMac::HIDDEN_INSET;
785+
} else if (title_bar_style == "customButtonsOnHover") {
786+
*out = atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER;
785787
} else {
786788
return false;
787789
}
@@ -802,7 +804,6 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
802804
is_kiosk_(false),
803805
was_fullscreen_(false),
804806
zoom_to_page_width_(false),
805-
custom_window_buttons_(false),
806807
attention_request_id_(0),
807808
title_bar_style_(NORMAL) {
808809
int width = 800, height = 600;
@@ -844,10 +845,8 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
844845
useStandardWindow = false;
845846
}
846847

847-
options.Get(options::kCustomWindowButtons, &custom_window_buttons_);
848-
849848
NSUInteger styleMask = NSTitledWindowMask;
850-
if (custom_window_buttons_ &&
849+
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
851850
base::mac::IsAtLeastOS10_10() &&
852851
(!useStandardWindow || transparent() || !has_frame())) {
853852
styleMask = NSFullSizeContentViewWindowMask;
@@ -906,7 +905,7 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
906905
if (transparent() || !has_frame()) {
907906
if (base::mac::IsAtLeastOS10_10()) {
908907
// Don't show title bar.
909-
if (custom_window_buttons_) {
908+
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER) {
910909
[window_ setTitlebarAppearsTransparent:YES];
911910
}
912911
[window_ setTitleVisibility:NSWindowTitleHidden];
@@ -1692,7 +1691,7 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
16921691
// The fullscreen button should always be hidden for frameless window.
16931692
[[window_ standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
16941693

1695-
if (custom_window_buttons_) {
1694+
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER) {
16961695
NSView* buttons = [[SemaphoreView alloc] initWithFrame:NSZeroRect];
16971696
buttons.frame = CGRectMake(0,
16981697
[content_view_ bounds].size.height - buttons.frame.size.height,

docs/api/browser-window.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,20 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
191191
Default is `false`.
192192
* `type` String (optional) - The type of window, default is normal window. See more about
193193
this below.
194-
* `titleBarStyle` String (optional) - The style of window title bar. Default is `default`. Possible values are:
194+
* `titleBarStyle` String (optional) - The style of window title bar.
195+
Default is `default`. Possible values are:
195196
* `default` - Results in the standard gray opaque Mac title
196197
bar.
197198
* `hidden` - Results in a hidden title bar and a full size content window, yet
198199
the title bar still has the standard window controls ("traffic lights") in
199200
the top left.
200-
* `hidden-inset` - Results in a hidden title bar with an alternative look
201+
* `hiddenInset` - Results in a hidden title bar with an alternative look
201202
where the traffic light buttons are slightly more inset from the window edge.
203+
* `customButtonsOnHover` Boolean (optional) - Draw custom close, minimize,
204+
and full screen buttons on macOS frameless windows. These buttons will not
205+
display unless hovered over in the top left of the window. These custom
206+
buttons prevent issues with mouse events that occur with the standard
207+
window toolbar buttons. **Note:** This option is currently experimental.
202208
* `thickFrame` Boolean (optional) - Use `WS_THICKFRAME` style for frameless windows on
203209
Windows, which adds standard window frame. Setting it to `false` will remove
204210
window shadow and window animations. Default is `true`.
@@ -214,11 +220,6 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
214220
* `tabbingIdentifier` String (optional) - Tab group name, allows opening the
215221
window as a native tab on macOS 10.12+. Windows with the same tabbing
216222
identifier will be grouped together.
217-
* `customWindowButtons` Boolean (optional) - Draw custom close, minimize,
218-
and full screen buttons on macOS frameless windows. These buttons will not
219-
display unless hovered over in the top left of the window. These custom
220-
buttons prevent issues with mouse events that occur with the standard
221-
window toolbar buttons. **Note:** This option is currently experimental.
222223
* `webPreferences` Object (optional) - Settings of web page's features.
223224
* `devTools` Boolean (optional) - Whether to enable DevTools. If it is set to `false`, can not use `BrowserWindow.webContents.openDevTools()` to open DevTools. Default is `true`.
224225
* `nodeIntegration` Boolean (optional) - Whether node integration is enabled. Default

0 commit comments

Comments
 (0)