summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2020-02-25 22:49:40 -0600
committerrcombs <rcombs@rcombs.me>2020-05-26 20:55:23 -0500
commit4b64c7a857bab71c5a557c7bd150891bede5f338 (patch)
tree4933bc6a24c01016d004332526432b87bd212bf6
parent4b854fab6821a10676e4134ef18a7f576a38debb (diff)
downloadmpv-rcombs/macos-fixes.tar.bz2
mpv-rcombs/macos-fixes.tar.xz
Cocoa: fix pasteboard deprecation warningsrcombs/macos-fixes
-rw-r--r--video/out/cocoa/events_view.m50
1 files changed, 39 insertions, 11 deletions
diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m
index 2cfe3f2fda..eb0bccec38 100644
--- a/video/out/cocoa/events_view.m
+++ b/video/out/cocoa/events_view.m
@@ -35,12 +35,40 @@
@synthesize tracker = _tracker;
@synthesize hasMouseDown = _mouse_down;
+#if !HAVE_MACOS_10_13_FEATURES
+typedef NSString* NSPasteboardType;
+#endif
+
+static NSPasteboardType filenameType(void)
+{
+#if HAVE_MACOS_10_13_FEATURES
+ if (@available(macOS 10.13, *)) {
+ return NSPasteboardTypeFileURL;
+ } else
+#endif
+ {
+ return (NSPasteboardType)kUTTypeFileURL;
+ }
+}
+
+static NSPasteboardType urlType(void)
+{
+#if HAVE_MACOS_10_13_FEATURES
+ if (@available(macOS 10.13, *)) {
+ return NSPasteboardTypeURL;
+ } else
+#endif
+ {
+ return (NSPasteboardType)kUTTypeURL;
+ }
+}
+
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
- [self registerForDraggedTypes:@[NSFilenamesPboardType,
- NSURLPboardType]];
+ [self registerForDraggedTypes:@[filenameType(),
+ urlType()]];
[self setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
}
return self;
@@ -305,8 +333,8 @@
{
NSPasteboard *pboard = [sender draggingPasteboard];
NSArray *types = [pboard types];
- if ([types containsObject:NSFilenamesPboardType] ||
- [types containsObject:NSURLPboardType]) {
+ if ([types containsObject:filenameType()] ||
+ [types containsObject:urlType()]) {
return NSDragOperationCopy;
} else {
return NSDragOperationNone;
@@ -316,13 +344,13 @@
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard = [sender draggingPasteboard];
- if ([[pboard types] containsObject:NSFilenamesPboardType]) {
- NSArray *pbitems = [pboard propertyListForType:NSFilenamesPboardType];
- [self.adapter handleFilesArray:pbitems];
- return YES;
- } else if ([[pboard types] containsObject:NSURLPboardType]) {
- NSURL *url = [NSURL URLFromPasteboard:pboard];
- [self.adapter handleFilesArray:@[[url absoluteString]]];
+ if ([[pboard types] containsObject:filenameType()] ||
+ [[pboard types] containsObject:urlType()]) {
+ NSArray *pbitems = [pboard readObjectsForClasses:@[[NSURL class]] options:nil];
+ NSMutableArray *stringArray = [NSMutableArray new];
+ for (NSURL *url in pbitems)
+ [stringArray addObject:[url absoluteString]];
+ [self.adapter handleFilesArray:stringArray];
return YES;
}
return NO;