Documentation for using the system clipboard ?

Grant Edwards grante at visi.com
Wed Mar 5 11:17:34 EST 2003


In article <pan.2003.03.05.16.36.02.349254.2082 at zonnet.nl>, jodocus wrote:
> On Wed, 05 Mar 2003 10:11:09 +0100, Eric Brunel wrote:

>> On XWindows, the clipboard just holds a reference to a text
>> managed by your application (sort of...), so the copied text
>> won't be available anymore if your application is closed.
> 
> Are you really sure about this?

Well, like Eric said: Sort of. 

It depends on the apps involved.  

Under X, there are selections and there are cut buffers.  

A "selection" doesn't contain any data, it's just an abstract
object the only useful property of which is who owns it. When
you want to paste from a selection, you tell the X server. The
X server sends an event to the owner of the selection telling
it to cough up some data and send it to you.  If that app isn't
running anymore (or just chooses to ignore the request), you
get no data.

A cut buffer OTOH, is a global container that actually can
contain data. Some apps also copy the selected data to a cut
buffer when a selection is made. Correspondingly, some apps
when told to paste will try to fetch the selection data first,
and if that fails they'll use the contents of the cut buffer as
a fallback.

> I have never noticed any text vanishing from the X selection
> after closing an application. Also, I can't recall ever reading
> about that in any discussion about how selections should be
> implemented in X.

If you're talking strictly about X11 selections, then yes,
they're only valid as long as the app that last owned the
selection is alive and willing to send data.  If an app grabs a
selection then dies, there's no selection owner from which the
X server can request data when you want to get the "contents"
of the selection.

However, most (but not all) X apps use a cut buffer as a
"fallback" mechanism so that you can get selected data from a
no-longer living selection owner.

-- 
Grant Edwards                   grante             Yow!  Yow! We're going to
                                  at               a new disco!
                               visi.com            




More information about the Python-list mailing list