diff options
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/macosx_application.m | 4 | ||||
-rw-r--r-- | osdep/macosx_compat.h | 2 | ||||
-rw-r--r-- | osdep/macosx_events.h | 2 | ||||
-rw-r--r-- | osdep/macosx_events.m | 30 | ||||
-rw-r--r-- | osdep/macosx_events_objc.h | 2 |
5 files changed, 15 insertions, 25 deletions
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index cccd60b4e2..fb3d742ed8 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -81,8 +81,8 @@ static void terminate_cocoa_application(void) - (void)sendEvent:(NSEvent *)event { - [super sendEvent:event]; - + if (![_eventsResponder processKeyEvent:event]) + [super sendEvent:event]; [_eventsResponder wakeup]; } diff --git a/osdep/macosx_compat.h b/osdep/macosx_compat.h index 06b8cbd175..1cb5018382 100644 --- a/osdep/macosx_compat.h +++ b/osdep/macosx_compat.h @@ -37,8 +37,6 @@ static const NSEventType NSEventTypeSystemDefined = NSSystemDefined; static const NSEventType NSEventTypeKeyDown = NSKeyDown; static const NSEventType NSEventTypeKeyUp = NSKeyUp; -static const NSEventMask NSEventMaskKeyDown = NSKeyDownMask; -static const NSEventMask NSEventMaskKeyUp = NSKeyUpMask; static const NSEventMask NSEventMaskLeftMouseUp = NSLeftMouseUpMask; #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10) diff --git a/osdep/macosx_events.h b/osdep/macosx_events.h index 019f24feef..9da3cb27bc 100644 --- a/osdep/macosx_events.h +++ b/osdep/macosx_events.h @@ -28,8 +28,6 @@ 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); - void cocoa_init_apple_remote(void); void cocoa_uninit_apple_remote(void); diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m index 47448fd965..6cddd40026 100644 --- a/osdep/macosx_events.m +++ b/osdep/macosx_events.m @@ -55,7 +55,6 @@ - (NSEvent *)handleKey:(NSEvent *)event; - (void)setMpvHandle:(struct mpv_handle *)ctx; - (void)readEvents; -- (void)startEventMonitor; - (void)startAppleRemote; - (void)stopAppleRemote; - (void)startMediaKeys; @@ -123,11 +122,6 @@ static int convert_key(unsigned key, unsigned charcode) return charcode; } -void cocoa_start_event_monitor(void) -{ - [[EventsResponder sharedInstance] startEventMonitor]; -} - void cocoa_init_apple_remote(void) { [[EventsResponder sharedInstance] startAppleRemote]; @@ -347,19 +341,6 @@ void cocoa_set_mpv_handle(struct mpv_handle *ctx) } } -- (void)startEventMonitor -{ - [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown|NSEventMaskKeyUp - handler:^(NSEvent *event) { - BOOL equivalent = [[NSApp mainMenu] performKeyEquivalent:event]; - if (equivalent) { - return (NSEvent *)nil; - } else { - return [self handleKey:event]; - } - }]; -} - - (void)startAppleRemote { @@ -527,6 +508,17 @@ void cocoa_set_mpv_handle(struct mpv_handle *ctx) return nil; } +- (bool)processKeyEvent:(NSEvent *)event +{ + if ((event.type == NSEventTypeKeyDown || event.type == NSEventTypeKeyUp) && + ![[NSApp mainMenu] performKeyEquivalent:event]) + { + [self handleKey:event]; + return true; + } + return false; +} + - (void)handleFilesArray:(NSArray *)files { enum mp_dnd_action action = [NSEvent modifierFlags] & diff --git a/osdep/macosx_events_objc.h b/osdep/macosx_events_objc.h index 99f00dcc1e..ff5db938c9 100644 --- a/osdep/macosx_events_objc.h +++ b/osdep/macosx_events_objc.h @@ -42,4 +42,6 @@ struct input_ctx; - (void)handleFilesArray:(NSArray *)files; +- (bool)processKeyEvent:(NSEvent *)event; + @end |