... the answer to the topic of your post may be the following.
You have a program (GTK2) that reads a graphic file. The user can somehow modify it.
The image should be saved in the clipboard when the program is closed.
Solution scheme.
1. Create a simple utility for reading and sending an image to the clipboard. It is just a few lines of code.
2. When your program is closed, insert the code to run this utility, for example using TProcess.
This would be a very cumbersome solution:
- my program needs to know the path to the utility, so that it can be started
- the utility must be started in a way, that it continues to run, after its parent has stopped
- the utility would run never-ending in the background
- when my program is started one more time and exits one more time, it must detect, whether the utility is already running, to avoid to start it again and again
- in this case the already running utility must be triggered, to do it's job once again
- my program can be started more than once at the same time, which can make things not easier.
Of course everything of this is somehow "possible", but for me it's not worth the effort. I definitely don't wont to go a way like this.
As said multiple times, I search for a solution like unit 'fix_gtk_clipboard' but for graphical contents - or some kind of procedure FormClose() for the same purpose, which runs on
KDE Plasma Desktop (because for Gnome I still have a solution from jeremiah). This would be a *common* solution and very easy to use in every project :-)) That was the intention, why I started this Topic.
Linux desktop managers usually implement both gtk and qt. ie, Cinnamon is gtk but has support for qt though not full qt. KDE is qt and supports gtk though not full gtk. They will try to implement enough so the program will run but it is limited.
...
The clipboard in Linux is managed by X11 and historically when the program quit the clipboard was wiped to free memory, precious in those days. Desktop managers can hack around this and use their own version of a clipboard, KDE does this I think, or as gtk does and utilize the store feature that has been implemented in X11.
Thank you jeremiah for that infos (I did not know that) and for your continuous help.
I think it is possible to preserve the clipboard in qt though I do not know how much support Lazarus/Free Pascal have.
...
Search in your Lazarus/LCL/interfaces/qt5 source and check the bindings to see what is implemented. Best place to start if you want to preserve the clipboard in KDE and KDE might have their own implementation so scour them also.
I checked folder Lazarus/LCL/interfaces/qt5 which has more than 4 MB of source code in about 40 files. I have no idea what to do there. I have never heard of bindings and by google I found
https://en.wikipedia.org/wiki/Binding where I understood nothing. My knowledge about QT is near zero.
To solve this by myself is far beyond my horizon. That's why I'm asking for help in this Topic from someone who is familiar with the clipboard on KDE Plasma Desktop. If I should switch to another subforum for that please let me know and to which.