X11 client fails keeping ownership of CLIPBOARD

2025-03-30 Thread Travis Shelton
Hello!
I'm trying to run a very basic program about X11 clipboard. It is
(unmodified) the code with title `Program 3: Owning a selection' in
this page:

 

I build it on `Ubuntu 22.04.5 LTS` with this Desktop Environment

KDE Plasma Version: 5.24.7
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.3
Graphics Platform: X11

using

gcc -Wall -Wextra -o program3 program3.c -lX11`

If I then run it on the same system, which uses X11 as its server,
I obtain:

Requestor: 0x285
Denying request of type 'TARGETS'
Requestor: 0x4e9
Denying request of type 'TARGETS'
Requestor: 0x3400013
Denying request of type 'TARGETS'
Requestor: 0x1e0005b
Denying request of type 'TARGETS'

Lost selection ownership

This occurs within less than a second, before I can act on the clipboard.

Using `xwininfo', each of the `requestors' is related to `Qt Clipboard 
Requestor Window'. Qt is probably part of my Desktop Environment.

I would like the above code to keep the ownership of `CLIPBOARD' for 
example until I "fill" the clipboard manually from any other program. Is
there some modification that can be done to accomplish this?

Thank you anyways,

Travis


Re: X11 client fails keeping ownership of CLIPBOARD

2025-03-30 Thread Lucas de Sena
On 2025-03-30, Travis Shelton wrote:

> This occurs within less than a second, before I can act on the clipboard.
> 
> Using `xwininfo', each of the `requestors' is related to `Qt Clipboard 
> Requestor Window'. Qt is probably part of my Desktop Environment.
> 
> I would like the above code to keep the ownership of `CLIPBOARD' for 
> example until I "fill" the clipboard manually from any other program. Is
> there some modification that can be done to accomplish this?

I do not have KDE around to confirm it, but that is probably because of
KDE's clipboard manager.  A clipboard manager can “steal” the CLIPBOARD
selection from other clients, especially if they do not support the
SAVE_TARGETS mechanism for clipboard managers.

You can try to terminate/kill KDE's clipboard manager while you are doing
your experiments with the CLIPBOARD selection.  Or you can edit the code
to use the PRIMARY selection instead, which clipboard managers (usually)
do not mess with.

-- 
Lucas de Sena.