summaryrefslogtreecommitdiffstats
path: root/osdep/macosx_events.m
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-08-30 19:46:48 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-08-30 19:49:30 +0200
commit462e6f281a66ad8d8bfcfc9a342d365ccc28121f (patch)
treecc1f2674d8ff6faac6c3ee3ca976a49a916252c0 /osdep/macosx_events.m
parentc89b162462d37b06d1d2f78379c8d4fc9bf57c81 (diff)
downloadmpv-462e6f281a66ad8d8bfcfc9a342d365ccc28121f.tar.bz2
mpv-462e6f281a66ad8d8bfcfc9a342d365ccc28121f.tar.xz
cocoa: let the core handle key repeats
Report key down and key up modifiers to the core so that it can issue it's own key repeats (instead of relying on Cocoa's ones).
Diffstat (limited to 'osdep/macosx_events.m')
-rw-r--r--osdep/macosx_events.m16
1 files changed, 14 insertions, 2 deletions
diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m
index dfa43a0437..e09dc0af93 100644
--- a/osdep/macosx_events.m
+++ b/osdep/macosx_events.m
@@ -252,8 +252,10 @@ void cocoa_put_key_with_modifiers(int keycode, int modifiers)
andMapping:keymap];
}
-- (NSEvent*)handleKeyDown:(NSEvent *)event
+- (NSEvent*)handleKey:(NSEvent *)event
{
+ if ([event isARepeat]) return nil;
+
NSString *chars;
if (RightAltPressed([event modifierFlags]))
@@ -316,9 +318,19 @@ void cocoa_put_key_with_modifiers(int keycode, int modifiers)
return mask;
}
+- (int)mapTypeModifiers:(NSEventType)type
+{
+ NSDictionary *map = @{
+ @(NSKeyDown) : @(MP_KEY_STATE_DOWN),
+ @(NSKeyUp) : @(MP_KEY_STATE_UP),
+ };
+ return [map[@(type)] intValue];
+}
+
- (int)keyModifierMask:(NSEvent *)event
{
- return [self mapKeyModifiers:[event modifierFlags]];
+ return [self mapKeyModifiers:[event modifierFlags]] |
+ [self mapTypeModifiers:[event type]];
}
-(BOOL)handleKey:(int)key withMask:(int)mask andMapping:(NSDictionary *)mapping