[vlc-commits] macosx: SPMediaKeyTap: Consolidate callbacks
Marvin Scholz
git at videolan.org
Fri Apr 23 21:27:38 UTC 2021
vlc/vlc-3.0 | branch: master | Marvin Scholz <epirat07 at gmail.com> | Fri Apr 23 01:01:37 2021 +0200| [68cffcff2bcb6d14d459112831e3ae00291b053b] | committer: Marvin Scholz
macosx: SPMediaKeyTap: Consolidate callbacks
One callback only existed to call the other one with the
autorelease pool. Move that to the other one and get rid of
the unnecessary callback.
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=68cffcff2bcb6d14d459112831e3ae00291b053b
---
modules/gui/macosx/SPMediaKeyTap.m | 72 +++++++++++++++++---------------------
1 file changed, 33 insertions(+), 39 deletions(-)
diff --git a/modules/gui/macosx/SPMediaKeyTap.m b/modules/gui/macosx/SPMediaKeyTap.m
index 0b7dccdf70..4ffb01087a 100644
--- a/modules/gui/macosx/SPMediaKeyTap.m
+++ b/modules/gui/macosx/SPMediaKeyTap.m
@@ -213,48 +213,42 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
#pragma mark -
#pragma mark Event tap callbacks
-static CGEventRef tapEventCallback2(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
-{
- SPMediaKeyTap *self = (__bridge SPMediaKeyTap *)refcon;
-
- if(type == kCGEventTapDisabledByTimeout) {
- NSLog(@"VLC SPMediaKeyTap: Media key event tap was disabled by timeout");
- CGEventTapEnable(self->_eventPort, TRUE);
- return event;
- } else if(type == kCGEventTapDisabledByUserInput) {
- // Was disabled manually by -setShouldInterceptMediaKeyEvents:
- return event;
- }
- NSEvent *nsEvent = nil;
- @try {
- nsEvent = [NSEvent eventWithCGEvent:event];
- }
- @catch (NSException * e) {
- NSLog(@"VLC SPMediaKeyTap: Strange CGEventType: %d: %@", type, e);
- assert(0);
- return event;
- }
-
- if (type != NX_SYSDEFINED || [nsEvent subtype] != SPSystemDefinedEventMediaKeys)
- return event;
-
- int keyCode = (([nsEvent data1] & 0xFFFF0000) >> 16);
- 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;
-}
-
static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
{
@autoreleasepool {
- CGEventRef ret = tapEventCallback2(proxy, type, event, refcon);
- return ret;
+ SPMediaKeyTap *self = (__bridge SPMediaKeyTap *)refcon;
+
+ if(type == kCGEventTapDisabledByTimeout) {
+ NSLog(@"VLC SPMediaKeyTap: Media key event tap was disabled by timeout");
+ CGEventTapEnable(self->_eventPort, TRUE);
+ return event;
+ } else if(type == kCGEventTapDisabledByUserInput) {
+ // Was disabled manually by -setShouldInterceptMediaKeyEvents:
+ return event;
+ }
+ NSEvent *nsEvent = nil;
+ @try {
+ nsEvent = [NSEvent eventWithCGEvent:event];
+ }
+ @catch (NSException * e) {
+ NSLog(@"VLC SPMediaKeyTap: Strange CGEventType: %d: %@", type, e);
+ assert(0);
+ return event;
+ }
+
+ if (type != NX_SYSDEFINED || [nsEvent subtype] != SPSystemDefinedEventMediaKeys)
+ return event;
+
+ int keyCode = (([nsEvent data1] & 0xFFFF0000) >> 16);
+ 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