diff --git a/atom/browser/ui/cocoa/atom_touch_bar.mm b/atom/browser/ui/cocoa/atom_touch_bar.mm index 3a8037b1c5fe..a3e846df4871 100644 --- a/atom/browser/ui/cocoa/atom_touch_bar.mm +++ b/atom/browser/ui/cocoa/atom_touch_bar.mm @@ -113,19 +113,10 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item"; return nil; } - - (void)refreshTouchBarItem:(NSTouchBar*)touchBar - id:(const std::string&)item_id { - if (![self hasItemWithID:item_id]) return; - - mate::PersistentDictionary settings = settings_[item_id]; - std::string item_type; - settings.Get("type", &item_type); - - NSTouchBarItemIdentifier identifier = [self identifierFromID:item_id - type:item_type]; - if (!identifier) return; - + id:(NSTouchBarItemIdentifier)identifier + withType:(const std::string&)item_type + withSettings:(const mate::PersistentDictionary&)settings { NSTouchBarItem* item = [touchBar itemForIdentifier:identifier]; if (!item) return; @@ -166,6 +157,37 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item"; } } +- (void)refreshTouchBarItem:(NSTouchBar*)touchBar + id:(const std::string&)item_id { + if (![self hasItemWithID:item_id]) return; + + mate::PersistentDictionary settings = settings_[item_id]; + std::string item_type; + settings.Get("type", &item_type); + + auto identifier = [self identifierFromID:item_id type:item_type]; + if (!identifier) return; + + std::vector popover_ids; + settings.Get("_popover", &popover_ids); + for (auto& popover_id : popover_ids) { + auto popoverIdentifier = [self identifierFromID:popover_id type:"popover"]; + if (!popoverIdentifier) continue; + + NSPopoverTouchBarItem* popoverItem = + [touchBar itemForIdentifier:popoverIdentifier]; + [self refreshTouchBarItem:popoverItem.popoverTouchBar + id:identifier + withType:item_type + withSettings:settings]; + } + + [self refreshTouchBarItem:touchBar + id:identifier + withType:item_type + withSettings:settings]; +} + - (void)buttonAction:(id)sender { NSString* item_id = [NSString stringWithFormat:@"%ld", ((NSButton*)sender).tag]; window_->NotifyTouchBarItemInteraction([item_id UTF8String], diff --git a/lib/browser/api/touch-bar.js b/lib/browser/api/touch-bar.js index 1070398c75c9..1a9c3238a97f 100644 --- a/lib/browser/api/touch-bar.js +++ b/lib/browser/api/touch-bar.js @@ -223,6 +223,10 @@ TouchBar.TouchBarPopover = class TouchBarPopover extends TouchBarItem { if (!(this.child instanceof TouchBar)) { this.child = new TouchBar(this.child) } + this.child.ordereredItems.forEach((item) => { + item._popover = item._popover || [] + if (!item._popover.includes(this.id)) item._popover.push(this.id) + }) } }