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

From: Alan Third <[email-masked]>
Date: Sun, 25 Mar 2018 12:57:32 +0100

On Sun, Mar 25, 2018 at 01:28:11AM +1300, Nick Helm wrote:
> 
> On MacOS text drag-n-drop does not work out of the box. Also a dnd 
> event seems to be bound to different functions depending on modifier 
> settings.
> 
> Emacs -Q
> 
> C-h v ns-command-modifier -> "It's value is super"
> 
> C-h k <drag and drop external text> 
>   -> "<M-s-drag-n-drop> is undefined"
> 
> (setq ns-command-modifier 'none)
> C-h k <drag and drop external text>
>   -> "<M-drag-n-drop> at that spot runs the command
>       ns-drag-n-drop-as-text"
> 
> (setq ns-command-modifier 'control)
> C-h k <drag and drop external text>
>   -> "<C-M-drag-n-drop> at that spot runs the command
>       ns-drag-n-drop-as-text-other-frame"

Looks like this is how the modifiers are set in performDragOperation

  if (! (op & (NSDragOperationMove|NSDragOperationDelete)) &&
      // URL drags contain all operations (0xf), don't allow all to be set.
      (op & 0xf) != 0xf)
    {
      if (op & NSDragOperationLink)
        modifiers |= NSEventModifierFlagControl;
      if (op & NSDragOperationCopy)
        modifiers |= NSEventModifierFlagOption;
      if (op & NSDragOperationGeneric)
        modifiers |= NSEventModifierFlagCommand;
    }

  modifiers = EV_MODIFIERS2 (modifiers);

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. I’ll
have to read up on it and have a think to see if I can work out a
solution.
-- 
Alan Third