diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2021-01-10 17:05:18 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2021-01-18 12:52:08 +0100 |
commit | 36d33776c21b3765b8a611f09ae7d86417abee8a (patch) | |
tree | d7ad363db5ed0fff1610e60d89a808c05402fc4f | |
parent | 3b4050154e3f72c06501cd9a5ad83841b92c7bd6 (diff) | |
download | emacs-36d33776c21b3765b8a611f09ae7d86417abee8a.tar.gz |
Avoid macOS NSFilenamesPboardType warning (bug#33035)
* src/nsterm.h (NS_USE_NSPasteboardTypeFileURL): New #define.
* src/nsterm.m (ns_term_init):
([EmacsView performDragOperation:]):
* src/nsselect.m (ns_string_to_symbol):
(nxatoms_of_nsselect):
NSFilenamesPboardType was deprecated in macOS 10.14; use
NSPasteboardTypeFileURL instead when available.
-rw-r--r-- | src/nsselect.m | 15 | ||||
-rw-r--r-- | src/nsterm.h | 9 | ||||
-rw-r--r-- | src/nsterm.m | 21 |
3 files changed, 40 insertions, 5 deletions
diff --git a/src/nsselect.m b/src/nsselect.m index 27db9248e46..5ab3ef77fec 100644 --- a/src/nsselect.m +++ b/src/nsselect.m @@ -78,7 +78,13 @@ ns_string_to_symbol (NSString *t) return QSECONDARY; if ([t isEqualToString: NSPasteboardTypeString]) return QTEXT; - if ([t isEqualToString: NSFilenamesPboardType]) + if ([t isEqualToString: +#if NS_USE_NSPasteboardTypeFileURL != 0 + NSPasteboardTypeFileURL +#else + NSFilenamesPboardType +#endif + ]) return QFILE_NAME; if ([t isEqualToString: NSPasteboardTypeTabularText]) return QTEXT; @@ -467,7 +473,12 @@ nxatoms_of_nsselect (void) [NSNumber numberWithLong:0], NXPrimaryPboard, [NSNumber numberWithLong:0], NXSecondaryPboard, [NSNumber numberWithLong:0], NSPasteboardTypeString, - [NSNumber numberWithLong:0], NSFilenamesPboardType, + [NSNumber numberWithLong:0], +#if NS_USE_NSPasteboardTypeFileURL != 0 + NSPasteboardTypeFileURL, +#else + NSFilenamesPboardType, +#endif [NSNumber numberWithLong:0], NSPasteboardTypeTabularText, nil] retain]; } diff --git a/src/nsterm.h b/src/nsterm.h index 2c9d8e85ba9..eae1d0725ea 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -39,6 +39,15 @@ typedef CGFloat EmacsCGFloat; typedef float EmacsCGFloat; #endif +/* NSFilenamesPboardType is deprecated in macOS 10.14, but + NSPasteboardTypeFileURL is only available in 10.13 (and GNUstep + probably lacks it too). */ +#if defined NS_IMPL_COCOA && MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 +#define NS_USE_NSPasteboardTypeFileURL 1 +#else +#define NS_USE_NSPasteboardTypeFileURL 0 +#endif + /* ========================================================================== Trace support diff --git a/src/nsterm.m b/src/nsterm.m index 2defb9e2eec..c5815ce8d10 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5602,7 +5602,11 @@ ns_term_init (Lisp_Object display_name) ns_drag_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, NSPasteboardTypeTabularText, +#if NS_USE_NSPasteboardTypeFileURL != 0 + NSPasteboardTypeFileURL, +#else NSFilenamesPboardType, +#endif NSPasteboardTypeURL, nil] retain]; /* If fullscreen is in init/default-frame-alist, focus isn't set @@ -8533,9 +8537,19 @@ not_in_argv (NSString *arg) { return NO; } - /* FIXME: NSFilenamesPboardType is deprecated in 10.14, but the - NSURL method can only handle one file at a time. Stick with the - existing code at the moment. */ +#if NS_USE_NSPasteboardTypeFileURL != 0 + else if ([type isEqualToString: NSPasteboardTypeFileURL]) + { + type_sym = Qfile; + + NSArray *urls = [pb readObjectsForClasses: @[[NSURL self]] + options: nil]; + NSEnumerator *uenum = [urls objectEnumerator]; + NSURL *url; + while ((url = [uenum nextObject])) + strings = Fcons ([[url path] lispString], strings); + } +#else // !NS_USE_NSPasteboardTypeFileURL else if ([type isEqualToString: NSFilenamesPboardType]) { NSArray *files; @@ -8551,6 +8565,7 @@ not_in_argv (NSString *arg) while ( (file = [fenum nextObject]) ) strings = Fcons ([file lispString], strings); } +#endif // !NS_USE_NSPasteboardTypeFileURL else if ([type isEqualToString: NSPasteboardTypeURL]) { NSURL *url = [NSURL URLFromPasteboard: pb]; |