Recent

Author Topic: Copy-to-clipboard, text clears after exiting my app  (Read 14243 times)

KarenT

  • Full Member
  • ***
  • Posts: 120
Re: Copy-to-clipboard, text clears after exiting my app
« Reply #15 on: May 21, 2017, 08:40:01 pm »
All too hard for the time I have available and the Timer is solving it fine. The program is for my own use so I can live with it until I see a native-working option for Linux/Lazarus.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Copy-to-clipboard, text clears after exiting my app
« Reply #16 on: May 21, 2017, 09:11:44 pm »
Just install a clipboard manager. It's WM/DE problem, not application problem.

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: Copy-to-clipboard, text clears after exiting my app
« Reply #17 on: May 22, 2017, 10:12:53 am »
I wonder if Kylix is still available some where.
Yes, but I really wouldn't recommend using Kylix any more. It is just too out of date these days (compiler and IDE), and CLX uses a terribly old Qt (that just looks crap - doesn't even support anti-aliased text).

   http://geldenhuys.co.uk/~graemeg/kylix3_openedition.tar.gz

Rather use fpGUI or MSEgui for true cross-platform applications, or look at LCL with its inconsistencies across platforms.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: Copy-to-clipboard, text clears after exiting my app
« Reply #18 on: May 22, 2017, 10:24:33 am »
after my app exits, other apps don't see this text. Clipboard empty. Why?
It is standard X11 behaviour, and is actually more efficient than Windows clipboard. Why, because on Windows, if you copy something to the clipboard you instantly get a copy, and thus it uses memory (RAM) to store that copy. On X11 when you copy something to the clipboard, it simply notifies the windowing system of the window that has content available, but no copy actually exists in RAM yet. Once once a target applications requests that content (via a Paste action), does it query the source window/application for the contents. This explains why you clipboard is empty, because that source application has already terminated.

Now some newer Window Managers in X11 support clipboard managers that can go against the X11 design. What these clipboard managers do, is become the "source" of the clipboard content, instead of the original source application. This clipboard managers keep running while the window manager runs, so you never get the "out of scope" situation.

If you want to see the technical details in how this is implemented, so applications (actually the GUI framework) can take advantage of such clipboard managers, take a look at how it was implemented in fpGUI Toolkit.

Quote
commit c2af2a386efef5d52db20482e81748fc36aedb91
Author: Andrew Haines <andrewd207@****>
Date:   Wed Apr 24 17:24:50 2013 +0200

    Persistent clipboard support under X11.
   
    Some desktop environments or window managers include support for a clipboard
    manager. This clipboard manager can make the content of the clipboard persistent
    even after the source application closed down.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Copy-to-clipboard, text clears after exiting my app
« Reply #19 on: May 22, 2017, 11:12:18 am »
There is the small complication that keeping data on the clipboard after exiting a process is technically a memory leak.
That's also the reason that X11 developers won't fix it. It is unsafe behavior.
A clipboard manager merely takes ownership of the data but clipboards are inherently not secure unless the manager encrypts and decrypts the data.

This is a known Windows design flaw, although even on Windows the clipboard data is only accessible locally after process termination.
Specialize a type, not a var.

KarenT

  • Full Member
  • ***
  • Posts: 120
Re: Copy-to-clipboard, text clears after exiting my app
« Reply #20 on: May 22, 2017, 06:58:08 pm »
Just install a clipboard manager. It's WM/DE problem, not application problem.

But, I shouldn't have to, gedit handles it and leaves text on the Clipboard after closing. But not an issue as I have mentioned, I'll just go with the Timer. :)

 

TinyPortal © 2005-2018