CLIPBOARD selection doesn't save content

Glynn Clements glynn at
Sat Apr 3 16:32:26 PDT 2010

Quintus wrote:

> Now, I'm trying to
> implement writing, only for the CLIPBOARD selection, since that one's
> contents should persist across program death.I know, I have to acquire
> CLIPBOARD's ownership; afterwards the xclipboard process would send me a
> TARGETS request asking me what data I provide. I answer this with
> TARGETS, UTF8_STRING, XA_STRING and TIMESTAMP, which should cause
> xclipboard to ask me for UTF8_STRING or XA_STRING, but... It doesn't.
> Instead, if I try to paste the copied text into an application, my
> program gets a request from that application rather than from
> xclipboard. Further more, when my program finishes, the data is gone. So
> I suppose, something is wrong at my side.

X itself doesn't have a persistent clipboard. If you want the
clipboard contents to persist after the application terminates, a
clipboard manager must be running.

Clipboard managers are something of a mixed blessing, so not everyone
uses one. Whether a clipboard manager is in use and its exact
behaviour are dependent upon the desktop environment. All that your
program can do is to implement the relevant protocols; the rest is
beyond its control.

Apart from implementing the CLIPBOARD selection, the application
should implement the SAVE_TARGETS protocol for optimum behaviour with
modern clipboard managers. For details, see:

If a compliant clipboard manager is running, this should cause it to
take over the clipboard (ownership and contents) from the terminating

Older clipboard managers (and clients) don't support the SAVE_TARGETS
protocol, which means that the clipboard manager must retrieve the
clipboard contents whenever the clipboard changes, which can be
inefficient if the data is large and/or if there are many targets
(some of which may be computationally expensive to generate).

Glynn Clements <glynn at>

More information about the xorg mailing list