fix: update deprecated NSWindow masks (#14760)

This commit is contained in:
Shelley Vohr 2018-09-26 16:00:57 -07:00 committed by GitHub
parent be2c27d5b8
commit 985d35fc1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 25 deletions

View file

@ -55,7 +55,7 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
return; return;
} }
if (self.window.styleMask & NSFullScreenWindowMask) { if (self.window.styleMask & NSWindowStyleMaskFullScreen) {
return; return;
} }
@ -67,7 +67,7 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
return; return;
} }
if (self.window.styleMask & NSFullScreenWindowMask) { if (self.window.styleMask & NSWindowStyleMaskFullScreen) {
return; return;
} }

View file

@ -70,13 +70,15 @@
- (id)initWithFrame:(NSRect)frame { - (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
NSButton* close_button = [NSWindow standardWindowButton:NSWindowCloseButton NSButton* close_button =
forStyleMask:NSTitledWindowMask]; [NSWindow standardWindowButton:NSWindowCloseButton
forStyleMask:NSWindowStyleMaskTitled];
NSButton* miniaturize_button = NSButton* miniaturize_button =
[NSWindow standardWindowButton:NSWindowMiniaturizeButton [NSWindow standardWindowButton:NSWindowMiniaturizeButton
forStyleMask:NSTitledWindowMask]; forStyleMask:NSWindowStyleMaskTitled];
NSButton* zoom_button = [NSWindow standardWindowButton:NSWindowZoomButton NSButton* zoom_button =
forStyleMask:NSTitledWindowMask]; [NSWindow standardWindowButton:NSWindowZoomButton
forStyleMask:NSWindowStyleMaskTitled];
CGFloat x = 0; CGFloat x = 0;
const CGFloat space_between = 20; const CGFloat space_between = 20;
@ -319,18 +321,18 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
useStandardWindow = false; useStandardWindow = false;
} }
NSUInteger styleMask = NSTitledWindowMask; NSUInteger styleMask = NSWindowStyleMaskTitled;
if (@available(macOS 10.10, *)) { if (@available(macOS 10.10, *)) {
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER && if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
(!useStandardWindow || transparent() || !has_frame())) { (!useStandardWindow || transparent() || !has_frame())) {
styleMask = NSFullSizeContentViewWindowMask; styleMask = NSWindowStyleMaskFullSizeContentView;
} }
} }
if (minimizable) { if (minimizable) {
styleMask |= NSMiniaturizableWindowMask; styleMask |= NSMiniaturizableWindowMask;
} }
if (closable) { if (closable) {
styleMask |= NSClosableWindowMask; styleMask |= NSWindowStyleMaskClosable;
} }
if (title_bar_style_ != NORMAL) { if (title_bar_style_ != NORMAL) {
// The window without titlebar is treated the same with frameless window. // The window without titlebar is treated the same with frameless window.
@ -610,7 +612,7 @@ void NativeWindowMac::Unmaximize() {
} }
bool NativeWindowMac::IsMaximized() { bool NativeWindowMac::IsMaximized() {
if (([window_ styleMask] & NSResizableWindowMask) != 0) { if (([window_ styleMask] & NSWindowStyleMaskResizable) != 0) {
return [window_ isZoomed]; return [window_ isZoomed];
} else { } else {
NSRect rectScreen = [[NSScreen mainScreen] visibleFrame]; NSRect rectScreen = [[NSScreen mainScreen] visibleFrame];
@ -651,7 +653,7 @@ void NativeWindowMac::SetFullScreen(bool fullscreen) {
} }
bool NativeWindowMac::IsFullscreen() const { bool NativeWindowMac::IsFullscreen() const {
return [window_ styleMask] & NSFullScreenWindowMask; return [window_ styleMask] & NSWindowStyleMaskFullScreen;
} }
void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) { void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) {
@ -688,7 +690,7 @@ bool NativeWindowMac::IsNormal() {
gfx::Rect NativeWindowMac::GetNormalBounds() { gfx::Rect NativeWindowMac::GetNormalBounds() {
if (IsNormal()) { if (IsNormal()) {
return GetBounds(); return GetBounds();
} }
NSRect frame = original_frame_; NSRect frame = original_frame_;
gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame)); gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
@ -730,11 +732,11 @@ void NativeWindowMac::MoveTop() {
} }
void NativeWindowMac::SetResizable(bool resizable) { void NativeWindowMac::SetResizable(bool resizable) {
SetStyleMask(resizable, NSResizableWindowMask); SetStyleMask(resizable, NSWindowStyleMaskResizable);
} }
bool NativeWindowMac::IsResizable() { bool NativeWindowMac::IsResizable() {
return [window_ styleMask] & NSResizableWindowMask; return [window_ styleMask] & NSWindowStyleMaskResizable;
} }
void NativeWindowMac::SetAspectRatio(double aspect_ratio, void NativeWindowMac::SetAspectRatio(double aspect_ratio,
@ -800,11 +802,11 @@ bool NativeWindowMac::IsFullScreenable() {
} }
void NativeWindowMac::SetClosable(bool closable) { void NativeWindowMac::SetClosable(bool closable) {
SetStyleMask(closable, NSClosableWindowMask); SetStyleMask(closable, NSWindowStyleMaskClosable);
} }
bool NativeWindowMac::IsClosable() { bool NativeWindowMac::IsClosable() {
return [window_ styleMask] & NSClosableWindowMask; return [window_ styleMask] & NSWindowStyleMaskClosable;
} }
void NativeWindowMac::SetAlwaysOnTop(bool top, void NativeWindowMac::SetAlwaysOnTop(bool top,
@ -911,7 +913,7 @@ void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
if (!fullscreen_window_title()) { if (!fullscreen_window_title()) {
// Hide the titlebar // Hide the titlebar
SetStyleMask(false, NSTitledWindowMask); SetStyleMask(false, NSWindowStyleMaskTitled);
// Resize the window to accomodate the _entire_ screen size // Resize the window to accomodate the _entire_ screen size
fullscreenFrame.size.height -= fullscreenFrame.size.height -=
@ -936,7 +938,7 @@ void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
if (!fullscreen_window_title()) { if (!fullscreen_window_title()) {
// Restore the titlebar // Restore the titlebar
SetStyleMask(true, NSTitledWindowMask); SetStyleMask(true, NSWindowStyleMaskTitled);
} }
// Restore window controls visibility state // Restore window controls visibility state

View file

@ -213,7 +213,7 @@
// Set window style to hide the toolbar, otherwise the toolbar will show // Set window style to hide the toolbar, otherwise the toolbar will show
// in fullscreen mode. // in fullscreen mode.
[window setTitlebarAppearsTransparent:NO]; [window setTitlebarAppearsTransparent:NO];
shell_->SetStyleMask(true, NSFullSizeContentViewWindowMask); shell_->SetStyleMask(true, NSWindowStyleMaskFullSizeContentView);
} }
} }
} }
@ -230,8 +230,7 @@
// Turn off the style for toolbar. // Turn off the style for toolbar.
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask); shell_->SetStyleMask(false, NSWindowStyleMaskFullSizeContentView);
[window setTitlebarAppearsTransparent:YES];
} }
} }
} }

View file

@ -136,10 +136,10 @@
inspectable_web_contents->GetDevToolsWebContents(); inspectable_web_contents->GetDevToolsWebContents();
auto devToolsView = devToolsWebContents->GetNativeView(); auto devToolsView = devToolsWebContents->GetNativeView();
auto styleMask = NSTitledWindowMask | NSClosableWindowMask | auto styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
NSMiniaturizableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask | NSWindowStyleMaskResizable |
NSTexturedBackgroundWindowMask | NSTexturedBackgroundWindowMask |
NSUnifiedTitleAndToolbarWindowMask; NSWindowStyleMaskUnifiedTitleAndToolbar;
devtools_window_.reset([[EventDispatchingWindow alloc] devtools_window_.reset([[EventDispatchingWindow alloc]
initWithContentRect:NSMakeRect(0, 0, 800, 600) initWithContentRect:NSMakeRect(0, 0, 800, 600)
styleMask:styleMask styleMask:styleMask