[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Alan Third
Subject: bug#30929: 26.0.91; Text drag and drop does not work
Date: Thu, 26 Apr 2018 21:44:42 +0100
User-agent: Mutt/1.9.3 (2018-01-21)

On Thu, Apr 26, 2018 at 11:16:32AM +1200, Nick Helm wrote:
> My main problem is the bewildering number of different data types that
> have be to handled, in particular casting every possibility from 
> ObjC -> C -> Lisp and interpreting them at the end.

Can we simplify this? For example, the current code only supports
‘file’, ‘URL’ and ‘text’. I don’t think we need to worry about more
than that. At least for now.

I also don’t think you need to worry about converting many different
types. When we pass the data to lisp we *always* want it in plain
text, so if it’s a file then the filepath, a URL is plaintext anyway,
as is text.

Anything else we can ignore or reject.

If we did want to add other types, like say images, then we would
still want to accept only a plaintext description, like a filepath or

FWIW, the current code appears to handle this. But I may be completely
misunderstanding what you’re telling me.

> Then there's backwards compatibility, as not all these things work the
> same way on older versions of macOS. It all gets pretty convoluted. 

Remember we only support back to 10.6, so it may not be too bad.
Either way, we can deal with it as we go. Just make sure to mark where
you think there may be issues in the code. In the worst case we can
continue to use the current code, modified somewhat, in older versions
of macOS.

> Other related stuff doesn't work the way I expect either. I'd planned to
> highlight the target Emacs window with a border to give the user better
> feedback about the drop location. That's a pretty basic thing to do. But
> there's something odd about Emacs's NSView implementation, which means
> any code using drawRect is either ignored or affects all the objects in
> the view at once, as if everything is drawn onto one flat canvas.

It is pretty much drawn onto a single flat canvas. I think this
because of the way Emacs draws. It is annoying.

Do you need to use ns_focus and ns_unfocus? These select and unselect
an NSRect you want to update. If you search through nsterm.m for
ns_focus you’ll be able to find other places where we draw to the

> I also wanted to use draggingUpdate to update point during the dragging
> session, in order to give the user better control over the insertion
> point. Again, pretty rudimentary stuff. But I'm embarrassed to admit, I
> can't even work out how to move point from C, much less from ObjC, and
> much much less make it follow the mouse mid-dragging session.

I’m not sure how you’d implement that, nor whether it’s actually a
good idea: you could accidentally move point by dragging over the
wrong window. But you should be able to use lisp functions from C, for
example goto-char is Fgoto_char, but you need to remember to convert
the C int type to a lisp number type before passing it in. (see

I don’t think this stuff is terribly easy, mostly I’ve got to know it
through modifying existing code (and messing it up).

> As far as I can tell, Emacs on free platforms doesn't support being the
> dragging source (either to other apps or within Emacs itself), so
> I didn't look at that option at all.

If it works in GNUstep, and I think this must, then we’re home free as
it counts as a Free platform.


I’ve got a GNUstep build virtual machine, so I can make sure it all
works OK.

If you need any help, or don’t understand something, please feel free
to ask.
Alan Third

reply via email to

[Prev in Thread] Current Thread [Next in Thread]