Browse Source

macosx: SPMediaKeyTap: Always use default bundle identifiers list

Do not read the list from the user defaults, it is unlikely anyone
ever has to customize this.
pull/73/head
Marvin Scholz 8 years ago
parent
commit
4221ab456b
  1. 3
      modules/gui/macosx/SPMediaKeyTap.h
  2. 84
      modules/gui/macosx/SPMediaKeyTap.m
  3. 8
      modules/gui/macosx/VLCCoreInteraction.m

3
modules/gui/macosx/SPMediaKeyTap.h

@ -31,8 +31,6 @@
@interface SPMediaKeyTap : NSObject
+ (NSArray*)defaultMediaKeyUserBundleIdentifiers;
- (id)initWithDelegate:(id)delegate;
+ (BOOL)usesGlobalMediaKeyTap;
@ -49,7 +47,6 @@
extern "C" {
#endif
extern NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey;
extern NSString *kIgnoreMediaKeysDefaultsKey;
#ifdef __cplusplus

84
modules/gui/macosx/SPMediaKeyTap.m

@ -25,6 +25,8 @@
#import "SPMediaKeyTap.h"
#import "SPInvocationGrabbing.h"
NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys";
@interface SPMediaKeyTap () {
EventHandlerRef _app_switching_ref;
EventHandlerRef _app_terminating_ref;
@ -162,42 +164,47 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
#endif
}
+ (NSArray*)defaultMediaKeyUserBundleIdentifiers
+ (NSArray*)mediaKeyUserBundleIdentifiers
{
return [NSArray arrayWithObjects:
static NSArray *bundleIdentifiers;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
bundleIdentifiers = @[
[[NSBundle mainBundle] bundleIdentifier], // your app
@"com.spotify.client",
@"com.apple.iTunes",
@"com.apple.QuickTimePlayerX",
@"com.apple.quicktimeplayer",
@"com.apple.iWork.Keynote",
@"com.apple.iPhoto",
@"org.videolan.vlc",
@"com.apple.Aperture",
@"com.plexsquared.Plex",
@"com.soundcloud.desktop",
@"org.niltsh.MPlayerX",
@"com.ilabs.PandorasHelper",
@"com.mahasoftware.pandabar",
@"com.bitcartel.pandorajam",
@"org.clementine-player.clementine",
@"fm.last.Last.fm",
@"fm.last.Scrobbler",
@"com.beatport.BeatportPro",
@"com.Timenut.SongKey",
@"com.macromedia.fireworks", // the tap messes up their mouse input
@"at.justp.Theremin",
@"ru.ya.themblsha.YandexMusic",
@"com.jriver.MediaCenter18",
@"com.jriver.MediaCenter19",
@"com.jriver.MediaCenter20",
@"co.rackit.mate",
@"com.ttitt.b-music",
@"com.beardedspice.BeardedSpice",
@"com.plug.Plug",
@"com.netease.163music",
nil
];
@"com.spotify.client",
@"com.apple.iTunes",
@"com.apple.QuickTimePlayerX",
@"com.apple.quicktimeplayer",
@"com.apple.iWork.Keynote",
@"com.apple.iPhoto",
@"org.videolan.vlc",
@"com.apple.Aperture",
@"com.plexsquared.Plex",
@"com.soundcloud.desktop",
@"org.niltsh.MPlayerX",
@"com.ilabs.PandorasHelper",
@"com.mahasoftware.pandabar",
@"com.bitcartel.pandorajam",
@"org.clementine-player.clementine",
@"fm.last.Last.fm",
@"fm.last.Scrobbler",
@"com.beatport.BeatportPro",
@"com.Timenut.SongKey",
@"com.macromedia.fireworks", // the tap messes up their mouse input
@"at.justp.Theremin",
@"ru.ya.themblsha.YandexMusic",
@"com.jriver.MediaCenter18",
@"com.jriver.MediaCenter19",
@"com.jriver.MediaCenter20",
@"co.rackit.mate",
@"com.ttitt.b-music",
@"com.beardedspice.BeardedSpice",
@"com.plug.Plug",
@"com.netease.163music",
];
});
return bundleIdentifiers;
}
@ -295,11 +302,6 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
#pragma mark Task switching callbacks
NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey = @"SPApplicationsNeedingMediaKeys";
NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys";
- (void)mediaKeyAppListChanged
{
if([_mediaKeyAppList count] == 0) return;
@ -335,8 +337,8 @@ NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys";
);
NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey];
NSArray *whitelistIdentifiers = [[NSUserDefaults standardUserDefaults] arrayForKey:kMediaKeyUsingBundleIdentifiersDefaultsKey];
if(![whitelistIdentifiers containsObject:bundleIdentifier]) return;
if (![[SPMediaKeyTap mediaKeyUserBundleIdentifiers] containsObject:bundleIdentifier])
return;
[_mediaKeyAppList removeObject:psnv];
[_mediaKeyAppList insertObject:psnv atIndex:0];

8
modules/gui/macosx/VLCCoreInteraction.m

@ -103,11 +103,11 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
b_mediaKeySupport = var_InheritBool(p_intf, "macosx-mediakeys");
if (b_mediaKeySupport) {
_mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
[SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers], kMediaKeyUsingBundleIdentifiersDefaultsKey,
nil]];
}
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name:VLCMediaKeySupportSettingChangedNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(coreChangedMediaKeySupportSetting:)
name:VLCMediaKeySupportSettingChangedNotification
object:nil];
/* init Apple Remote support */
_remote = [[AppleRemote alloc] init];

Loading…
Cancel
Save