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

From: Daniel Martín <[email-masked]>
Date: Fri, 18 Sep 2020 14:00:16 +0200

Alan Third <[email-masked]> writes:

> IIRC (and I could definitely be wrong here) a simple find/replace
> breaks the ability to handle more than one file being dragged at a
> time, which is why I left it (it used to work fine even though it was
> flagged as deprecated).

You're right. I also misread the FIXME, which mentions this particular
problem. That part of the patch is not correct.

I think we need to use the same constant names as those that are
included in the ns_drag_types array, at least until we implement proper
support for the new pasteboard API. This means that three constant names
should be renamed in nsterm.m.

I've attached a new patch that implements this idea. I've tested the
following drag and drop operations work correctly after the patch is
applied:

- Drag a URL.
- Drag arbitrary text from another application.
- Drag tabular text from another application.
- Drag a couple of files from the OS file manager. It correctly creates
a couple of buffers in Emacs that visit those files.

>From 8d50e8c08600306a6355014d90eb21b1b15af59e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <[email-masked]>
Date: Fri, 18 Sep 2020 13:36:47 +0200
Subject: [PATCH] Use modern constant names for the NS pasteboard

Use the same pasteboard constant names defined in
ns_drag_types. (Bug#43470).

* src/nsterm.m: Rename NSURLPboardType to NSPasteboardTypeURL,
NSStringPboardType to NSPasteboardTypeString, and
NSTabularTextPboardType to NSPasteboardTypeTabularText
---
 src/nsterm.m | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index 26059ab67c..bab7a0abb9 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -8610,7 +8610,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 +8619,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;
 
-- 
2.28.0