]> asedeno.scripts.mit.edu Git - PuTTY.git/commit - unix/unix.h
Initial support for clipboard on OS X.
authorSimon Tatham <anakin@pobox.com>
Wed, 2 Sep 2015 20:37:33 +0000 (21:37 +0100)
committerSimon Tatham <anakin@pobox.com>
Wed, 2 Sep 2015 20:54:03 +0000 (21:54 +0100)
commita50da0e30952c4edfacebb1ba01b5b91b0fee63c
tree31d40db0aa81d7cf8e0e264a6ceaf4357f321b8b
parent0de1ac95e5fe91e71061120de314b9bd852c2303
Initial support for clipboard on OS X.

Rather than trying to get my existing hugely complicated X-style
clipboard code to somehow work with the Quartz GTK back end, I've
written an entirely new and much simpler alternative clipboard handler
usnig the higher-leve GtkClipboard interface. It assumes all clipboard
text can be converted to and from UTF-8 sensibly (which isn't a good
assumption on all front ends, but on OS X I think it's reasonable),
and it talks to GDK_SELECTION_CLIPBOARD rather than PRIMARY, which is
the only clipboard OS X has.

I had to do a fiddly thing to cope with the fact that each call to
gtk_clipboard_set_with_data caused a call to the clipboard clear
function left over from the previous set of data, so I had to avoid
mistaking that for a clipboard-clear for the _new_ data and
immediately deselecting it. I did that by allocating a distinct
placeholder object in memory for each instance of the copy operation,
so that I can tell whether a clipboard-clear is for the current copy
or a previous one.

This is only very basic support which demonstrates successful copying
and pasting is at least possible. For a sensible OS X implementation
we'll need a more believable means of generating a paste UI action
(it's quite easy to find a Mac on which neither Shift-Ins nor the
third mouse button even exists!). Also, after the trouble I had with
the clipboard-clear event, it's a bit annoying to find that it
_doesn't_ seem to get called when another application becomes the
clipboard owner. That may just be something we have to put up with, if
I can't find any reason why it's failing.
unix/gtkwin.c
unix/unix.h