mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 12:17:12 +00:00
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).
This commit is contained in:
parent
c89b162462
commit
462e6f281a
@ -93,11 +93,10 @@ static NSString *escape_loadfile_name(NSString *input)
|
||||
self.eventsResponder = [[[EventsResponder alloc] init] autorelease];
|
||||
self.willStopOnOpenEvent = NO;
|
||||
|
||||
[NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask
|
||||
[NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask|NSKeyUpMask
|
||||
handler:^(NSEvent *event) {
|
||||
return [self.eventsResponder handleKeyDown:event];
|
||||
return [self.eventsResponder handleKey:event];
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
@interface EventsResponder : NSObject <HIDRemoteDelegate>
|
||||
- (BOOL)handleMediaKey:(NSEvent *)event;
|
||||
- (NSEvent *)handleKeyDown:(NSEvent *)event;
|
||||
- (NSEvent *)handleKey:(NSEvent *)event;
|
||||
- (void)startAppleRemote;
|
||||
- (void)stopAppleRemote;
|
||||
- (void)startMediaKeys;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user