[vlc-devel] [VLC 3.x v2 06/11] macosx: SPMediaKeyTap: Check earlier for event type
Marvin Scholz
epirat07 at gmail.com
Fri Apr 23 01:19:33 UTC 2021
Do not create the NSEvent before checking if the event is actually a
NX_SYSDEFINED. It should never happen, but just in case, there is no
point in creating the NSEvent first.
---
modules/gui/macosx/SPMediaKeyTap.m | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/modules/gui/macosx/SPMediaKeyTap.m b/modules/gui/macosx/SPMediaKeyTap.m
index 4ffb01087a..bd32d5017e 100644
--- a/modules/gui/macosx/SPMediaKeyTap.m
+++ b/modules/gui/macosx/SPMediaKeyTap.m
@@ -225,6 +225,9 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
} else if(type == kCGEventTapDisabledByUserInput) {
// Was disabled manually by -setShouldInterceptMediaKeyEvents:
return event;
+ } else if(type != NX_SYSDEFINED) {
+ // If not a system defined event, do nothing.
+ return event;
}
NSEvent *nsEvent = nil;
@try {
@@ -236,7 +239,7 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
return event;
}
- if (type != NX_SYSDEFINED || [nsEvent subtype] != SPSystemDefinedEventMediaKeys)
+ if ([nsEvent subtype] != SPSystemDefinedEventMediaKeys)
return event;
int keyCode = (([nsEvent data1] & 0xFFFF0000) >> 16);
--
2.30.1
More information about the vlc-devel
mailing list