Commit 99fbdecc 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.
parent df23caf7
......@@ -6,6 +6,7 @@ Mac OS X:
* Update Auhal audio output to the latest API
* Fix images disappearing issue on the interface
* Reduced installation size by up to 30 MB
* Resolved conflict between iTunes and VLC wrt Media Key handling
Mozilla/ActiveX webplugin:
* Fullscreen mode is fixed on Win32
......
......@@ -34,7 +34,7 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
#pragma mark Setup and teardown
-(id)initWithDelegate:(id)delegate;
{
_delegate = delegate;
_delegate = delegate;
[self startWatchingAppSwitching];
singleton = self;
_mediaKeyAppList = [NSMutableArray new];
......@@ -42,7 +42,7 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
}
-(void)dealloc;
{
[self stopWatchingMediaKeys];
[self stopWatchingMediaKeys];
[self stopWatchingAppSwitching];
[_mediaKeyAppList release];
[super dealloc];
......@@ -68,7 +68,7 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
}
-(void)startWatchingMediaKeys;{
[self setShouldInterceptMediaKeyEvents:YES];
[self setShouldInterceptMediaKeyEvents:YES];
// Add an event tap to intercept the system defined media key events
_eventPort = CGEventTapCreate(kCGSessionEventTap,
......
......@@ -574,14 +574,16 @@ static VLCMain *_o_sharedMainInstance = nil;
if( !p_intf ) return;
/* init media key support */
o_mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
[o_mediaKeyController startWatchingMediaKeys];
[o_mediaKeyController setShouldInterceptMediaKeyEvents:b_mediaKeySupport];
if( 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];
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
[SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers], kMediaKeyUsingBundleIdentifiersDefaultsKey,
nil]];
[self _removeOldPreferences];
......@@ -838,6 +840,9 @@ static VLCMain *_o_sharedMainInstance = nil;
/* release some other objects here, because it isn't sure whether dealloc
* will be called later on */
if( o_mediaKeyController )
[o_mediaKeyController release];
if( nib_about_loaded )
[o_about release];
......@@ -2843,7 +2848,30 @@ end:
- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
{
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
......
......@@ -844,9 +844,6 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
[[[VLCMain sharedInstance] appleRemoteController] startListening: [VLCMain sharedInstance]];
else
[[[VLCMain sharedInstance] appleRemoteController] stopListening: [VLCMain sharedInstance]];
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCMediaKeySupportSettingChanged"
object: nil
userInfo: nil];
/* okay, let's save our changes to vlcrc */
i = config_SaveConfigFile( p_intf, "main" );
......@@ -1092,6 +1089,10 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
}
b_hotkeyChanged = NO;
}
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCMediaKeySupportSettingChanged"
object: nil
userInfo: nil];
}
- (void)showSettingsForCategory: (id)o_new_category_view
......
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