Changeset 9c623237a0965223c78d8544708d7c1bac62d1ec

Show
Ignore:
Timestamp:
04/20/04 06:24:52 (4 years ago)
Author:
Andre Pang <andrep@videolan.org>
git-committer:
Andre Pang <andrep@videolan.org> 1082435092 +0000
git-parent:

[1ce23b854fd7bf0805f1cdd5969ac8c2ead2d5c3]

git-author:
Andre Pang <andrep@videolan.org> 1082435092 +0000
Message:

* 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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/macosx/intf.h

    rd5c4e1b r9c62323  
    4545- (void)setIntf:(intf_thread_t *)p_intf; 
    4646- (intf_thread_t *)getIntf; 
     47- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event; 
    4748 
    4849@end 
  • modules/gui/macosx/intf.m

    r15206e7 r9c62323  
    211211{ 
    212212    p_intf->p_vlc->b_die = VLC_TRUE; 
     213} 
     214 
     215 
     216/***************************************************************************** 
     217 * hasDefinedShortcutKey: Check to see if the key press is a defined VLC 
     218 * shortcut key.  If it is, pass it off to VLC for handling and return YES, 
     219 * otherwise ignore it and return NO (where it will get handled by Cocoa). 
     220 *****************************************************************************/ 
     221- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event 
     222{ 
     223    unichar key = 0; 
     224    vlc_value_t val; 
     225    unsigned int i_pressed_modifiers = 0; 
     226    struct hotkey *p_hotkeys; 
     227    int i; 
     228 
     229    val.i_int = 0; 
     230    p_hotkeys = p_intf->p_vlc->p_hotkeys; 
     231 
     232    i_pressed_modifiers = [o_event modifierFlags]; 
     233 
     234    if( i_pressed_modifiers & NSShiftKeyMask ) 
     235        val.i_int |= KEY_MODIFIER_SHIFT; 
     236    if( i_pressed_modifiers & NSControlKeyMask ) 
     237        val.i_int |= KEY_MODIFIER_CTRL; 
     238    if( i_pressed_modifiers & NSAlternateKeyMask ) 
     239        val.i_int |= KEY_MODIFIER_ALT; 
     240    if( i_pressed_modifiers & NSCommandKeyMask ) 
     241        val.i_int |= KEY_MODIFIER_COMMAND; 
     242 
     243    key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0]; 
     244 
     245    val.i_int |= CocoaKeyToVLC( key ); 
     246 
     247    for( i = 0; p_hotkeys[i].psz_action != NULL; i++ ) 
     248    { 
     249        if( p_hotkeys[i].i_key == val.i_int ) 
     250        { 
     251            var_Set( p_intf->p_vlc, "key-pressed", val ); 
     252            return YES; 
     253        } 
     254    } 
     255 
     256    return NO; 
    213257} 
    214258 
  • modules/gui/macosx/misc.m

    r136957e r9c62323  
    2424#include <Cocoa/Cocoa.h> 
    2525 
     26#include "intf.h"                                          /* VLCApplication */ 
    2627#include "misc.h" 
    2728#include "playlist.h" 
     
    4142    return( self ); 
    4243} 
     44 
     45- (BOOL)performKeyEquivalent:(NSEvent *)o_event 
     46{ 
     47    return [( (VLCApplication *) [VLCApplication sharedApplication] ) 
     48            hasDefinedShortcutKey:o_event]; 
     49} 
     50 
    4351@end 
    4452 
  • modules/gui/macosx/vout.m

    r1ce23b8 r9c62323  
    974974} 
    975975 
     976- (BOOL)performKeyEquivalent:(NSEvent *)o_event 
     977{ 
     978    return [(VLCApplication *) [VLCApplication sharedApplication] 
     979            hasDefinedShortcutKey:o_event]; 
     980} 
     981 
    976982- (void)keyDown:(NSEvent *)o_event 
    977983{