Commit e822e3f9 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: make sure that we don't block media keys for iTunes in case the user...

macosx: make sure that we don't block media keys for iTunes in case the user doesn't want to use them within VLC

Changing this option requires a relaunch now, which is automatically offered when needed.

Fixes #5025
parent 167a895e
...@@ -439,14 +439,16 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -439,14 +439,16 @@ static VLCMain *_o_sharedMainInstance = nil;
if( !p_intf ) return; if( !p_intf ) return;
/* init media key support */ /* init media key support */
o_mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" ); b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
[o_mediaKeyController startWatchingMediaKeys]; if( b_mediaKeySupport )
[o_mediaKeyController setShouldInterceptMediaKeyEvents:b_mediaKeySupport]; {
o_mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
[o_mediaKeyController startWatchingMediaKeys];
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
[SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers], kMediaKeyUsingBundleIdentifiersDefaultsKey,
nil]];
}
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name: @"VLCMediaKeySupportSettingChanged" object: nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name: @"VLCMediaKeySupportSettingChanged" object: nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
[SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers], kMediaKeyUsingBundleIdentifiersDefaultsKey,
nil]];
[self _removeOldPreferences]; [self _removeOldPreferences];
...@@ -2030,7 +2032,30 @@ end: ...@@ -2030,7 +2032,30 @@ end:
- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
{ {
b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" ); b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
[o_mediaKeyController setShouldInterceptMediaKeyEvents:b_mediaKeySupport]; if (b_mediaKeySupport) {
if (!o_mediaKeyController)
o_mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
[o_mediaKeyController startWatchingMediaKeys];
}
else if (!b_mediaKeySupport && o_mediaKeyController)
{
int returnedValue = NSRunInformationalAlertPanel(_NS("Relaunch required"),
_NS("To make sure that VLC no longer listens to your media key events, it needs to be restarted."),
_NS("Relaunch VLC"), _NS("Ignore"), nil, nil);
if( returnedValue == NSOKButton )
{
/* Relaunch now */
const char * path = [[[NSBundle mainBundle] executablePath] UTF8String];
/* For some reason we need to fork(), not just execl(), which reports a ENOTSUP then. */
if(fork() != 0)
{
exit(0);
return;
}
execl(path, path, NULL);
}
}
} }
@end @end
......
...@@ -793,9 +793,6 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch ...@@ -793,9 +793,6 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
[[[VLCMain sharedInstance] appleRemoteController] startListening: [VLCMain sharedInstance]]; [[[VLCMain sharedInstance] appleRemoteController] startListening: [VLCMain sharedInstance]];
else else
[[[VLCMain sharedInstance] appleRemoteController] stopListening: [VLCMain sharedInstance]]; [[[VLCMain sharedInstance] appleRemoteController] stopListening: [VLCMain sharedInstance]];
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCMediaKeySupportSettingChanged"
object: nil
userInfo: nil];
b_intfSettingChanged = NO; b_intfSettingChanged = NO;
} }
...@@ -1151,6 +1148,10 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch ...@@ -1151,6 +1148,10 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
[o_hotkeys_listbox reloadData]; [o_hotkeys_listbox reloadData];
b_hotkeyChanged = YES; b_hotkeyChanged = YES;
} }
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCMediaKeySupportSettingChanged"
object: nil
userInfo: nil];
} }
- (void)showHotkeySettings - (void)showHotkeySettings
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment