[vlc-commits] macosx: change handling of arrow keys slightly

David Fuhrmann git at videolan.org
Tue Jul 3 14:42:55 CEST 2012


vlc/vlc-2.0 | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Tue Jul  3 13:29:54 2012 +0200| [ba9cae3ae9f4ed32c9f1ba72664996a6891355e4] | committer: Felix Paul Kühne

macosx: change handling of arrow keys slightly

When the key is assigned to an main menu item: In this case the event
is never passed to the controls, so we want to handle it here for these
exeptional cases.

For all other cases: The event is ignored here and handled by the controls
(playlist, or video view, which also sends it to vlc core).
(cherry picked from commit 0ccbaa821f8b7b928c651df53db5ad50ed246b83)

Signed-off-by: Felix Paul Kühne <fkuehne at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=ba9cae3ae9f4ed32c9f1ba72664996a6891355e4
---

 modules/gui/macosx/MainWindow.m |    5 ++++-
 modules/gui/macosx/intf.h       |    2 +-
 modules/gui/macosx/intf.m       |    4 ++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 3473ef0..aa60731 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -122,6 +122,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
 - (BOOL)performKeyEquivalent:(NSEvent *)o_event
 {
+    BOOL b_force = NO;
     // these are key events which should be handled by vlc core, but are attached to a main menu item
     if( ![self isEvent: o_event forKey: "key-vol-up"] &&
         ![self isEvent: o_event forKey: "key-vol-down"] &&
@@ -132,8 +133,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
         if([[NSApp mainMenu] performKeyEquivalent:o_event])
             return TRUE;
     }
+    else
+        b_force = YES;
 
-    return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event] ||
+    return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event force:b_force] ||
            [(VLCControls *)[[VLCMain sharedInstance] controls] keyEvent:o_event];
 }
 
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index eff1f78..7cae304 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -175,7 +175,7 @@ struct intf_sys_t
 - (NSString *)localizedString:(const char *)psz;
 - (char *)delocalizeString:(NSString *)psz;
 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
-- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
+- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
 - (NSString *)VLCKeyToString:(NSString *)theString;
 - (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
 - (void)updateCurrentlyUsedHotkeys;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 9df99fc..7bac8c5 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1305,7 +1305,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
  * 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
+- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force
 {
     unichar key = 0;
     vlc_value_t val;
@@ -1336,7 +1336,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
         return YES;
     }
 
-    if( val.i_int == 0 ) // ignore only when no modifier is pressed
+    if( !b_force )
     {
         switch( key )
         {



More information about the vlc-commits mailing list