Skip to content

Commit

Permalink
Fix menu flickering on macOS 10.15
Browse files Browse the repository at this point in the history
  • Loading branch information
relikd committed Oct 25, 2019
1 parent 8d2e4e4 commit 9af1918
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 24 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ and this project does adhere to [Semantic Versioning](https://semver.org/spec/v2

## [Unreleased]
### Fixed
- Preferences could not be opened on Catalina
- Preferences could not be opened on macOS 10.15
- Menu flickering resulting in a hang on macOS 10.15

## [1.0.1] - 2019-10-04
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion baRSS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>14438</string>
<string>14465</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.news</string>
<key>LSMinimumSystemVersion</key>
Expand Down
31 changes: 16 additions & 15 deletions baRSS/Status Bar Menu/BarMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ - (void)menuNeedsUpdate:(NSMenu*)menu {
}
}

/// Get rid of everything that is not needed.
- (void)menuDidClose:(NSMenu*)menu {
[menu cleanup];
}

/// Generate items for @c FeedGroup menu.
- (void)setFeedGroups:(NSArray<FeedGroup*>*)sortedList forMenu:(NSMenu*)menu {
[menu insertDefaultHeader];
Expand Down Expand Up @@ -125,17 +120,21 @@ - (void)setArticles:(NSArray<FeedArticle*>*)sortedList forMenu:(NSMenu*)menu {
Fetch @c Feed from core data and find deepest visible @c NSMenuItem.
@warning @c item and @c feed will often mismatch.
*/
- (void)updateFeedMenuItem:(NSManagedObjectID*)oid withBlock:(void(^)(Feed *feed, NSMenuItem *item))block {
Feed *feed = [[StoreCoordinator getMainContext] objectWithID:oid];
if ([feed isKindOfClass:[Feed class]]) {
NSMenuItem *item = [self.statusItem.mainMenu deepestItemWithPath:feed.indexPath];
if (item) block(feed, item);
}
- (BOOL)findDeepest:(NSManagedObjectID*)oid feed:(Feed*__autoreleasing*)feed menuItem:(NSMenuItem*__autoreleasing*)item {
Feed *f = [[StoreCoordinator getMainContext] objectWithID:oid];
if (![f isKindOfClass:[Feed class]]) return NO;
NSMenuItem *mi = [self.statusItem.mainMenu deepestItemWithPath:f.indexPath];
if (!mi) return NO;
*feed = f;
*item = mi;
return YES;
}

/// Callback method fired when feed has been updated in the background.
- (void)articlesUpdated:(NSNotification*)notify {
[self updateFeedMenuItem:notify.object withBlock:^(Feed *feed, NSMenuItem *item) {
Feed *feed;
NSMenuItem *item;
if ([self findDeepest:notify.object feed:&feed menuItem:&item]) {
// 1. update in-memory unread count
UnreadTotal *updated = [UnreadTotal new];
updated.total = feed.articles.count;
Expand All @@ -160,15 +159,17 @@ - (void)articlesUpdated:(NSNotification*)notify {
[item setTitleCount:uct.unread];
item = item.parentItem;
}
}];
}
}

/// Callback method fired when feed icon has changed.
- (void)feedIconUpdated:(NSNotification*)notify {
[self updateFeedMenuItem:notify.object withBlock:^(Feed *feed, NSMenuItem *item) {
Feed *feed;
NSMenuItem *item;
if ([self findDeepest:notify.object feed:&feed menuItem:&item]) {
if (item.submenu.isFeedMenu)
item.image = [feed iconImage16];
}];
}
}

@end
1 change: 0 additions & 1 deletion baRSS/Status Bar Menu/NSMenu+Ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
- (NSMenuItem*)insertFeedGroupItem:(FeedGroup*)fg;
- (void)insertDefaultHeader;
// Update menu
- (void)cleanup;
- (void)setHeaderHasUnread:(BOOL)hasUnread hasRead:(BOOL)hasRead;
- (NSMenuItem*)deepestItemWithPath:(nonnull NSString*)path;
@end
Expand Down
6 changes: 0 additions & 6 deletions baRSS/Status Bar Menu/NSMenu+Ext.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ - (void)insertDefaultHeader {

#pragma mark - Update Menu

/// Replace this menu with a clean @c NSMenu. Copy old @c title and @c delegate to new menu. @b Won't work without supermenu!
- (void)cleanup {
NSMenu *m = [[NSMenu alloc] initWithTitle:self.title];
m.delegate = self.delegate;
self.parentItem.submenu = m;
}

/// Loop over default header and enable 'OpenAllUnread' and 'TagMarkAllRead' based on unread count.
- (void)setHeaderHasUnread:(BOOL)hasUnread hasRead:(BOOL)hasRead {
Expand Down

0 comments on commit 9af1918

Please sign in to comment.