Fix fullscreenable on EL Capitan

This commit is contained in:
Cheng Zhao 2016-01-22 23:51:52 -08:00
parent 5372b6cd91
commit ae7e96f181

View file

@ -375,9 +375,6 @@ NativeWindowMac::NativeWindowMac(
bool maximizable = true; bool maximizable = true;
options.Get(options::kMaximizable, &maximizable); options.Get(options::kMaximizable, &maximizable);
bool fullscreenable = true;
options.Get(options::kFullScreenable, &fullscreenable);
bool closable = true; bool closable = true;
options.Get(options::kClosable, &closable); options.Get(options::kClosable, &closable);
@ -496,17 +493,15 @@ NativeWindowMac::NativeWindowMac(
options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor); options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor);
[window_ setDisableAutoHideCursor:disableAutoHideCursor]; [window_ setDisableAutoHideCursor:disableAutoHideCursor];
// Disable fullscreen button when 'fullscreen' is specified to false. // Disable fullscreen button when 'fullscreenable' is false or 'fullscreen'
// is specified to false.
bool fullscreenable = true;
options.Get(options::kFullScreenable, &fullscreenable);
bool fullscreen = false; bool fullscreen = false;
options.Get(options::kFullscreen, &fullscreen); if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen)
fullscreenable = false;
if (fullscreenable) { if (!fullscreenable) {
SetFullScreenable(true); SetFullScreenable(false);
} else if (base::mac::IsOSElCapitanOrLater()) {
// On EL Capitan this flag is required to hide fullscreen button.
NSUInteger collectionBehavior = [window_ collectionBehavior];
collectionBehavior |= NSWindowCollectionBehaviorFullScreenAuxiliary;
[window_ setCollectionBehavior:collectionBehavior];
} }
// Disable zoom button if window is not resizable // Disable zoom button if window is not resizable
@ -717,6 +712,8 @@ void NativeWindowMac::SetFullScreenable(bool fullscreenable) {
collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary; collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
} else { } else {
collectionBehavior &= (~NSWindowCollectionBehaviorFullScreenPrimary); collectionBehavior &= (~NSWindowCollectionBehaviorFullScreenPrimary);
// On EL Capitan this flag is required to hide fullscreen button.
collectionBehavior |= NSWindowCollectionBehaviorFullScreenAuxiliary;
} }
[window_ setCollectionBehavior:collectionBehavior]; [window_ setCollectionBehavior:collectionBehavior];
if (!maximizable) { if (!maximizable) {