Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
cfdad448
Commit
cfdad448
authored
May 18, 2012
by
Felix Paul Kühne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
macosx: update SPMediaKeyTap to latest code from upstream (refs #6613)
(cherry picked from commit
c6aa5ac9
)
parent
d707f8f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
24 deletions
+57
-24
modules/gui/macosx/SPMediaKeyTap.h
modules/gui/macosx/SPMediaKeyTap.h
+18
-19
modules/gui/macosx/SPMediaKeyTap.m
modules/gui/macosx/SPMediaKeyTap.m
+39
-5
No files found.
modules/gui/macosx/SPMediaKeyTap.h
View file @
cfdad448
...
...
@@ -18,24 +18,15 @@
#define SPSystemDefinedEventMediaKeys 8
@interface
SPMediaKeyTap
:
NSObject
{
EventHandlerRef
_app_switching_ref
;
EventHandlerRef
_app_terminating_ref
;
CFMachPortRef
_eventPort
;
CFRunLoopSourceRef
_eventPortSource
;
CFRunLoopRef
_tapThreadRL
;
BOOL
_shouldInterceptMediaKeyEvents
;
id
_delegate
;
// The app that is frontmost in this list owns media keys
NSMutableArray
*
_mediaKeyAppList
;
EventHandlerRef
_app_switching_ref
;
EventHandlerRef
_app_terminating_ref
;
CFMachPortRef
_eventPort
;
CFRunLoopSourceRef
_eventPortSource
;
CFRunLoopRef
_tapThreadRL
;
BOOL
_shouldInterceptMediaKeyEvents
;
id
_delegate
;
// The app that is frontmost in this list owns media keys
NSMutableArray
*
_mediaKeyAppList
;
}
+
(
NSArray
*
)
defaultMediaKeyUserBundleIdentifiers
;
...
...
@@ -45,11 +36,19 @@ NSMutableArray *_mediaKeyAppList;
-
(
void
)
startWatchingMediaKeys
;
-
(
void
)
stopWatchingMediaKeys
;
-
(
void
)
handleAndReleaseMediaKeyEvent
:(
NSEvent
*
)
event
;
-
(
void
)
setShouldInterceptMediaKeyEvents
:(
BOOL
)
newSetting
;
@end
@interface
NSObject
(
SPMediaKeyTapDelegate
)
-
(
void
)
mediaKeyTap
:(
SPMediaKeyTap
*
)
keyTap
receivedMediaKeyEvent
:(
NSEvent
*
)
event
;
@end
#ifdef __cplusplus
extern
"C"
{
#endif
extern
NSString
*
kMediaKeyUsingBundleIdentifiersDefaultsKey
;
extern
NSString
*
kIgnoreMediaKeysDefaultsKey
;
#ifdef __cplusplus
}
#endif
modules/gui/macosx/SPMediaKeyTap.m
View file @
cfdad448
...
...
@@ -11,10 +11,11 @@
// Copyright (c) 2010 Spotify AB
#import "SPMediaKeyTap.h"
#import "SPInvocationGrabbing.h"
// https://gist.github.com/511181
#import "SPInvocationGrabbing.h"
@interface
SPMediaKeyTap
()
-
(
BOOL
)
shouldInterceptMediaKeyEvents
;
-
(
void
)
setShouldInterceptMediaKeyEvents
:(
BOOL
)
newSetting
;
-
(
void
)
startWatchingAppSwitching
;
-
(
void
)
stopWatchingAppSwitching
;
-
(
void
)
eventTapThread
;
...
...
@@ -38,6 +39,9 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
[
self
startWatchingAppSwitching
];
singleton
=
self
;
_mediaKeyAppList
=
[
NSMutableArray
new
];
_tapThreadRL
=
nil
;
_eventPort
=
nil
;
_eventPortSource
=
nil
;
return
self
;
}
-
(
void
)
dealloc
;
...
...
@@ -68,6 +72,9 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
}
-
(
void
)
startWatchingMediaKeys
;{
// Prevent having multiple mediaKeys threads
[
self
stopWatchingMediaKeys
];
[
self
setShouldInterceptMediaKeyEvents
:
YES
];
// Add an event tap to intercept the system defined media key events
...
...
@@ -88,6 +95,22 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
-
(
void
)
stopWatchingMediaKeys
;
{
// 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 -
...
...
@@ -95,18 +118,21 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
+
(
BOOL
)
usesGlobalMediaKeyTap
{
return
YES
;
#ifdef _DEBUG
// breaking in gdb with a key tap inserted sometimes locks up all mouse and keyboard input forever, forcing reboot
return
NO
;
#else
// 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
}
+
(
NSArray
*
)
defaultMediaKeyUserBundleIdentifiers
;
{
return
[
NSArray
arrayWithObjects
:
[[
NSBundle
mainBundle
]
bundleIdentifier
],
// your app
@"com.spotify.client"
,
@"com.apple.iTunes"
,
@"com.apple.QuickTimePlayerX"
,
...
...
@@ -117,6 +143,14 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
@"com.apple.Aperture"
,
@"com.plexsquared.Plex"
,
@"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
nil
];
...
...
@@ -222,6 +256,8 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
#pragma mark Task switching callbacks
NSString
*
kMediaKeyUsingBundleIdentifiersDefaultsKey
=
@"SPApplicationsNeedingMediaKeys"
;
NSString
*
kIgnoreMediaKeysDefaultsKey
=
@"SPIgnoreMediaKeys"
;
-
(
void
)
mediaKeyAppListChanged
;
...
...
@@ -247,7 +283,6 @@ NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey = @"SPApplicationsNeedingMe
Boolean
same
;
OSErr
err
=
SameProcess
(
&
mySerial
,
&
topSerial
,
&
same
);
[
self
setShouldInterceptMediaKeyEvents
:(
err
==
noErr
&&
same
)];
}
-
(
void
)
appIsNowFrontmost
:(
ProcessSerialNumber
)
psn
;
{
...
...
@@ -301,7 +336,6 @@ static pascal OSStatus appTerminated (EventHandlerCallRef nextHandler, EventRef
&
deadPSN
);
[
self
appTerminated
:
deadPSN
];
return
CallNextEventHandler
(
nextHandler
,
evt
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment