diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index ffd1e9d705a9..fa4bffc9cc43 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -209,7 +209,7 @@ enum { #endif -@interface AtomNSWindow : EventDispatchingWindow { +@interface AtomNSWindow : EventDispatchingWindow { @private atom::NativeWindowMac* shell_; bool enable_larger_than_screen_; @@ -252,14 +252,6 @@ enum { return nil; } -- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar - makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier API_AVAILABLE(macosx(10.12.2)) { - if (touchBar && shell_->atom_touch_bar()) - return [shell_->atom_touch_bar() makeItemForIdentifier:identifier]; - else - return nil; -} - // NSWindow overrides. - (void)swipeWithEvent:(NSEvent *)event { @@ -1515,9 +1507,10 @@ void NativeWindowMac::SetTouchBar( if (![window_ respondsToSelector:@selector(touchBar)]) return; - atom_touch_bar_.reset([[AtomTouchBar alloc] initWithDelegate:window_.get() - window:this - settings:items]); + atom_touch_bar_.reset([[AtomTouchBar alloc] + initWithDelegate:window_delegate_.get() + window:this + settings:items]); [window_ setTouchBar:nil]; } diff --git a/atom/browser/ui/cocoa/atom_ns_window_delegate.h b/atom/browser/ui/cocoa/atom_ns_window_delegate.h index 2cd4171b14ad..62bcbee35723 100644 --- a/atom/browser/ui/cocoa/atom_ns_window_delegate.h +++ b/atom/browser/ui/cocoa/atom_ns_window_delegate.h @@ -11,7 +11,8 @@ namespace atom { class NativeWindowMac; } -@interface AtomNSWindowDelegate : NSObject { +@interface AtomNSWindowDelegate : NSObject { @private atom::NativeWindowMac* shell_; bool is_zooming_; diff --git a/atom/browser/ui/cocoa/atom_ns_window_delegate.mm b/atom/browser/ui/cocoa/atom_ns_window_delegate.mm index 090e8db6e2cb..0b71c6af79a5 100644 --- a/atom/browser/ui/cocoa/atom_ns_window_delegate.mm +++ b/atom/browser/ui/cocoa/atom_ns_window_delegate.mm @@ -6,6 +6,7 @@ #include "atom/browser/browser.h" #include "atom/browser/native_window_mac.h" +#include "atom/browser/ui/cocoa/atom_touch_bar.h" #include "base/mac/mac_util.h" @implementation AtomNSWindowDelegate @@ -19,6 +20,8 @@ return self; } +#pragma mark - NSWindowDelegate + - (void)windowDidChangeOcclusionState:(NSNotification *)notification { // notification.object is the window that changed its state. // It's safe to use self.window instead if you don't assign one delegate to many windows @@ -246,4 +249,14 @@ atom::Browser::Get()->NewWindowForTab(); } +#pragma mark - NSTouchBarDelegate + +- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar + makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier API_AVAILABLE(macosx(10.12.2)) { + if (touchBar && shell_->atom_touch_bar()) + return [shell_->atom_touch_bar() makeItemForIdentifier:identifier]; + else + return nil; +} + @end