Commit 9c623237 authored by Andre Pang's avatar Andre Pang

* Mac OS X: intercept and respond to user-configured VLC hotkeys, rather

  than only responding to shortcut keys which are defined in the .nib
  interface file
parent 1ce23b85
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
- (void)setIntf:(intf_thread_t *)p_intf; - (void)setIntf:(intf_thread_t *)p_intf;
- (intf_thread_t *)getIntf; - (intf_thread_t *)getIntf;
- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
@end @end
......
...@@ -212,6 +212,50 @@ static void Run( intf_thread_t *p_intf ) ...@@ -212,6 +212,50 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_vlc->b_die = VLC_TRUE; p_intf->p_vlc->b_die = VLC_TRUE;
} }
/*****************************************************************************
* hasDefinedShortcutKey: Check to see if the key press is a defined VLC
* shortcut key. If it is, pass it off to VLC for handling and return YES,
* otherwise ignore it and return NO (where it will get handled by Cocoa).
*****************************************************************************/
- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event
{
unichar key = 0;
vlc_value_t val;
unsigned int i_pressed_modifiers = 0;
struct hotkey *p_hotkeys;
int i;
val.i_int = 0;
p_hotkeys = p_intf->p_vlc->p_hotkeys;
i_pressed_modifiers = [o_event modifierFlags];
if( i_pressed_modifiers & NSShiftKeyMask )
val.i_int |= KEY_MODIFIER_SHIFT;
if( i_pressed_modifiers & NSControlKeyMask )
val.i_int |= KEY_MODIFIER_CTRL;
if( i_pressed_modifiers & NSAlternateKeyMask )
val.i_int |= KEY_MODIFIER_ALT;
if( i_pressed_modifiers & NSCommandKeyMask )
val.i_int |= KEY_MODIFIER_COMMAND;
key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
val.i_int |= CocoaKeyToVLC( key );
for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
{
if( p_hotkeys[i].i_key == val.i_int )
{
var_Set( p_intf->p_vlc, "key-pressed", val );
return YES;
}
}
return NO;
}
@end @end
int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <Cocoa/Cocoa.h> #include <Cocoa/Cocoa.h>
#include "intf.h" /* VLCApplication */
#include "misc.h" #include "misc.h"
#include "playlist.h" #include "playlist.h"
...@@ -40,6 +41,13 @@ ...@@ -40,6 +41,13 @@
return( self ); return( self );
} }
- (BOOL)performKeyEquivalent:(NSEvent *)o_event
{
return [( (VLCApplication *) [VLCApplication sharedApplication] )
hasDefinedShortcutKey:o_event];
}
@end @end
......
...@@ -973,6 +973,12 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -973,6 +973,12 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
return( YES ); return( YES );
} }
- (BOOL)performKeyEquivalent:(NSEvent *)o_event
{
return [(VLCApplication *) [VLCApplication sharedApplication]
hasDefinedShortcutKey:o_event];
}
- (void)keyDown:(NSEvent *)o_event - (void)keyDown:(NSEvent *)o_event
{ {
unichar key = 0; unichar key = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment