1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 06:42:03 +00:00

cocoa: post keydown and keyup events without event monitor

Our code worked under the assumption that the event monitor is always active
and we did remove the keydown and keyup overrides from our cocoa view.
This commit is contained in:
Stefano Pigozzi 2014-10-09 22:11:12 +02:00
parent e99a37f635
commit 8a25a4af65
5 changed files with 20 additions and 0 deletions

View File

@ -25,6 +25,7 @@ struct input_ctx;
void cocoa_put_key(int keycode);
void cocoa_put_key_with_modifiers(int keycode, int modifiers);
void cocoa_put_key_event(void *event);
void cocoa_start_event_monitor(void);

View File

@ -189,6 +189,11 @@ void cocoa_put_key(int keycode)
mp_input_put_key(inputContext, keycode);
}
void cocoa_put_key_event(void *event)
{
[[EventsResponder sharedInstance] handleKey:event];
}
void cocoa_put_key_with_modifiers(int keycode, int modifiers)
{
keycode |= [[EventsResponder sharedInstance] mapKeyModifiers:modifiers];

View File

@ -130,6 +130,14 @@
- (BOOL)becomeFirstResponder { return YES; }
- (BOOL)resignFirstResponder { return YES; }
- (void)keyDown:(NSEvent *)event {
[self.adapter putKeyEvent:event];
}
- (void)keyUp:(NSEvent *)event {
[self.adapter putKeyEvent:event];
}
- (BOOL)canHideCursor
{
return !self.hasMouseDown && [self containsMouseLocation];

View File

@ -23,6 +23,7 @@
- (void)unlock;
- (void)setNeedsResize;
- (void)signalMouseMovement:(NSPoint)point;
- (void)putKeyEvent:(NSEvent*)event;
- (void)putKey:(int)mpkey withModifiers:(int)modifiers;
- (void)putAxis:(int)mpkey delta:(float)delta;
- (void)putCommand:(char*)cmd;

View File

@ -719,6 +719,11 @@ void *vo_cocoa_cgl_pixel_format(struct vo *vo)
[self recalcMovableByWindowBackground:point];
}
- (void)putKeyEvent:(NSEvent*)event
{
cocoa_put_key_event(event);
}
- (void)putKey:(int)mpkey withModifiers:(int)modifiers
{
cocoa_put_key_with_modifiers(mpkey, modifiers);