NSString *notificationType;
NSMutableDictionary *registrationDictionary;
id lastNotification;
- BOOL isInForeground;
intf_thread_t *interfaceThread;
}
registrationDictionary = nil;
interfaceThread = thread;
- // Assume we start in foreground
- isInForeground = YES;
-
- // Subscribe to notifications to determine if VLC is in foreground or not
- @autoreleasepool {
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(applicationActiveChange:)
- name:NSApplicationDidBecomeActiveNotification
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(applicationActiveChange:)
- name:NSApplicationDidResignActiveNotification
- object:nil];
- }
return self;
}
removeDeliveredNotification:(NSUserNotification *)lastNotification];
[lastNotification release];
}
- [[NSNotificationCenter defaultCenter] removeObserver:self];
}
#endif
andArtUrl:(const char *)url
{
@autoreleasepool {
+ // Do not notify if in foreground
+ if ([NSApplication sharedApplication].active)
+ return;
+
// Init Cover
NSData *coverImageData = nil;
NSImage *coverImage = nil;
} else {
// Without title, notification makes no sense, so return here
// title should never be empty, but better check than crash.
+ [coverImage release];
return;
}
if (artist)
return applicationName;
}
-- (void)applicationActiveChange:(NSNotification *)n {
- if (n.name == NSApplicationDidBecomeActiveNotification)
- isInForeground = YES;
- else if (n.name == NSApplicationDidResignActiveNotification)
- isInForeground = NO;
-}
-
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
- (void)userNotificationCenter:(NSUserNotificationCenter *)center
didActivateNotification:(NSUserNotification *)notification
{
+ // Skip to next song
if (notification.activationType == NSUserNotificationActivationTypeActionButtonClicked) {
playlist_Next(pl_Get(interfaceThread));
}
[notification retain];
lastNotification = notification;
}
-
-- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
- shouldPresentNotification:(NSUserNotification *)notification
-{
- // Show notifications regardless if App in foreground or background
- return YES;
-}
#endif
@end