summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--osdep/macosx_application_objc.h1
-rw-r--r--video/out/cocoa/mpvadapter.h1
-rw-r--r--video/out/cocoa/view.h2
-rw-r--r--video/out/cocoa/view.m21
-rw-r--r--video/out/cocoa_common.m6
5 files changed, 30 insertions, 1 deletions
diff --git a/osdep/macosx_application_objc.h b/osdep/macosx_application_objc.h
index c130e51eba..3a3b75335f 100644
--- a/osdep/macosx_application_objc.h
+++ b/osdep/macosx_application_objc.h
@@ -36,6 +36,7 @@
- (void)initialize_menu;
- (void)registerSelector:(SEL)selector forKey:(MPMenuKey)key;
- (void)stopPlayback;
+- (void)handleFilesArray:(NSArray *)files;
@property(nonatomic, assign) struct input_ctx *inputContext;
@property(nonatomic, retain) EventsResponder *eventsResponder;
diff --git a/video/out/cocoa/mpvadapter.h b/video/out/cocoa/mpvadapter.h
index b1a13d5ace..f691f4d824 100644
--- a/video/out/cocoa/mpvadapter.h
+++ b/video/out/cocoa/mpvadapter.h
@@ -25,6 +25,7 @@
- (void)putAxis:(int)mpkey delta:(float)delta;
- (void)putCommand:(char*)cmd;
- (void)performAsyncResize:(NSSize)size;
+- (void)handleFilesArray:(NSArray *)files;
- (BOOL)isInFullScreenMode;
- (NSSize)videoSize;
diff --git a/video/out/cocoa/view.h b/video/out/cocoa/view.h
index 71d58a3348..490af221b1 100644
--- a/video/out/cocoa/view.h
+++ b/video/out/cocoa/view.h
@@ -18,7 +18,7 @@
#import <Cocoa/Cocoa.h>
#import "video/out/cocoa/mpvadapter.h"
-@interface MpvVideoView : NSView {
+@interface MpvVideoView : NSView <NSDraggingDestination> {
BOOL hasMouseDown;
}
@property(nonatomic, retain) MpvCocoaAdapter *adapter;
diff --git a/video/out/cocoa/view.m b/video/out/cocoa/view.m
index 45f0f17b06..9fc7506fc6 100644
--- a/video/out/cocoa/view.m
+++ b/video/out/cocoa/view.m
@@ -30,6 +30,14 @@
@synthesize adapter = _adapter;
@synthesize tracker = _tracker;
+- (id)initWithFrame:(NSRect)frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ [self registerForDraggedTypes:@[NSFilenamesPboardType]];
+ }
+ return self;
+}
+
- (void)setFullScreen:(BOOL)willBeFullscreen
{
if (willBeFullscreen && ![self isInFullScreenMode]) {
@@ -223,4 +231,17 @@
[self.adapter performAsyncResize:[self frameInPixels].size];
[self.adapter setNeedsResize];
}
+
+- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
+{
+ return NSDragOperationEvery;
+}
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
+{
+ NSPasteboard *pboard = [sender draggingPasteboard];
+ NSArray *pbitems = [pboard propertyListForType:NSFilenamesPboardType];
+ [self.adapter handleFilesArray:pbitems];
+ return YES;
+}
@end
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 748673cf15..15305aa93f 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -29,6 +29,7 @@
#include "osdep/macosx_compat.h"
#include "osdep/macosx_application.h"
+#include "osdep/macosx_application_objc.h"
#include "osdep/macosx_events.h"
#include "config.h"
@@ -660,4 +661,9 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
struct vo_cocoa_state *s = self.vout->cocoa;
return s->fs_screen;
}
+
+- (void)handleFilesArray:(NSArray *)files
+{
+ [mpv_shared_app() handleFilesArray:files];
+}
@end