CLIPBOARD selection doesn't save content

Peter Clifton pcjc2 at cam.ac.uk
Fri Apr 2 15:17:12 PDT 2010


On Fri, 2010-04-02 at 23:08 +0200, Quintus wrote:
> .... I answer this with
> TARGETS, UTF8_STRING, XA_STRING and TIMESTAMP, which should cause
> xclipboard to ask me for UTF8_STRING or XA_STRING, but... It doesn't.
> Instead, if I try to paste the copied text into an application, my
> program gets a request from that application rather than from
> xclipboard. Further more, when my program finishes, the data is gone. So
> I suppose, something is wrong at my side.

If you can, try it under gnome too - as the last time I worked with any
clipboard code, I found its clipboard manager more cooperative at saving
non-standard data-types than when testing under KDE.

Also, the clipboard manager in gnome will only request the clipboard
contents and take over from my app when the app closes. We explicitly
call gtk_clipboard_store() as we tear down the app.

When we set the clipboard contents, we call this:

  /* Hint that the data can be stored to be accessed after the program
   * has quit. */
  gtk_clipboard_set_can_store (cb, NULL, 0);

gtk_clipboard_store calls gdk_display_store_clipboard, which pokes the clipboard manager with (roughly) this code:


  clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");
  save_targets = gdk_x11_get_xatom_by_name_for_display (display, "SAVE_TARGETS");

  if (XGetSelectionOwner (display_x11->xdisplay, clipboard_manager) != None)
    {
      Atom property_name = None;
      Atom *xatoms;
      int i;
      
      if (n_targets > 0)
	{
	  property_name = gdk_x11_atom_to_xatom_for_display (display, _gdk_selection_property);

	  xatoms = g_new (Atom, n_targets);
	  for (i = 0; i < n_targets; i++)
	    xatoms[i] = gdk_x11_atom_to_xatom_for_display (display, targets[i]);

	  XChangeProperty (display_x11->xdisplay, GDK_WINDOW_XID (clipboard_window),
			   property_name, XA_ATOM,
			   32, PropModeReplace, (guchar *)xatoms, n_targets);
	  g_free (xatoms);

	}
      
      XConvertSelection (display_x11->xdisplay,
			 clipboard_manager, save_targets, property_name,
			 GDK_WINDOW_XID (clipboard_window), time_);
      


Take a look at the clipboard manager spec. here:

http://www.freedesktop.org/wiki/ClipboardManager

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
Tel: +44 (0)1223 748328 - (Shared lab phone, ask for me)




More information about the xorg mailing list