summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2020-02-25 22:49:40 -0600
committerrcombs <rcombs@rcombs.me>2020-06-17 21:09:31 -0500
commit8102b83cb235b4b37f1e8897acbc99d67ae073b1 (patch)
treebed08415559226620586caacdc9f87e48b062412
parentb020cb028eaab44823951ead4984d48321f38ee9 (diff)
downloadmpv-8102b83cb235b4b37f1e8897acbc99d67ae073b1.tar.bz2
mpv-8102b83cb235b4b37f1e8897acbc99d67ae073b1.tar.xz
Cocoa: fix pasteboard deprecation warnings
-rw-r--r--video/out/cocoa/events_view.m52
-rw-r--r--wscript5
2 files changed, 46 insertions, 11 deletions
diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m
index 2cfe3f2fda..8d00b1b1b8 100644
--- a/video/out/cocoa/events_view.m
+++ b/video/out/cocoa/events_view.m
@@ -22,6 +22,8 @@
#include "video/out/cocoa_common.h"
#include "events_view.h"
+#include "config.h"
+
@interface MpvEventsView()
@property(nonatomic, assign) BOOL hasMouseDown;
@property(nonatomic, retain) NSTrackingArea *tracker;
@@ -35,12 +37,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 +335,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 +346,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;
diff --git a/wscript b/wscript
index 1c45e20a27..2c469bfc34 100644
--- a/wscript
+++ b/wscript
@@ -815,6 +815,11 @@ standalone_features = [
'deps': 'cocoa',
'func': check_macos_sdk('10.12.2')
}, {
+ 'name': '--macos-10-13-features',
+ 'desc': 'macOS 10.13 SDK Features',
+ 'deps': 'cocoa',
+ 'func': check_macos_sdk('10.13')
+ }, {
'name': '--macos-10-14-features',
'desc': 'macOS 10.14 SDK Features',
'deps': 'cocoa',