static void xf_cliprdr_get_requested_targets(xfInfo* xfi) { int num; int i, j; Atom atom; int format; BYTE* data = NULL; unsigned long length, bytes_left; RDP_CB_FORMAT_LIST_EVENT* event; clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; XGetWindowProperty(xfi->display, xfi->drawable, cb->property_atom, 0, 200, 0, XA_ATOM, &atom, &format, &length, &bytes_left, &data); DEBUG_X11_CLIPRDR("type=%d format=%d length=%d bytes_left=%d", (int) atom, format, (int) length, (int) bytes_left); if (length > 0) { event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_FormatList, NULL, NULL); event->formats = (UINT32*) malloc(sizeof(UINT32) * cb->num_format_mappings); num = 0; for (i = 0; i < length; i++) { atom = ((Atom*) data)[i]; DEBUG_X11("atom %d", (int) atom); for (j = 0; j < cb->num_format_mappings; j++) { if (cb->format_mappings[j].target_format == atom) { DEBUG_X11("found format %d for atom %d", cb->format_mappings[j].format_id, (int)atom); event->formats[num++] = cb->format_mappings[j].format_id; break; } } } event->num_formats = num; XFree(data); freerdp_channels_send_event(cb->channels, (wMessage*) event); } else { if (data) XFree(data); xf_cliprdr_send_null_format_list(xfi); } }
static void xf_cliprdr_get_requested_targets(xfInfo* xfi) { int num; int i, j; Atom atom; int format; uint8* data = NULL; unsigned long len, bytes_left; RDP_CB_FORMAT_LIST_EVENT* event; clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; XGetWindowProperty(xfi->display, xfi->window->handle, cb->property_atom, 0, 200, 0, XA_ATOM, &atom, &format, &len, &bytes_left, &data); DEBUG_X11("type=%d format=%d len=%d bytes_left=%d", (int)atom, format, (int)len, (int)bytes_left); if (len > 0) { event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); event->formats = (uint32*) xmalloc(sizeof(uint32) * cb->num_format_mappings); num = 0; for (i = 0; i < len; i++) { atom = ((Atom*)data)[i]; DEBUG_X11("atom %d", (int)atom); for (j = 0; j < cb->num_format_mappings; j++) { if (cb->format_mappings[j].target_format == atom) { DEBUG_X11("found format %d for atom %d", cb->format_mappings[j].format_id, (int)atom); event->formats[num++] = cb->format_mappings[j].format_id; break; } } } event->num_formats = num; XFree(data); freerdp_chanman_send_event(cb->chanman, (RDP_EVENT*) event); } else { if (data) { XFree(data); } xf_cliprdr_send_null_format_list(xfi); } }
static void xf_cliprdr_send_format_list(xfInfo* xfi) { clipboardContext* cb = (clipboardContext*) xfi->clipboard_context; if (xf_cliprdr_is_self_owned(xfi)) { xf_cliprdr_send_raw_format_list(xfi); } else if (cb->owner == None) { xf_cliprdr_send_null_format_list(xfi); } else if (cb->owner != xfi->drawable) { /* Request the owner for TARGETS, and wait for SelectionNotify event */ XConvertSelection(xfi->display, cb->clipboard_atom, cb->targets[1], cb->property_atom, xfi->drawable, CurrentTime); } }