-void
-gdk_selection_convert (GdkWindow *requestor,
- GdkAtom selection,
- GdkAtom target,
- guint32 time)
-{
- GdkWindowPrivate *private;
-
- g_return_if_fail (requestor != NULL);
-
- private = (GdkWindowPrivate*) requestor;
- if (private->destroyed)
- return;
-
- XConvertSelection (private->xdisplay, selection, target,
- gdk_selection_property, private->xwindow, time);
-}
-
-gint
-gdk_selection_property_get (GdkWindow *requestor,
- guchar **data,
- GdkAtom *ret_type,
- gint *ret_format)
-{
- GdkWindowPrivate *private;
- gulong nitems;
- gulong nbytes;
- gulong length;
- GdkAtom prop_type;
- gint prop_format;
- guchar *t = NULL;
-
- g_return_val_if_fail (requestor != NULL, 0);
-
- /* If retrieved chunks are typically small, (and the ICCCM says the
- should be) it would be a win to try first with a buffer of
- moderate length, to avoid two round trips to the server */
-
- private = (GdkWindowPrivate*) requestor;
- if (private->destroyed)
- return 0;
-
- t = NULL;
- XGetWindowProperty (private->xdisplay, private->xwindow,
- gdk_selection_property, 0, 0, False,
- AnyPropertyType, &prop_type, &prop_format,
- &nitems, &nbytes, &t);
-
- if (ret_type)
- *ret_type = prop_type;
- if (ret_format)
- *ret_format = prop_format;
-
- if (prop_type == None)
- {
- *data = NULL;
- return 0;
- }
-
- if (t)
- {
- XFree (t);
- t = NULL;
- }
-
- /* Add on an extra byte to handle null termination. X guarantees
- that t will be 1 longer than nbytes and null terminated */
- length = nbytes + 1;
-
- /* We can't delete the selection here, because it might be the INCR
- protocol, in which case the client has to make sure they'll be
- notified of PropertyChange events _before_ the property is deleted.
- Otherwise there's no guarantee we'll win the race ... */
- XGetWindowProperty (private->xdisplay, private->xwindow,
- gdk_selection_property, 0, (nbytes + 3) / 4, False,
- AnyPropertyType, &prop_type, &prop_format,
- &nitems, &nbytes, &t);
-
- if (prop_type != None)
- {
- *data = g_new (guchar, length);
- memcpy (*data, t, length);
- if (t)
- XFree (t);
- return length-1;
- }
- else
- {
- *data = NULL;
- return 0;
- }
-}
-
-