diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2014-10-09 22:11:12 +0200 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2014-10-09 22:14:41 +0200 |
commit | 8a25a4af655f429382040aac6625ddd776f5da96 (patch) | |
tree | 5c8a6a3b78989e20981884cb1f77396a933a0552 | |
parent | e99a37f635ae1ddf933ce4a21634946b3fca3330 (diff) | |
download | mpv-8a25a4af655f429382040aac6625ddd776f5da96.tar.bz2 mpv-8a25a4af655f429382040aac6625ddd776f5da96.tar.xz |
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.
-rw-r--r-- | osdep/macosx_events.h | 1 | ||||
-rw-r--r-- | osdep/macosx_events.m | 5 | ||||
-rw-r--r-- | video/out/cocoa/events_view.m | 8 | ||||
-rw-r--r-- | video/out/cocoa/mpvadapter.h | 1 | ||||
-rw-r--r-- | video/out/cocoa_common.m | 5 |
5 files changed, 20 insertions, 0 deletions
diff --git a/osdep/macosx_events.h b/osdep/macosx_events.h index 34d653c3de..f9008b40ec 100644 --- a/osdep/macosx_events.h +++ b/osdep/macosx_events.h @@ -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); diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m index 71a9591134..f913b5db1a 100644 --- a/osdep/macosx_events.m +++ b/osdep/macosx_events.m @@ -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]; diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m index 744c3f27c7..6de24c470c 100644 --- a/video/out/cocoa/events_view.m +++ b/video/out/cocoa/events_view.m @@ -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]; diff --git a/video/out/cocoa/mpvadapter.h b/video/out/cocoa/mpvadapter.h index 205b2b1443..1355a5b345 100644 --- a/video/out/cocoa/mpvadapter.h +++ b/video/out/cocoa/mpvadapter.h @@ -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; diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index d704706501..ec0a61055b 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -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); |