[vlc-commits] [Git][videolan/vlc][3.0.x] macosx: respect previous media key option for touchbar integration

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Tue Jul 20 09:33:37 UTC 2021



Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC


Commits:
31bf2a82 by Felix Paul Kühne at 2021-07-18T18:28:58+02:00
macosx: respect previous media key option for touchbar integration

Currently, the touchbar and the system were always provided with
playback information on macOS 10.12.2 and higher. This patch respects
option used for the previous implementation to optionally disable this
behavior for increased privacy and to potential conflicts with third
party apps.

- - - - -


2 changed files:

- modules/gui/macosx/VLCInputManager.m
- modules/gui/macosx/VLCSimplePrefsController.m


Changes:

=====================================
modules/gui/macosx/VLCInputManager.m
=====================================
@@ -188,17 +188,25 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
 - (id)initWithMain:(VLCMain *)o_mainObj
 {
     self = [super init];
-    if(self) {
-        msg_Dbg(getIntf(), "Initializing input manager");
+    if (self) {
+        intf_thread_t *p_intf = getIntf();
+        msg_Dbg(p_intf, "Initializing input manager");
 
         o_main = o_mainObj;
-        var_AddCallback(pl_Get(getIntf()), "input-current", InputThreadChanged, (__bridge void *)self);
+        var_AddCallback(pl_Get(p_intf), "input-current", InputThreadChanged, (__bridge void *)self);
 
         informInputChangedQueue = dispatch_queue_create("org.videolan.vlc.inputChangedQueue", DISPATCH_QUEUE_SERIAL);
 
         if (@available(macOS 10.12.2, *)) {
-            _remoteControlService = [[VLCRemoteControlService alloc] init];
-            [_remoteControlService subscribeToRemoteCommands];
+            BOOL b_mediaKeySupport = var_InheritBool(p_intf, "macosx-mediakeys");
+            if (b_mediaKeySupport) {
+                _remoteControlService = [[VLCRemoteControlService alloc] init];
+                [_remoteControlService subscribeToRemoteCommands];
+            }
+            [[NSNotificationCenter defaultCenter] addObserver:self
+                                                     selector:@selector(coreChangedMediaKeySupportSetting:)
+                                                         name:VLCMediaKeySupportSettingChangedNotification
+                                                       object:nil];
         }
     }
     return self;
@@ -214,6 +222,9 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
 - (void)deinit
 {
     msg_Dbg(getIntf(), "Deinitializing input manager");
+
+    [[NSNotificationCenter defaultCenter] removeObserver: self];
+
     if (p_current_input) {
         /* continue playback where you left off */
         [self storePlaybackPositionForItem:p_current_input];
@@ -571,6 +582,23 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
                                                        deliverImmediately:YES];
 }
 
+- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    BOOL b_mediaKeySupport = var_InheritBool(p_intf, "macosx-mediakeys");
+    if (b_mediaKeySupport) {
+        if (!_remoteControlService) {
+            _remoteControlService = [[VLCRemoteControlService alloc] init];
+        }
+        [_remoteControlService subscribeToRemoteCommands];
+    } else {
+        [_remoteControlService unsubscribeFromRemoteCommands];
+    }
+}
+
 - (BOOL)hasInput
 {
     return p_current_input != NULL;


=====================================
modules/gui/macosx/VLCSimplePrefsController.m
=====================================
@@ -565,12 +565,7 @@ static inline const char * __config_GetLabel(vlc_object_t *p_this, const char *p
     [self setupButton:_intf_appleremoteCheckbox forBoolValue: "macosx-appleremote"];
     [self setupButton:_intf_appleremote_sysvolCheckbox forBoolValue: "macosx-appleremote-sysvol"];
     [self setupButton:_intf_statusIconCheckbox forBoolValue: "macosx-statusicon"];
-    if (OSX_SIERRA_AND_HIGHER) {
-        _intf_mediakeysCheckbox.enabled = NO;
-        _intf_mediakeysCheckbox.intValue = YES;
-    } else {
-        [self setupButton:_intf_mediakeysCheckbox forBoolValue: "macosx-mediakeys"];
-    }
+    [self setupButton:_intf_mediakeysCheckbox forBoolValue: "macosx-mediakeys"];
 
     [self setupButton:_video_nativeFullscreenCheckbox forBoolValue: "macosx-nativefullscreenmode"];
     [self setupButton:_video_embeddedCheckbox forBoolValue: "embedded-video"];



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/31bf2a82576c6c43e32aa9fce176aaca7ee2b277

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/31bf2a82576c6c43e32aa9fce176aaca7ee2b277
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list