Question

I am using gtk to clear the clipboard on Linux platforms with X11, and I was hoping that it would work across all Linux platforms. However, my gtk code does not work for Fedora KDE and some distributions of Fedora. When clipboard_clear function is called, the clipboard does not get cleared.

void clipboard_clear() {
  gtk_init(&args,NULL);
  GtkClipboard* cb = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
  gtk_clipboard_clear(cb);
  gtk_clipboard_set_text(cb, "", 0);

  cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
  gtk_clipboard_clear(cb);
  gtk_clipboard_set_text(cb, "", 0);
}

Is there anything that I can do to make this gtk implementation work as it suppose to on a Fedora KDE? If not, are there any libraries that can clear the clipboard on KDE and be statically linked? (Qt is not one among them because of licensing restrictions.)

Was it helpful?

Solution

External clipboard managers prevent the above code from clearing the clipboard.

On Fedora 19 KDE, klipper came pre-installed. After closing it, there wasn't any more problems with clearing the function. Similarly on Fedora 19 LXDE, clipit came pre-installed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top