[vlc-commits] macosx: SPMediaKeyTap: Remove interception state

Marvin Scholz git at videolan.org
Fri Apr 23 21:27:40 UTC 2021


vlc/vlc-3.0 | branch: master | Marvin Scholz <epirat07 at gmail.com> | Fri Apr 23 01:13:17 2021 +0200| [1133f053a09aed5b0f19470d58e2f8cf772d781a] | committer: Marvin Scholz

macosx: SPMediaKeyTap: Remove interception state

Do not keep an additional interception state which can get
out of sync with the actual interception state. Just call
CGEventTapEnable with the desired state directly.

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=1133f053a09aed5b0f19470d58e2f8cf772d781a
---

 modules/gui/macosx/SPMediaKeyTap.m | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/modules/gui/macosx/SPMediaKeyTap.m b/modules/gui/macosx/SPMediaKeyTap.m
index bd32d5017e..315af6ef5c 100644
--- a/modules/gui/macosx/SPMediaKeyTap.m
+++ b/modules/gui/macosx/SPMediaKeyTap.m
@@ -32,7 +32,6 @@ NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys";
 @interface SPMediaKeyTap () {
     CFMachPortRef _eventPort;
     CFRunLoopSourceRef _eventPortSource;
-    BOOL _shouldInterceptMediaKeyEvents;
     id _delegate;
     // The app that is frontmost in this list owns media keys
     NSMutableArray<NSRunningApplication *> *_mediaKeyAppList;
@@ -198,13 +197,8 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
 
 - (void)setShouldInterceptMediaKeyEvents:(BOOL)newSetting
 {
-    BOOL oldSetting = _shouldInterceptMediaKeyEvents;
-    _shouldInterceptMediaKeyEvents = newSetting;
-
     if (_eventPort == NULL)
         return;
-    if (oldSetting == newSetting)
-        return;
 
     CGEventTapEnable(_eventPort, newSetting);
 }
@@ -246,9 +240,6 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
         if (keyCode != NX_KEYTYPE_PLAY && keyCode != NX_KEYTYPE_FAST && keyCode != NX_KEYTYPE_REWIND && keyCode != NX_KEYTYPE_PREVIOUS && keyCode != NX_KEYTYPE_NEXT)
             return event;
 
-        if (!self->_shouldInterceptMediaKeyEvents)
-            return event;
-
         [self performSelectorOnMainThread:@selector(handleAndReleaseMediaKeyEvent:) withObject:nsEvent waitUntilDone:NO];
 
         return NULL;



More information about the vlc-commits mailing list