diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index f64b0408274..9a4ae5850dc 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -853,7 +853,7 @@ void Window::RefreshTouchBarItem(const std::string& item_id) { window_->RefreshTouchBarItem(item_id); } -void Window::SetEscapeTouchBarItem(const mate::PersistentDictionary item) { +void Window::SetEscapeTouchBarItem(const mate::PersistentDictionary& item) { window_->SetEscapeTouchBarItem(item); } diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index c7b6a37265b..24afec354df 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -208,7 +208,7 @@ class Window : public mate::TrackableObject, void SetVibrancy(mate::Arguments* args); void SetTouchBar(const std::vector& items); void RefreshTouchBarItem(const std::string& item_id); - void SetEscapeTouchBarItem(const mate::PersistentDictionary item); + void SetEscapeTouchBarItem(const mate::PersistentDictionary& item); v8::Local WebContents(v8::Isolate* isolate); diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 4866e4294ca..413c756cdc3 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -347,7 +347,7 @@ void NativeWindow::SetTouchBar( void NativeWindow::RefreshTouchBarItem(const std::string& item_id) { } -void NativeWindow::SetEscapeTouchBarItem(const mate::PersistentDictionary item) { +void NativeWindow::SetEscapeTouchBarItem(const mate::PersistentDictionary& item) { } void NativeWindow::FocusOnWebView() { diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 3de57895e52..227e28c1e46 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -174,7 +174,7 @@ class NativeWindow : public base::SupportsUserData, virtual void SetTouchBar( const std::vector& items); virtual void RefreshTouchBarItem(const std::string& item_id); - virtual void SetEscapeTouchBarItem(const mate::PersistentDictionary item); + virtual void SetEscapeTouchBarItem(const mate::PersistentDictionary& item); // Webview APIs. virtual void FocusOnWebView(); diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 80ae8895aa1..a535cdb4bef 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -103,7 +103,7 @@ class NativeWindowMac : public NativeWindow, void SetTouchBar( const std::vector& items) override; void RefreshTouchBarItem(const std::string& item_id) override; - void SetEscapeTouchBarItem(const mate::PersistentDictionary item) override; + void SetEscapeTouchBarItem(const mate::PersistentDictionary& item) override; // content::RenderWidgetHost::InputEventObserver: void OnInputEvent(const blink::WebInputEvent& event) override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 7cbb8e2dffd..438bab6e5af 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -411,7 +411,7 @@ enum { } -(void)setEscapeTouchBarItem:(mate::PersistentDictionary)item { - if (self.touchBar && atom_touch_bar_) + if (atom_touch_bar_ && self.touchBar) [atom_touch_bar_ setEscapeTouchBarItem:item forTouchBar:self.touchBar]; } @@ -1422,7 +1422,7 @@ void NativeWindowMac::RefreshTouchBarItem(const std::string& item_id) { [window_ refreshTouchBarItem:item_id]; } -void NativeWindowMac::SetEscapeTouchBarItem(const mate::PersistentDictionary item) { +void NativeWindowMac::SetEscapeTouchBarItem(const mate::PersistentDictionary& item) { [window_ setEscapeTouchBarItem:item]; } diff --git a/atom/browser/ui/cocoa/atom_touch_bar.h b/atom/browser/ui/cocoa/atom_touch_bar.h index 8232e56f0a1..26662cf4850 100644 --- a/atom/browser/ui/cocoa/atom_touch_bar.h +++ b/atom/browser/ui/cocoa/atom_touch_bar.h @@ -31,8 +31,8 @@ - (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items; - (NSMutableArray*)identifiersFromSettings:(const std::vector&)settings; - (void)refreshTouchBarItem:(NSTouchBar*)touchBar id:(const std::string&)item_id; -- (void)addNonDefaultTouchBarItems:(std::vector)items; -- (void)setEscapeTouchBarItem:(mate::PersistentDictionary)item forTouchBar:(NSTouchBar*)touchBar; +- (void)addNonDefaultTouchBarItems:(const std::vector&)items; +- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item forTouchBar:(NSTouchBar*)touchBar; - (NSString*)idFromIdentifier:(NSString*)identifier withPrefix:(NSString*)prefix; diff --git a/atom/browser/ui/cocoa/atom_touch_bar.mm b/atom/browser/ui/cocoa/atom_touch_bar.mm index c12434467ee..3a8037b1c5f 100644 --- a/atom/browser/ui/cocoa/atom_touch_bar.mm +++ b/atom/browser/ui/cocoa/atom_touch_bar.mm @@ -147,11 +147,11 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item"; } } -- (void)addNonDefaultTouchBarItems:(std::vector)items { +- (void)addNonDefaultTouchBarItems:(const std::vector&)items { [self identifiersFromSettings:items]; } -- (void)setEscapeTouchBarItem:(mate::PersistentDictionary)item forTouchBar:(NSTouchBar*)touchBar { +- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item forTouchBar:(NSTouchBar*)touchBar { std::string type; std::string item_id; NSTouchBarItemIdentifier identifier = nil; diff --git a/docs/api/touch-bar.md b/docs/api/touch-bar.md index d5496b8b3f7..54315d79773 100644 --- a/docs/api/touch-bar.md +++ b/docs/api/touch-bar.md @@ -18,7 +18,7 @@ removed in future Electron releases. The following methods are available on instances of `TouchBar`: -#### `touchBar.replaceEscapeItem([touchBarItem])` +#### `touchBar.setEscapeItem([touchBarItem])` * `touchBarItem` (TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer) - (Optional) The touch bar item to replace the escape button with diff --git a/lib/browser/api/touch-bar.js b/lib/browser/api/touch-bar.js index 68cd6238616..1af18dfbe76 100644 --- a/lib/browser/api/touch-bar.js +++ b/lib/browser/api/touch-bar.js @@ -50,13 +50,13 @@ class TouchBar extends EventEmitter { }) } - replaceEscapeItem(item) { + setEscapeItem(item) { if (!item) item = {} Object.keys(this.windows).forEach((windowID) => { const window = this.windows[windowID] window._setEscapeTouchBarItem(item) }) - this._escape = item; + this._escape = item } _addToWindow (window) { @@ -90,7 +90,7 @@ class TouchBar extends EventEmitter { } window.once('closed', removeListeners) this.windowListeners[id] = removeListeners - this.windows[id] = window; + this.windows[id] = window window._setTouchBarItems(this.ordereredItems)