Subject: Re: bug#43470: 27.1; Drag and Drop not working properly in 27.1 on OSX

From: Daniel Martín <[email-masked]>
Date: Thu, 17 Sep 2020 20:12:56 +0200

Alan Third <[email-masked]> writes:
>
> Confirmed.
>
> Annoyingly I could've sworn this worked just a few months ago. I
> wonder if Apple have changed something in their libraries to
> completely deprecate the old methods.
>
> Anyway, It'll need to be almost completely rewritten (again!).

Hi, Alan:

Could it be caused by an incomplete rename done at
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=9624f609493da7c08016ba00d6895bad0fe26a0e?

The following patch fixes the reported bug for me on 10.15.6 and Emacs
28.0.50, and also fixes some compilation warnings as well:

diff --git a/src/nsterm.m b/src/nsterm.m
index 26059ab67c..c40f790e0f 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -5648,7 +5648,7 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes.
   ns_drag_types = [[NSArray arrayWithObjects:
                             NSPasteboardTypeString,
                             NSPasteboardTypeTabularText,
-                            NSFilenamesPboardType,
+                            NSPasteboardTypeFileURL,
                             NSPasteboardTypeURL, nil] retain];
 
   /* If fullscreen is in init/default-frame-alist, focus isn't set
@@ -8592,10 +8592,7 @@ -(BOOL)performDragOperation: (id <NSDraggingInfo>) sender
     {
       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.  */
-  else if ([type isEqualToString: NSFilenamesPboardType])
+  else if ([type isEqualToString: NSPasteboardTypeFileURL])
     {
       NSArray *files;
       NSEnumerator *fenum;
@@ -8610,7 +8607,7 @@ -(BOOL)performDragOperation: (id <NSDraggingInfo>) sender
       while ( (file = [fenum nextObject]) )
         strings = Fcons ([file lispString], strings);
     }
-  else if ([type isEqualToString: NSURLPboardType])
+  else if ([type isEqualToString: NSPasteboardTypeURL])
     {
       NSURL *url = [NSURL URLFromPasteboard: pb];
       if (url == nil) return NO;
@@ -8619,8 +8616,8 @@ -(BOOL)performDragOperation: (id <NSDraggingInfo>) sender
 
       strings = list1 ([[url absoluteString] lispString]);
     }
-  else if ([type isEqualToString: NSStringPboardType]
-           || [type isEqualToString: NSTabularTextPboardType])
+  else if ([type isEqualToString: NSPasteboardTypeString]
+           || [type isEqualToString: NSPasteboardTypeTabularText])
     {
       NSString *data;