summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2014-01-04 17:17:33 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2014-01-04 17:29:53 +0100
commit1e988c595bd4eb46c4df19cc33faf5d69a7d2ef1 (patch)
treea874ac727ca29dacca184a83f31cb26a7e822aa0 /video
parent69d44d992c685fd2e0a795448371d209d4522f44 (diff)
downloadmpv-1e988c595bd4eb46c4df19cc33faf5d69a7d2ef1.tar.bz2
mpv-1e988c595bd4eb46c4df19cc33faf5d69a7d2ef1.tar.xz
cocoa: handle files drag and drop on the player video view
Diffstat (limited to 'video')
-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
4 files changed, 29 insertions, 1 deletions
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