Commit 6325b1c3 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: fixed NSRangeException when triggering modifier keys without...

macosx: fixed NSRangeException when triggering modifier keys without characters as enabled by some international keyboards (close #7268)
(cherry picked from commit c97faddc527a0455c93419982b23763a3d6485d8)

Conflicts:
	modules/gui/macosx/MainWindow.m
	modules/gui/macosx/intf.m
parent c772af6d
...@@ -113,11 +113,15 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -113,11 +113,15 @@ static VLCMainWindow *_o_sharedInstance = nil;
unsigned int i_keyModifiers = [[VLCMain sharedInstance] VLCModifiersToCocoa:o_key]; unsigned int i_keyModifiers = [[VLCMain sharedInstance] VLCModifiersToCocoa:o_key];
return [[[o_event charactersIgnoringModifiers] lowercaseString] isEqualToString: [[VLCMain sharedInstance] VLCKeyToString: o_key]] && NSString * characters = [o_event charactersIgnoringModifiers];
if ([characters length] > 0) {
return [[characters lowercaseString] isEqualToString: [[VLCMain sharedInstance] VLCKeyToString: o_key]] &&
(i_keyModifiers & NSShiftKeyMask) == ([o_event modifierFlags] & NSShiftKeyMask) && (i_keyModifiers & NSShiftKeyMask) == ([o_event modifierFlags] & NSShiftKeyMask) &&
(i_keyModifiers & NSControlKeyMask) == ([o_event modifierFlags] & NSControlKeyMask) && (i_keyModifiers & NSControlKeyMask) == ([o_event modifierFlags] & NSControlKeyMask) &&
(i_keyModifiers & NSAlternateKeyMask) == ([o_event modifierFlags] & NSAlternateKeyMask) && (i_keyModifiers & NSAlternateKeyMask) == ([o_event modifierFlags] & NSAlternateKeyMask) &&
(i_keyModifiers & NSCommandKeyMask) == ([o_event modifierFlags] & NSCommandKeyMask); (i_keyModifiers & NSCommandKeyMask) == ([o_event modifierFlags] & NSCommandKeyMask);
}
return NO;
} }
- (BOOL)performKeyEquivalent:(NSEvent *)o_event - (BOOL)performKeyEquivalent:(NSEvent *)o_event
......
...@@ -140,7 +140,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -140,7 +140,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if( i_pressed_modifiers & NSCommandKeyMask ) if( i_pressed_modifiers & NSCommandKeyMask )
val.i_int |= KEY_MODIFIER_COMMAND; val.i_int |= KEY_MODIFIER_COMMAND;
key = [[[o_event charactersIgnoringModifiers] lowercaseString] characterAtIndex: 0]; NSString * characters = [o_event charactersIgnoringModifiers];
if ([characters length] > 0)
{
key = [[characters lowercaseString] characterAtIndex: 0];
if( key ) if( key )
{ {
...@@ -149,7 +152,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -149,7 +152,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if( key == (unichar) 0x1b ) if( key == (unichar) 0x1b )
{ {
playlist_t * p_playlist = pl_Get( VLCIntf ); playlist_t * p_playlist = pl_Get( VLCIntf );
if( var_GetBool( p_playlist, "fullscreen" ) ) if( var_GetBool( p_playlist, "fullscreen") )
[[VLCCoreInteraction sharedInstance] toggleFullscreen]; [[VLCCoreInteraction sharedInstance] toggleFullscreen];
} }
/* handle Lion's default key combo for fullscreen-toggle in addition to our own hotkeys */ /* handle Lion's default key combo for fullscreen-toggle in addition to our own hotkeys */
...@@ -172,8 +175,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -172,8 +175,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if (p_vout) if (p_vout)
vlc_object_release( p_vout ); vlc_object_release( p_vout );
return;
}
} }
else
[super keyDown: o_event]; [super keyDown: o_event];
} }
......
...@@ -345,7 +345,10 @@ ...@@ -345,7 +345,10 @@
- (BOOL)keyEvent:(NSEvent *)o_event - (BOOL)keyEvent:(NSEvent *)o_event
{ {
BOOL eventHandled = NO; BOOL eventHandled = NO;
unichar key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0]; NSString * characters = [o_event charactersIgnoringModifiers];
if ([characters length] > 0)
{
unichar key = [characters characterAtIndex: 0];
if( key ) if( key )
{ {
...@@ -375,6 +378,7 @@ ...@@ -375,6 +378,7 @@
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
} }
}
return eventHandled; return eventHandled;
} }
......
...@@ -1340,7 +1340,10 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1340,7 +1340,10 @@ unsigned int CocoaKeyToVLC( unichar i_key )
val.i_int |= KEY_MODIFIER_COMMAND; val.i_int |= KEY_MODIFIER_COMMAND;
} }
key = [[[o_event charactersIgnoringModifiers] lowercaseString] characterAtIndex: 0]; NSString * characters = [o_event charactersIgnoringModifiers];
if ([characters length] > 0)
{
key = [[characters lowercaseString] characterAtIndex: 0];
/* handle Lion's default key combo for fullscreen-toggle in addition to our own hotkeys */ /* handle Lion's default key combo for fullscreen-toggle in addition to our own hotkeys */
if( key == 'f' && i_pressed_modifiers & NSControlKeyMask && i_pressed_modifiers & NSCommandKeyMask ) if( key == 'f' && i_pressed_modifiers & NSControlKeyMask && i_pressed_modifiers & NSCommandKeyMask )
...@@ -1381,7 +1384,7 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1381,7 +1384,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
NSString *str = [o_usedHotkeys objectAtIndex: i]; NSString *str = [o_usedHotkeys objectAtIndex: i];
unsigned int i_keyModifiers = [self VLCModifiersToCocoa: str]; unsigned int i_keyModifiers = [self VLCModifiersToCocoa: str];
if( [[[o_event charactersIgnoringModifiers] lowercaseString] isEqualToString: [self VLCKeyToString: str]] && if( [[characters lowercaseString] isEqualToString: [self VLCKeyToString: str]] &&
(i_keyModifiers & NSShiftKeyMask) == (i_pressed_modifiers & NSShiftKeyMask) && (i_keyModifiers & NSShiftKeyMask) == (i_pressed_modifiers & NSShiftKeyMask) &&
(i_keyModifiers & NSControlKeyMask) == (i_pressed_modifiers & NSControlKeyMask) && (i_keyModifiers & NSControlKeyMask) == (i_pressed_modifiers & NSControlKeyMask) &&
(i_keyModifiers & NSAlternateKeyMask) == (i_pressed_modifiers & NSAlternateKeyMask) && (i_keyModifiers & NSAlternateKeyMask) == (i_pressed_modifiers & NSAlternateKeyMask) &&
...@@ -1397,6 +1400,7 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1397,6 +1400,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
var_SetInteger( p_intf->p_libvlc, "key-pressed", val.i_int ); var_SetInteger( p_intf->p_libvlc, "key-pressed", val.i_int );
return YES; return YES;
} }
}
return NO; return NO;
} }
......
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