Tk Source Code

View Ticket
Login
Ticket UUID: c947c77eef1b5550f490c02c639cfd5c1d80293b
Title: Clipboard duration under x11
Type: RFE Version: All
Submitter: anonymous Created on: 2017-09-19 23:45:08
Subsystem: 52. [clipboard] Assigned To: nobody
Priority: 3 Low Severity: Minor
Status: Closed Last Modified: 2018-06-03 18:24:18
Resolution: Rejected Closed By: fvogel
    Closed on: 2018-06-03 18:24:18
Description:
Clipboard content disappears for Tcl/Tk applications under Linux-like systems, since there is apparently no standard for storing clipboard somewhere.

Some desktop environments solve it via methods that provide support for clipboard duration, e.g. via delegating that content to some daemons.
It would be useful if Tcl/Tk could talk to such systems and gain clipboard duration by that under Linux too.

Currently common desktop environments under Linux are GTK-based and they provide such a support via "gtk_clipboard_store" method for apps written in C (and related languages), using GTK as the main toolkit.
https://developer.gnome.org/gtk3/stable/gtk3-Clipboards.html#gtk-clipboard-store
https://git.gnome.org/browse/gtk+/tree/gtk/gtkclipboard.c#n2138
I have a small utility that uses this method, and calling that utility (as an external program) when I want to make sure that clipboard gets this duration. It is sort-of strange to do it this way though.

The "gtk_clipboard_store" method requires that the application is GTK-based with initialized GTK stuff. May be that if Tcl/Tk gets support for Wayland via GTK, this will get gained too.
It seems that the more inner part of this (when living on x11) is via "gdk_x11_display_store_clipboard" method.
https://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkdisplay-x11.c#n2450
It would be useful if it could be reused within Tcl/Tk.
User Comments: fvogel added on 2018-06-03 18:24:18:
OK, thanks for the feedback. Closing then.

kvutza added on 2018-06-03 17:58:56:
For the clipboard duration when being under X11 (with GNOME-like environment), it is possible to use the way described at:
https://core.tcl.tk/tk/tktview/73ba07efcd3834adcebe

Thus this ticket may be closed, at least for me as I submitted this ticket; doing it roughly alike:

if {"SAVE_TARGETS" in [selection get -selection CLIPBOARD_MANAGER -type SAVE_TARGETS]} {
    selection handle -selection CLIPBOARD . some_method_that_serves_text_parts
}

It just seems that the desktop system asks for the text (in chunks) twice. I do not know whether it is standard (to ask twice for the clipboard content), thus noticing it here for other users.