Subject: bug#30929: 26.0.91; Text drag and drop does not work

From: Nick Helm <[email-masked]>
Date: Mon, 09 Apr 2018 13:51:58 +1200

On Sun, 08 Apr 2018 at 03:01:19 +1200, Alan Third wrote:

> On Wed, Mar 28, 2018 at 10:20:13PM +1300, Nick Helm wrote:
>> > It’s setting the actual modifier keys, so when a user changes those
>> > keys’ settings this breaks.
>> >
>> > You can also set these flags by using the actual modifier keys.
>> >
>> > This looks like it matches up with what Apple expect you to do, but it
>> > doesn’t seem to match up with Emacs’s event handling very well. 
>> 
>> That looks about right to me too, it least it matches the general
>> approach in the docs.
>> 
>> I had a go at mapping the hardware modifiers to Emacs events (and
>> existing bindings) for each drag type and DragOperation mask. Patch
>> attached. This doesn't support the ns-right-*-modifiers yet, but they
>> should be pretty easy to add if you want to go this way.

> I’ve been thinking about this and I’m not entirely sure it’s a good
> idea to expose these modifier presses to Emacs. At least not by
> default.

For what it's worth, I think this is a much better idea. It's a
significant change from what we have now though.

> ns-drag-n-drop is perfectly capable of determining what action to take
> by examining what it’s been passed in the event. 

Based solely on the received operation mask (which may include the
user's OS-level modifers) and the data type sitting on the pb, right?

> This does mean that the modifier presses aren’t customisable, but they
> will always match the OS default at least.

Isn't that a good thing in this case? If dnd is considered an OS-level
event, then adding customisable modifier bindings was actually the wrong
thing to do.

> If there’s a good use case for allowing these modifiers to leak
> through then I suggest we make it customisable. 

Personally, I don't see a need. I think it's better to just do what the
user expects, which is what I think you're proposing. Experts can still
intercept the event in Lisp (BTW, it's interesting to note that the
mac-port doesn't expose incoming dnd events to Lisp at all and silently
ignores all the modifiers).

If the dnd code gets a rewrite, it would be nice to add support for
Emacs as the dragging source as well as a few nicities like mouse
pointer overlays on copy operations etc.

I'm guessing the boat has well and truly sailed for such major tweaks in
Emacs 26 though. Instead, would it make sense to change the default
binding on macOS so at least basic (unmodified) text dnd works out of
the box for the upcoming release?