Commit 1f363525 authored by David Fuhrmann's avatar David Fuhrmann Committed by Felix Paul Kühne

macosx: robustify media key trap handling

Only start and stop media key support when needed (ressource-intensive).

(cherry picked from commit 272b0ffa072918603894ecbb22e037824f1dbcfa)
Signed-off-by: default avatarFelix Paul Kühne <fkuehne@videolan.org>
parent d72c23fd
......@@ -105,6 +105,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
BOOL b_mediaKeySupport;
BOOL b_mediakeyJustJumped;
SPMediaKeyTap * o_mediaKeyController;
BOOL b_mediaKeyTrapEnabled;
NSArray *o_usedHotkeys;
......
......@@ -1833,18 +1833,23 @@ static const int kCurrentPreferencesVersion = 3;
- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
{
b_mediaKeySupport = var_InheritBool(VLCIntf, "macosx-mediakeys");
if (b_mediaKeySupport) {
if (!o_mediaKeyController)
o_mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
if (b_mediaKeySupport && !o_mediaKeyController)
o_mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot]->i_children > 0 ||
p_current_input)
if (b_mediaKeySupport && ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot]->i_children > 0 ||
p_current_input)) {
if (!b_mediaKeyTrapEnabled) {
b_mediaKeyTrapEnabled = YES;
msg_Dbg(p_intf, "Enable media key support");
[o_mediaKeyController startWatchingMediaKeys];
else
}
} else {
if (b_mediaKeyTrapEnabled) {
b_mediaKeyTrapEnabled = NO;
msg_Dbg(p_intf, "Disable media key support");
[o_mediaKeyController stopWatchingMediaKeys];
}
}
else if (!b_mediaKeySupport && o_mediaKeyController)
[o_mediaKeyController stopWatchingMediaKeys];
}
@end
......
......@@ -1451,10 +1451,6 @@ static inline void save_string_list(intf_thread_t * p_intf, id object, const cha
[o_hotkeys_listbox reloadData];
b_hotkeyChanged = YES;
}
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCMediaKeySupportSettingChanged"
object: nil
userInfo: nil];
}
- (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