From 14ef5c595779c6929cf487d0ebd4bba028db94c4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Feb 2017 13:50:16 -0800 Subject: [PATCH] Reset helper when makeTouchBar is called --- atom/browser/native_window_mac.mm | 13 ++++--------- atom/browser/ui/cocoa/atom_touch_bar.mm | 8 ++++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index c4f127459d1..6cd42bc64ac 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -352,9 +352,8 @@ bool ScopedDisableResize::disable_resize_ = false; - (void)setShell:(atom::NativeWindowMac*)shell; - (void)setEnableLargerThanScreen:(bool)enable; - (void)enableWindowButtonsOffset; -- (void)reloadTouchBar; -- (void)refreshTouchBarItem:(mate::Arguments*)args; - (void)resetTouchBar; +- (void)refreshTouchBarItem:(mate::Arguments*)args; @end @interface AtomNSWindow () @@ -365,7 +364,6 @@ bool ScopedDisableResize::disable_resize_ = false; - (void)setShell:(atom::NativeWindowMac*)shell { shell_ = shell; - touch_bar_.reset([[AtomTouchBar alloc] initWithDelegate:self window:shell]); } - (void)setEnableLargerThanScreen:(bool)enable { @@ -376,16 +374,12 @@ bool ScopedDisableResize::disable_resize_ = false; self.touchBar = nil; } -- (void)reloadTouchBar { - [touch_bar_ clear]; - self.touchBar = nil; -} - - (void)refreshTouchBarItem:(mate::Arguments*)args { [touch_bar_ refreshTouchBarItem:args]; } - (NSTouchBar*)makeTouchBar { + touch_bar_.reset([[AtomTouchBar alloc] initWithDelegate:self window:shell_]); return [touch_bar_ makeTouchBarFromItemOptions:shell_->GetTouchBarItems()]; } @@ -1377,6 +1371,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) { } void NativeWindowMac::DestroyTouchBar() { + touch_bar_items_.clear(); [window_ resetTouchBar]; } @@ -1384,7 +1379,7 @@ void NativeWindowMac::SetTouchBar(mate::Arguments* args) { std::vector items; if (args->GetNext(&items)) { touch_bar_items_ = items; - [window_ reloadTouchBar]; + [window_ resetTouchBar]; } } diff --git a/atom/browser/ui/cocoa/atom_touch_bar.mm b/atom/browser/ui/cocoa/atom_touch_bar.mm index 4865e400c8e..f24baad10aa 100644 --- a/atom/browser/ui/cocoa/atom_touch_bar.mm +++ b/atom/browser/ui/cocoa/atom_touch_bar.mm @@ -161,7 +161,7 @@ static NSTouchBarItemIdentifier SliderIdentifier = @"com.electron.touchbar.slide } - (NSTouchBarItem*)makeButtonForID:(NSString*)id - withIdentifier:(NSString*)identifier { + withIdentifier:(NSString*)identifier { std::string s_id([id UTF8String]); if (![self hasItemWithID:s_id]) return nil; @@ -213,7 +213,7 @@ static NSTouchBarItemIdentifier SliderIdentifier = @"com.electron.touchbar.slide } - (NSTouchBarItem*)makeLabelForID:(NSString*)id - withIdentifier:(NSString*)identifier { + withIdentifier:(NSString*)identifier { std::string s_id([id UTF8String]); if (![self hasItemWithID:s_id]) return nil; @@ -260,7 +260,7 @@ static NSTouchBarItemIdentifier SliderIdentifier = @"com.electron.touchbar.slide } - (NSTouchBarItem*)makeSliderForID:(NSString*)id - withIdentifier:(NSString*)identifier { + withIdentifier:(NSString*)identifier { std::string s_id([id UTF8String]); if (![self hasItemWithID:s_id]) return nil; @@ -296,7 +296,7 @@ static NSTouchBarItemIdentifier SliderIdentifier = @"com.electron.touchbar.slide } - (NSTouchBarItem*)makePopoverForID:(NSString*)id - withIdentifier:(NSString*)identifier { + withIdentifier:(NSString*)identifier { std::string s_id([id UTF8String]); if (![self hasItemWithID:s_id]) return nil;