mirror of https://github.com/mpv-player/mpv
cocoa: fix pasteboard deprecation warnings
This commit is contained in:
parent
fcf7e1f83c
commit
761d4c8353
|
@ -22,6 +22,8 @@
|
||||||
#include "video/out/cocoa_common.h"
|
#include "video/out/cocoa_common.h"
|
||||||
#include "events_view.h"
|
#include "events_view.h"
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
@interface MpvEventsView()
|
@interface MpvEventsView()
|
||||||
@property(nonatomic, assign) BOOL hasMouseDown;
|
@property(nonatomic, assign) BOOL hasMouseDown;
|
||||||
@property(nonatomic, retain) NSTrackingArea *tracker;
|
@property(nonatomic, retain) NSTrackingArea *tracker;
|
||||||
|
@ -35,12 +37,40 @@
|
||||||
@synthesize tracker = _tracker;
|
@synthesize tracker = _tracker;
|
||||||
@synthesize hasMouseDown = _mouse_down;
|
@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
|
- (id)initWithFrame:(NSRect)frame
|
||||||
{
|
{
|
||||||
self = [super initWithFrame:frame];
|
self = [super initWithFrame:frame];
|
||||||
if (self) {
|
if (self) {
|
||||||
[self registerForDraggedTypes:@[NSFilenamesPboardType,
|
[self registerForDraggedTypes:@[filenameType(),
|
||||||
NSURLPboardType]];
|
urlType()]];
|
||||||
[self setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
|
[self setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
@ -305,8 +335,8 @@
|
||||||
{
|
{
|
||||||
NSPasteboard *pboard = [sender draggingPasteboard];
|
NSPasteboard *pboard = [sender draggingPasteboard];
|
||||||
NSArray *types = [pboard types];
|
NSArray *types = [pboard types];
|
||||||
if ([types containsObject:NSFilenamesPboardType] ||
|
if ([types containsObject:filenameType()] ||
|
||||||
[types containsObject:NSURLPboardType]) {
|
[types containsObject:urlType()]) {
|
||||||
return NSDragOperationCopy;
|
return NSDragOperationCopy;
|
||||||
} else {
|
} else {
|
||||||
return NSDragOperationNone;
|
return NSDragOperationNone;
|
||||||
|
@ -316,13 +346,13 @@
|
||||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
NSPasteboard *pboard = [sender draggingPasteboard];
|
NSPasteboard *pboard = [sender draggingPasteboard];
|
||||||
if ([[pboard types] containsObject:NSFilenamesPboardType]) {
|
if ([[pboard types] containsObject:filenameType()] ||
|
||||||
NSArray *pbitems = [pboard propertyListForType:NSFilenamesPboardType];
|
[[pboard types] containsObject:urlType()]) {
|
||||||
[self.adapter handleFilesArray:pbitems];
|
NSArray *pbitems = [pboard readObjectsForClasses:@[[NSURL class]] options:nil];
|
||||||
return YES;
|
NSMutableArray *stringArray = [NSMutableArray new];
|
||||||
} else if ([[pboard types] containsObject:NSURLPboardType]) {
|
for (NSURL *url in pbitems)
|
||||||
NSURL *url = [NSURL URLFromPasteboard:pboard];
|
[stringArray addObject:[url absoluteString]];
|
||||||
[self.adapter handleFilesArray:@[[url absoluteString]]];
|
[self.adapter handleFilesArray:stringArray];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
|
|
5
wscript
5
wscript
|
@ -842,6 +842,11 @@ standalone_features = [
|
||||||
'desc': 'macOS 10.12.2 SDK Features',
|
'desc': 'macOS 10.12.2 SDK Features',
|
||||||
'deps': 'cocoa',
|
'deps': 'cocoa',
|
||||||
'func': check_macos_sdk('10.12.2')
|
'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',
|
'name': '--macos-10-14-features',
|
||||||
'desc': 'macOS 10.14 SDK Features',
|
'desc': 'macOS 10.14 SDK Features',
|
||||||
|
|
Loading…
Reference in New Issue