mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
Upgrade SPMediaKeyTap
This commit is contained in:
@@ -88,8 +88,7 @@
|
|||||||
}
|
}
|
||||||
-(void)printBacktrace;
|
-(void)printBacktrace;
|
||||||
{
|
{
|
||||||
int x;
|
for(int x = 3; x < frameCount; x++) {
|
||||||
for(x = 3; x < frameCount; x++) {
|
|
||||||
if(frameStrings[x] == NULL) { break; }
|
if(frameStrings[x] == NULL) { break; }
|
||||||
printf("%s\n", frameStrings[x]);
|
printf("%s\n", frameStrings[x]);
|
||||||
}
|
}
|
||||||
|
9
thirdparty/SPMediaKeyTap/SPMediaKeyTap.h
vendored
9
thirdparty/SPMediaKeyTap/SPMediaKeyTap.h
vendored
@@ -31,4 +31,13 @@
|
|||||||
-(void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
|
-(void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
extern NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey;
|
extern NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey;
|
||||||
|
extern NSString *kIgnoreMediaKeysDefaultsKey;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
36
thirdparty/SPMediaKeyTap/SPMediaKeyTap.m
vendored
36
thirdparty/SPMediaKeyTap/SPMediaKeyTap.m
vendored
@@ -28,6 +28,9 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
|
|||||||
[self startWatchingAppSwitching];
|
[self startWatchingAppSwitching];
|
||||||
singleton = self;
|
singleton = self;
|
||||||
_mediaKeyAppList = [NSMutableArray new];
|
_mediaKeyAppList = [NSMutableArray new];
|
||||||
|
_tapThreadRL=nil;
|
||||||
|
_eventPort=nil;
|
||||||
|
_eventPortSource=nil;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
-(void)dealloc;
|
-(void)dealloc;
|
||||||
@@ -58,6 +61,9 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
|
|||||||
}
|
}
|
||||||
|
|
||||||
-(void)startWatchingMediaKeys;{
|
-(void)startWatchingMediaKeys;{
|
||||||
|
// Prevent having multiple mediaKeys threads
|
||||||
|
[self stopWatchingMediaKeys];
|
||||||
|
|
||||||
[self setShouldInterceptMediaKeyEvents:YES];
|
[self setShouldInterceptMediaKeyEvents:YES];
|
||||||
|
|
||||||
// Add an event tap to intercept the system defined media key events
|
// Add an event tap to intercept the system defined media key events
|
||||||
@@ -78,6 +84,22 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
|
|||||||
-(void)stopWatchingMediaKeys;
|
-(void)stopWatchingMediaKeys;
|
||||||
{
|
{
|
||||||
// TODO<nevyn>: Shut down thread, remove event tap port and source
|
// TODO<nevyn>: Shut down thread, remove event tap port and source
|
||||||
|
|
||||||
|
if(_tapThreadRL){
|
||||||
|
CFRunLoopStop(_tapThreadRL);
|
||||||
|
_tapThreadRL=nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_eventPort){
|
||||||
|
CFMachPortInvalidate(_eventPort);
|
||||||
|
CFRelease(_eventPort);
|
||||||
|
_eventPort=nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_eventPortSource){
|
||||||
|
CFRelease(_eventPortSource);
|
||||||
|
_eventPortSource=nil;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
@@ -90,7 +112,9 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
|
|||||||
return NO;
|
return NO;
|
||||||
#else
|
#else
|
||||||
// XXX(nevyn): MediaKey event tap doesn't work on 10.4, feel free to figure out why if you have the energy.
|
// XXX(nevyn): MediaKey event tap doesn't work on 10.4, feel free to figure out why if you have the energy.
|
||||||
return floor(NSAppKitVersionNumber) >= 949/*NSAppKitVersionNumber10_5*/;
|
return
|
||||||
|
![[NSUserDefaults standardUserDefaults] boolForKey:kIgnoreMediaKeysDefaultsKey]
|
||||||
|
&& floor(NSAppKitVersionNumber) >= 949/*NSAppKitVersionNumber10_5*/;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +132,14 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
|
|||||||
@"com.apple.Aperture",
|
@"com.apple.Aperture",
|
||||||
@"com.plexsquared.Plex",
|
@"com.plexsquared.Plex",
|
||||||
@"com.soundcloud.desktop",
|
@"com.soundcloud.desktop",
|
||||||
|
@"org.niltsh.MPlayerX",
|
||||||
|
@"com.ilabs.PandorasHelper",
|
||||||
|
@"com.mahasoftware.pandabar",
|
||||||
|
@"com.bitcartel.pandorajam",
|
||||||
|
@"org.clementine-player.clementine",
|
||||||
|
@"fm.last.Last.fm",
|
||||||
|
@"com.beatport.BeatportPro",
|
||||||
|
@"com.Timenut.SongKey",
|
||||||
@"com.macromedia.fireworks", // the tap messes up their mouse input
|
@"com.macromedia.fireworks", // the tap messes up their mouse input
|
||||||
nil
|
nil
|
||||||
];
|
];
|
||||||
@@ -213,6 +245,8 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
|
|||||||
#pragma mark Task switching callbacks
|
#pragma mark Task switching callbacks
|
||||||
|
|
||||||
NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey = @"SPApplicationsNeedingMediaKeys";
|
NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey = @"SPApplicationsNeedingMediaKeys";
|
||||||
|
NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-(void)mediaKeyAppListChanged;
|
-(void)mediaKeyAppListChanged;
|
||||||
|
Reference in New Issue
Block a user