[vlc-devel] [VLC 3.x v2 07/11] macosx: SPMediaKeyTap: Remove interception state
Marvin Scholz
epirat07 at gmail.com
Fri Apr 23 01:19:34 UTC 2021
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.
---
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;
--
2.30.1
More information about the vlc-devel
mailing list