diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index 18c47f4bea..9b62eb68b2 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -22,7 +22,6 @@ #include "common/msg.h" #include "input/input.h" -#include "input/event.h" #import "osdep/macosx_application_objc.h" #include "osdep/macosx_compat.h" @@ -270,23 +269,9 @@ Application *mpv_shared_app(void) } } - -- (void)handleFilesArray:(NSArray *)files -{ - size_t num_files = [files count]; - char **files_utf8 = talloc_array(NULL, char*, num_files); - [files enumerateObjectsUsingBlock:^(id obj, NSUInteger i, BOOL *_){ - char *filename = (char *)[obj UTF8String]; - size_t bytes = [obj lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - files_utf8[i] = talloc_memdup(files_utf8, filename, bytes + 1); - }]; - mp_event_drop_files(_eventsResponder.inputContext, num_files, files_utf8); - talloc_free(files_utf8); -} - - (void)handleFiles { - [self handleFilesArray:self.files]; + [_eventsResponder handleFilesArray:self.files]; } @end diff --git a/osdep/macosx_application_objc.h b/osdep/macosx_application_objc.h index d203711054..bc2ff8eee7 100644 --- a/osdep/macosx_application_objc.h +++ b/osdep/macosx_application_objc.h @@ -23,7 +23,6 @@ - (void)initialize_menu; - (void)registerSelector:(SEL)selector forKey:(MPMenuKey)key; - (void)stopPlayback; -- (void)handleFilesArray:(NSArray *)files; @property(nonatomic, retain) NSMutableDictionary *menuItems; @property(nonatomic, retain) NSArray *files; diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m index 0b3eeb1d48..97ef93f405 100644 --- a/osdep/macosx_events.m +++ b/osdep/macosx_events.m @@ -26,6 +26,7 @@ #import #include "talloc.h" +#include "input/event.h" #include "input/input.h" #include "input/keycodes.h" // doesn't make much sense, but needed to access keymap functionality @@ -410,4 +411,18 @@ void cocoa_set_input_context(struct input_ctx *input_context) return nil; } + +- (void)handleFilesArray:(NSArray *)files +{ + size_t num_files = [files count]; + char **files_utf8 = talloc_array(NULL, char*, num_files); + [files enumerateObjectsUsingBlock:^(id obj, NSUInteger i, BOOL *_){ + char *filename = (char *)[obj UTF8String]; + size_t bytes = [obj lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + files_utf8[i] = talloc_memdup(files_utf8, filename, bytes + 1); + }]; + mp_event_drop_files(_inputContext, num_files, files_utf8); + talloc_free(files_utf8); +} + @end diff --git a/osdep/macosx_events_objc.h b/osdep/macosx_events_objc.h index 575f336f87..e9b14ed079 100644 --- a/osdep/macosx_events_objc.h +++ b/osdep/macosx_events_objc.h @@ -30,6 +30,8 @@ struct input_ctx; /// Blocks until inputContext is present. - (void)waitForInputContext; +- (void)handleFilesArray:(NSArray *)files; + @property(nonatomic, assign) struct input_ctx *inputContext; @end diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 094236884b..6837a062d4 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -30,7 +30,7 @@ #include "osdep/macosx_compat.h" #include "osdep/macosx_application.h" #include "osdep/macosx_application_objc.h" -#include "osdep/macosx_events.h" +#include "osdep/macosx_events_objc.h" #include "config.h" @@ -753,7 +753,7 @@ void *vo_cocoa_cgl_pixel_format(struct vo *vo) - (void)handleFilesArray:(NSArray *)files { - [mpv_shared_app() handleFilesArray:files]; + [[EventsResponder sharedInstance] handleFilesArray:files]; } - (void)didChangeWindowedScreenProfile:(NSScreen *)screen