From 985d35fc1cab1fad5bad537592166f7311d86fe4 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 26 Sep 2018 16:00:57 -0700 Subject: [PATCH] fix: update deprecated NSWindow masks (#14760) --- atom/browser/native_browser_view_mac.mm | 4 +-- atom/browser/native_window_mac.mm | 36 ++++++++++--------- .../ui/cocoa/atom_ns_window_delegate.mm | 5 ++- .../mac/bry_inspectable_web_contents_view.mm | 6 ++-- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/atom/browser/native_browser_view_mac.mm b/atom/browser/native_browser_view_mac.mm index 0416e26e89..300e9b1050 100644 --- a/atom/browser/native_browser_view_mac.mm +++ b/atom/browser/native_browser_view_mac.mm @@ -55,7 +55,7 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask = return; } - if (self.window.styleMask & NSFullScreenWindowMask) { + if (self.window.styleMask & NSWindowStyleMaskFullScreen) { return; } @@ -67,7 +67,7 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask = return; } - if (self.window.styleMask & NSFullScreenWindowMask) { + if (self.window.styleMask & NSWindowStyleMaskFullScreen) { return; } diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 54dfba66fc..629bafc3c9 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -70,13 +70,15 @@ - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; - NSButton* close_button = [NSWindow standardWindowButton:NSWindowCloseButton - forStyleMask:NSTitledWindowMask]; + NSButton* close_button = + [NSWindow standardWindowButton:NSWindowCloseButton + forStyleMask:NSWindowStyleMaskTitled]; NSButton* miniaturize_button = [NSWindow standardWindowButton:NSWindowMiniaturizeButton - forStyleMask:NSTitledWindowMask]; - NSButton* zoom_button = [NSWindow standardWindowButton:NSWindowZoomButton - forStyleMask:NSTitledWindowMask]; + forStyleMask:NSWindowStyleMaskTitled]; + NSButton* zoom_button = + [NSWindow standardWindowButton:NSWindowZoomButton + forStyleMask:NSWindowStyleMaskTitled]; CGFloat x = 0; const CGFloat space_between = 20; @@ -319,18 +321,18 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options, useStandardWindow = false; } - NSUInteger styleMask = NSTitledWindowMask; + NSUInteger styleMask = NSWindowStyleMaskTitled; if (@available(macOS 10.10, *)) { if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER && (!useStandardWindow || transparent() || !has_frame())) { - styleMask = NSFullSizeContentViewWindowMask; + styleMask = NSWindowStyleMaskFullSizeContentView; } } if (minimizable) { styleMask |= NSMiniaturizableWindowMask; } if (closable) { - styleMask |= NSClosableWindowMask; + styleMask |= NSWindowStyleMaskClosable; } if (title_bar_style_ != NORMAL) { // The window without titlebar is treated the same with frameless window. @@ -610,7 +612,7 @@ void NativeWindowMac::Unmaximize() { } bool NativeWindowMac::IsMaximized() { - if (([window_ styleMask] & NSResizableWindowMask) != 0) { + if (([window_ styleMask] & NSWindowStyleMaskResizable) != 0) { return [window_ isZoomed]; } else { NSRect rectScreen = [[NSScreen mainScreen] visibleFrame]; @@ -651,7 +653,7 @@ void NativeWindowMac::SetFullScreen(bool fullscreen) { } bool NativeWindowMac::IsFullscreen() const { - return [window_ styleMask] & NSFullScreenWindowMask; + return [window_ styleMask] & NSWindowStyleMaskFullScreen; } void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) { @@ -688,7 +690,7 @@ bool NativeWindowMac::IsNormal() { gfx::Rect NativeWindowMac::GetNormalBounds() { if (IsNormal()) { - return GetBounds(); + return GetBounds(); } NSRect frame = original_frame_; gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame)); @@ -730,11 +732,11 @@ void NativeWindowMac::MoveTop() { } void NativeWindowMac::SetResizable(bool resizable) { - SetStyleMask(resizable, NSResizableWindowMask); + SetStyleMask(resizable, NSWindowStyleMaskResizable); } bool NativeWindowMac::IsResizable() { - return [window_ styleMask] & NSResizableWindowMask; + return [window_ styleMask] & NSWindowStyleMaskResizable; } void NativeWindowMac::SetAspectRatio(double aspect_ratio, @@ -800,11 +802,11 @@ bool NativeWindowMac::IsFullScreenable() { } void NativeWindowMac::SetClosable(bool closable) { - SetStyleMask(closable, NSClosableWindowMask); + SetStyleMask(closable, NSWindowStyleMaskClosable); } bool NativeWindowMac::IsClosable() { - return [window_ styleMask] & NSClosableWindowMask; + return [window_ styleMask] & NSWindowStyleMaskClosable; } void NativeWindowMac::SetAlwaysOnTop(bool top, @@ -911,7 +913,7 @@ void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) { if (!fullscreen_window_title()) { // Hide the titlebar - SetStyleMask(false, NSTitledWindowMask); + SetStyleMask(false, NSWindowStyleMaskTitled); // Resize the window to accomodate the _entire_ screen size fullscreenFrame.size.height -= @@ -936,7 +938,7 @@ void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) { if (!fullscreen_window_title()) { // Restore the titlebar - SetStyleMask(true, NSTitledWindowMask); + SetStyleMask(true, NSWindowStyleMaskTitled); } // Restore window controls visibility state diff --git a/atom/browser/ui/cocoa/atom_ns_window_delegate.mm b/atom/browser/ui/cocoa/atom_ns_window_delegate.mm index 72739bec4c..2b588a59be 100644 --- a/atom/browser/ui/cocoa/atom_ns_window_delegate.mm +++ b/atom/browser/ui/cocoa/atom_ns_window_delegate.mm @@ -213,7 +213,7 @@ // Set window style to hide the toolbar, otherwise the toolbar will show // in fullscreen mode. [window setTitlebarAppearsTransparent:NO]; - shell_->SetStyleMask(true, NSFullSizeContentViewWindowMask); + shell_->SetStyleMask(true, NSWindowStyleMaskFullSizeContentView); } } } @@ -230,8 +230,7 @@ // Turn off the style for toolbar. if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { - shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask); - [window setTitlebarAppearsTransparent:YES]; + shell_->SetStyleMask(false, NSWindowStyleMaskFullSizeContentView); } } } diff --git a/brightray/browser/mac/bry_inspectable_web_contents_view.mm b/brightray/browser/mac/bry_inspectable_web_contents_view.mm index 1a9139e7af..176339fb78 100644 --- a/brightray/browser/mac/bry_inspectable_web_contents_view.mm +++ b/brightray/browser/mac/bry_inspectable_web_contents_view.mm @@ -136,10 +136,10 @@ inspectable_web_contents->GetDevToolsWebContents(); auto devToolsView = devToolsWebContents->GetNativeView(); - auto styleMask = NSTitledWindowMask | NSClosableWindowMask | - NSMiniaturizableWindowMask | NSResizableWindowMask | + auto styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | + NSMiniaturizableWindowMask | NSWindowStyleMaskResizable | NSTexturedBackgroundWindowMask | - NSUnifiedTitleAndToolbarWindowMask; + NSWindowStyleMaskUnifiedTitleAndToolbar; devtools_window_.reset([[EventDispatchingWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600) styleMask:styleMask