1 #include "ecore_xcb_private.h"
2 //#include "Ecore_X_Atoms.h"
4 #define ECORE_XCB_SELECTION_DATA(x) ((Ecore_X_Selection_Data *)(x))
6 /* local function prototypes */
7 static void *_ecore_xcb_selection_parser_text(const char *target EINA_UNUSED,
10 int format EINA_UNUSED);
11 static void *_ecore_xcb_selection_parser_xmozurl(const char *target EINA_UNUSED,
14 int format EINA_UNUSED);
15 static void *_ecore_xcb_selection_parser_files(const char *target,
18 int format EINA_UNUSED);
19 static void *_ecore_xcb_selection_parser_targets(const char *target EINA_UNUSED,
22 int format EINA_UNUSED);
24 //static int _ecore_xcb_selection_data_free(void *data);
25 static int _ecore_xcb_selection_data_text_free(void *data);
26 static int _ecore_xcb_selection_data_targets_free(void *data);
27 static int _ecore_xcb_selection_data_files_free(void *data);
28 static int _ecore_xcb_selection_data_default_free(void *data);
29 static Eina_Bool _ecore_xcb_selection_set(Ecore_X_Window win,
32 Ecore_X_Atom selection);
33 static void _ecore_xcb_selection_request(Ecore_X_Window win,
34 Ecore_X_Atom selection,
36 static Ecore_X_Atom _ecore_xcb_selection_target_atom_get(const char *target);
39 static Ecore_X_Selection_Intern _selections[4];
40 static Ecore_X_Selection_Converter *_converters = NULL;
41 static Ecore_X_Selection_Parser *_parsers = NULL;
45 _ecore_xcb_selection_init(void)
47 LOGFN(__FILE__, __LINE__, __FUNCTION__);
49 memset(_selections, 0, sizeof(_selections));
52 ecore_x_selection_converter_atom_add(ECORE_X_ATOM_TEXT,
53 ecore_x_selection_converter_text);
54 ecore_x_selection_converter_atom_add(ECORE_X_ATOM_UTF8_STRING,
55 ecore_x_selection_converter_text);
56 ecore_x_selection_converter_atom_add(ECORE_X_ATOM_COMPOUND_TEXT,
57 ecore_x_selection_converter_text);
58 ecore_x_selection_converter_atom_add(ECORE_X_ATOM_STRING,
59 ecore_x_selection_converter_text);
62 ecore_x_selection_parser_add("text/plain",
63 _ecore_xcb_selection_parser_text);
64 ecore_x_selection_parser_add(ECORE_X_SELECTION_TARGET_UTF8_STRING,
65 _ecore_xcb_selection_parser_text);
66 ecore_x_selection_parser_add("text/uri-list",
67 _ecore_xcb_selection_parser_files);
68 ecore_x_selection_parser_add("text/x-moz-url",
69 _ecore_xcb_selection_parser_xmozurl);
70 ecore_x_selection_parser_add("_NETSCAPE_URL",
71 _ecore_xcb_selection_parser_files);
72 ecore_x_selection_parser_add(ECORE_X_SELECTION_TARGET_TARGETS,
73 _ecore_xcb_selection_parser_targets);
77 _ecore_xcb_selection_shutdown(void)
79 Ecore_X_Selection_Converter *cnv;
80 Ecore_X_Selection_Parser *prs;
82 LOGFN(__FILE__, __LINE__, __FUNCTION__);
84 /* free selection converters */
88 Ecore_X_Selection_Converter *tmp;
100 Ecore_X_Selection_Parser *tmp;
110 /* public functions */
112 ecore_x_selection_converter_atom_add(Ecore_X_Atom target,
113 Eina_Bool (*func)(char *target,
121 Ecore_X_Selection_Converter *cnv;
123 LOGFN(__FILE__, __LINE__, __FUNCTION__);
130 if (cnv->target == target)
140 cnv->next = calloc(1, sizeof(Ecore_X_Selection_Converter));
141 if (!cnv->next) return;
146 _converters = calloc(1, sizeof(Ecore_X_Selection_Converter));
147 if (!_converters) return;
150 cnv->target = target;
155 ecore_x_selection_converter_add(char *target,
156 Eina_Bool (*func)(char *target,
161 Ecore_X_Atom *atom_ret,
164 Ecore_X_Atom atarget;
166 LOGFN(__FILE__, __LINE__, __FUNCTION__);
168 if ((!func) || (!target)) return;
169 atarget = _ecore_xcb_selection_target_atom_get(target);
170 ecore_x_selection_converter_atom_add(atarget, func);
174 ecore_x_selection_converter_del(char *target)
176 Ecore_X_Atom atarget;
178 LOGFN(__FILE__, __LINE__, __FUNCTION__);
181 atarget = _ecore_xcb_selection_target_atom_get(target);
182 ecore_x_selection_converter_atom_del(atarget);
186 ecore_x_selection_converter_atom_del(Ecore_X_Atom target)
188 Ecore_X_Selection_Converter *conv, *pconv = NULL;
190 LOGFN(__FILE__, __LINE__, __FUNCTION__);
195 if (conv->target == target)
198 pconv->next = conv->next;
200 _converters = conv->next;
210 ecore_x_selection_parser_add(const char *target,
211 void *(*func)(const char *target, void *data, int size, int format))
213 Ecore_X_Selection_Parser *prs;
215 LOGFN(__FILE__, __LINE__, __FUNCTION__);
223 if (!strcmp(prs->target, target))
230 prs->next = calloc(1, sizeof(Ecore_X_Selection_Parser));
235 _parsers = calloc(1, sizeof(Ecore_X_Selection_Parser));
238 prs->target = strdup(target);
243 ecore_x_selection_parser_del(const char *target)
245 Ecore_X_Selection_Parser *prs, *pprs = NULL;
247 LOGFN(__FILE__, __LINE__, __FUNCTION__);
254 if (!strcmp(prs->target, target))
257 pprs->next = prs->next;
259 _parsers = prs->next;
270 * Claim ownership of the PRIMARY selection and set its data.
271 * @param w The window to which this selection belongs
272 * @param data The data associated with the selection
273 * @param size The size of the data buffer in bytes
274 * @return Returns 1 if the ownership of the selection was successfully
275 * claimed, or 0 if unsuccessful.
278 ecore_x_selection_primary_set(Ecore_X_Window win,
282 LOGFN(__FILE__, __LINE__, __FUNCTION__);
284 return _ecore_xcb_selection_set(win, data, size,
285 ECORE_X_ATOM_SELECTION_PRIMARY);
289 * Release ownership of the primary selection
290 * @return Returns 1 if the selection was successfully cleared,
291 * or 0 if unsuccessful.
294 ecore_x_selection_primary_clear(void)
296 LOGFN(__FILE__, __LINE__, __FUNCTION__);
298 return _ecore_xcb_selection_set(XCB_NONE, NULL, 0,
299 ECORE_X_ATOM_SELECTION_PRIMARY);
303 ecore_x_selection_primary_request(Ecore_X_Window win,
306 LOGFN(__FILE__, __LINE__, __FUNCTION__);
308 _ecore_xcb_selection_request(win, ECORE_X_ATOM_SELECTION_PRIMARY, target);
312 * Claim ownership of the SECONDARY selection and set its data.
313 * @param w The window to which this selection belongs
314 * @param data The data associated with the selection
315 * @param size The size of the data buffer in bytes
316 * @return Returns 1 if the ownership of the selection was successfully
317 * claimed, or 0 if unsuccessful.
320 ecore_x_selection_secondary_set(Ecore_X_Window win,
324 LOGFN(__FILE__, __LINE__, __FUNCTION__);
326 return _ecore_xcb_selection_set(win, data, size,
327 ECORE_X_ATOM_SELECTION_SECONDARY);
331 * Release ownership of the secondary selection
332 * @return Returns 1 if the selection was successfully cleared,
333 * or 0 if unsuccessful.
336 ecore_x_selection_secondary_clear(void)
338 LOGFN(__FILE__, __LINE__, __FUNCTION__);
340 return _ecore_xcb_selection_set(XCB_NONE, NULL, 0,
341 ECORE_X_ATOM_SELECTION_SECONDARY);
345 ecore_x_selection_secondary_request(Ecore_X_Window win,
348 LOGFN(__FILE__, __LINE__, __FUNCTION__);
350 _ecore_xcb_selection_request(win, ECORE_X_ATOM_SELECTION_SECONDARY, target);
354 * Claim ownership of the XDND selection and set its data.
355 * @param w The window to which this selection belongs
356 * @param data The data associated with the selection
357 * @param size The size of the data buffer in bytes
358 * @return Returns 1 if the ownership of the selection was successfully
359 * claimed, or 0 if unsuccessful.
362 ecore_x_selection_xdnd_set(Ecore_X_Window win,
366 LOGFN(__FILE__, __LINE__, __FUNCTION__);
368 return _ecore_xcb_selection_set(win, data, size,
369 ECORE_X_ATOM_SELECTION_XDND);
373 * Release ownership of the XDND selection
374 * @return Returns 1 if the selection was successfully cleared,
375 * or 0 if unsuccessful.
378 ecore_x_selection_xdnd_clear(void)
380 LOGFN(__FILE__, __LINE__, __FUNCTION__);
382 return _ecore_xcb_selection_set(XCB_NONE, NULL, 0,
383 ECORE_X_ATOM_SELECTION_XDND);
387 ecore_x_selection_xdnd_request(Ecore_X_Window win,
391 Ecore_X_DND_Target *_target;
393 LOGFN(__FILE__, __LINE__, __FUNCTION__);
396 _target = _ecore_xcb_dnd_target_get();
397 atom = _ecore_xcb_selection_target_atom_get(target);
399 xcb_convert_selection(_ecore_xcb_conn, win, ECORE_X_ATOM_SELECTION_XDND,
400 atom, ECORE_X_ATOM_SELECTION_PROP_XDND, _target->time);
404 * Claim ownership of the CLIPBOARD selection and set its data.
405 * @param w The window to which this selection belongs
406 * @param data The data associated with the selection
407 * @param size The size of the data buffer in bytes
408 * @return Returns 1 if the ownership of the selection was successfully
409 * claimed, or 0 if unsuccessful.
411 * Get the converted data from a previous CLIPBOARD selection
412 * request. The buffer must be freed when done with.
415 ecore_x_selection_clipboard_set(Ecore_X_Window win,
419 LOGFN(__FILE__, __LINE__, __FUNCTION__);
421 return _ecore_xcb_selection_set(win, data, size,
422 ECORE_X_ATOM_SELECTION_CLIPBOARD);
426 * Release ownership of the clipboard selection
427 * @return Returns 1 if the selection was successfully cleared,
428 * or 0 if unsuccessful.
431 ecore_x_selection_clipboard_clear(void)
433 LOGFN(__FILE__, __LINE__, __FUNCTION__);
435 return _ecore_xcb_selection_set(XCB_NONE, NULL, 0,
436 ECORE_X_ATOM_SELECTION_CLIPBOARD);
440 ecore_x_selection_clipboard_request(Ecore_X_Window win,
443 LOGFN(__FILE__, __LINE__, __FUNCTION__);
445 _ecore_xcb_selection_request(win, ECORE_X_ATOM_SELECTION_CLIPBOARD, target);
449 ecore_x_selection_convert(Ecore_X_Atom selection,
453 Ecore_X_Atom *targtype,
456 Ecore_X_Selection_Intern *sel;
457 Ecore_X_Selection_Converter *cnv;
461 LOGFN(__FILE__, __LINE__, __FUNCTION__);
463 sel = _ecore_xcb_selection_get(selection);
464 tgt_str = _ecore_xcb_selection_target_get(target);
466 for (cnv = _converters; cnv; cnv = cnv->next)
468 if (cnv->target == target)
472 r = cnv->convert(tgt_str, sel->data, sel->length, &data, size,
477 if (data_ret) *data_ret = data;
490 ecore_x_selection_notify_send(Ecore_X_Window requestor,
491 Ecore_X_Atom selection,
493 Ecore_X_Atom property,
496 xcb_selection_notify_event_t ev;
498 LOGFN(__FILE__, __LINE__, __FUNCTION__);
501 memset(&ev, 0, sizeof(xcb_selection_notify_event_t));
503 ev.response_type = XCB_SELECTION_NOTIFY;
504 ev.requestor = requestor;
505 ev.selection = selection;
507 ev.property = property;
510 xcb_send_event(_ecore_xcb_conn, 0, requestor,
511 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
518 ecore_x_selection_owner_set(Ecore_X_Window win,
522 LOGFN(__FILE__, __LINE__, __FUNCTION__);
525 xcb_set_selection_owner(_ecore_xcb_conn, win, atom, tim);
529 ecore_x_selection_owner_get(Ecore_X_Atom atom)
531 xcb_get_selection_owner_cookie_t cookie;
532 xcb_get_selection_owner_reply_t *reply;
535 LOGFN(__FILE__, __LINE__, __FUNCTION__);
538 cookie = xcb_get_selection_owner(_ecore_xcb_conn, atom);
539 reply = xcb_get_selection_owner_reply(_ecore_xcb_conn, cookie, NULL);
540 if (!reply) return 0;
547 _ecore_xcb_selection_parse(const char *target,
552 Ecore_X_Selection_Parser *prs;
553 Ecore_X_Selection_Data *sel;
555 for (prs = _parsers; prs; prs = prs->next)
557 if (!strcmp(prs->target, target))
559 sel = prs->parse(target, data, size, format);
564 sel = calloc(1, sizeof(Ecore_X_Selection_Data));
565 if (!sel) return NULL;
566 sel->free = _ecore_xcb_selection_data_default_free;
568 sel->format = format;
574 Ecore_X_Selection_Intern *
575 _ecore_xcb_selection_get(Ecore_X_Atom selection)
577 if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
578 return &_selections[0];
579 else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
580 return &_selections[1];
581 else if (selection == ECORE_X_ATOM_SELECTION_XDND)
582 return &_selections[2];
583 else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
584 return &_selections[3];
589 /* local functions */
591 _ecore_xcb_selection_set(Ecore_X_Window win,
594 Ecore_X_Atom selection)
596 xcb_get_selection_owner_cookie_t cookie;
597 xcb_get_selection_owner_reply_t *reply;
600 LOGFN(__FILE__, __LINE__, __FUNCTION__);
603 xcb_set_selection_owner(_ecore_xcb_conn, win, selection, XCB_CURRENT_TIME);
605 cookie = xcb_get_selection_owner(_ecore_xcb_conn, selection);
606 reply = xcb_get_selection_owner_reply(_ecore_xcb_conn, cookie, NULL);
607 if (!reply) return EINA_FALSE;
609 if (reply->owner != win)
616 if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
618 else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
620 else if (selection == ECORE_X_ATOM_SELECTION_XDND)
622 else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
627 if (_selections[in].data)
629 free(_selections[in].data);
630 memset(&_selections[in], 0, sizeof(Ecore_X_Selection_Intern));
635 unsigned char *buff = NULL;
637 _selections[in].win = win;
638 _selections[in].selection = selection;
639 _selections[in].length = size;
640 _selections[in].time = _ecore_xcb_events_last_time_get();
643 if (!buff) return EINA_FALSE;
644 memcpy(buff, data, size);
645 _selections[in].data = buff;
652 _ecore_xcb_selection_request(Ecore_X_Window win,
653 Ecore_X_Atom selection,
656 Ecore_X_Atom atarget, prop;
658 LOGFN(__FILE__, __LINE__, __FUNCTION__);
661 if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
662 prop = ECORE_X_ATOM_SELECTION_PROP_PRIMARY;
663 else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
664 prop = ECORE_X_ATOM_SELECTION_PROP_SECONDARY;
665 else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
666 prop = ECORE_X_ATOM_SELECTION_PROP_CLIPBOARD;
670 atarget = _ecore_xcb_selection_target_atom_get(target);
672 xcb_convert_selection(_ecore_xcb_conn, win, selection, atarget, prop,
677 ecore_x_selection_converter_text(char *target,
682 Ecore_X_Atom *type EINA_UNUSED,
683 int *size_type EINA_UNUSED)
685 Ecore_Xcb_Encoding_Style style;
686 Ecore_Xcb_Textproperty ret;
689 LOGFN(__FILE__, __LINE__, __FUNCTION__);
692 if ((!data) || (!size)) return EINA_FALSE;
694 if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT))
695 style = XcbTextStyle;
696 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_COMPOUND_TEXT))
697 style = XcbCompoundTextStyle;
698 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_STRING))
699 style = XcbStringStyle;
701 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_UTF8_STRING))
702 style = XcbUTF8StringStyle;
707 str = alloca(size + 1);
708 memcpy(str, data, size);
712 if (_ecore_xcb_utf8_textlist_to_textproperty(&str, 1, style, &ret))
716 size = (strlen((char *)ret.value));
717 *data_ret = malloc(size);
718 if (!*data_ret) return EINA_FALSE;
719 memcpy(*data_ret, ret.value, size);
721 if (ret.value) free(ret.value);
725 if (_ecore_xcb_mb_textlist_to_textproperty(&str, 1, style, &ret))
729 size = (strlen((char *)ret.value));
730 *data_ret = malloc(size);
731 if (!*data_ret) return EINA_FALSE;
732 memcpy(*data_ret, ret.value, size);
734 if (ret.value) free(ret.value);
743 _ecore_xcb_selection_parser_text(const char *target EINA_UNUSED,
746 int format EINA_UNUSED)
748 Ecore_X_Selection_Data_Text *sel;
749 unsigned char *_data;
752 LOGFN(__FILE__, __LINE__, __FUNCTION__);
754 if (!(_data = data)) return NULL;
756 sel = calloc(1, sizeof(Ecore_X_Selection_Data_Text));
757 if (!sel) return NULL;
759 if (_data && _data[size - 1])
762 t = realloc(_data, size);
771 sel->text = (char *)_data;
772 ECORE_XCB_SELECTION_DATA(sel)->length = size;
773 ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_TEXT;
774 ECORE_XCB_SELECTION_DATA(sel)->data = _data;
775 ECORE_XCB_SELECTION_DATA(sel)->free = _ecore_xcb_selection_data_text_free;
780 _ecore_xcb_selection_data_xmozurl_free(void *data)
782 Ecore_X_Selection_Data_X_Moz_Url *sel = data;
785 LOGFN(__FILE__, __LINE__, __FUNCTION__);
788 buf = eina_inarray_nth(sel->links, 0);
790 eina_inarray_free(sel->links);
791 eina_inarray_free(sel->link_names);
797 _ecore_xcb_selection_parser_xmozurl(const char *target EINA_UNUSED,
800 int format EINA_UNUSED)
802 Ecore_X_Selection_Data_X_Moz_Url *sel;
803 char *prev, *n, *buf, *data = _data;
807 LOGFN(__FILE__, __LINE__, __FUNCTION__);
809 buf = eina_str_convert_len("UTF-16LE", "UTF-8", data, size, &sz);
810 if (!buf) return NULL;
811 sel = calloc(1, sizeof(Ecore_X_Selection_Data_X_Moz_Url));
815 sel->links = eina_inarray_new(sizeof(char*), 0);
819 sel->link_names = eina_inarray_new(sizeof(char*), 0);
820 if (!sel->link_names)
821 goto error_link_names;
823 for (n = memchr(buf, '\n', sz); n; n = memchr(prev, '\n', sz - (prev - buf)))
827 eina_inarray_push(sel->links, &prev);
829 eina_inarray_push(sel->link_names, &prev);
833 eina_inarray_push(sel->link_names, &prev[0]);
835 ECORE_XCB_SELECTION_DATA(sel)->length = size;
836 ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_X_MOZ_URL;
837 ECORE_XCB_SELECTION_DATA(sel)->data = (void*)data;
838 ECORE_XCB_SELECTION_DATA(sel)->free = _ecore_xcb_selection_data_xmozurl_free;
842 eina_inarray_free(sel->links);
853 _ecore_xcb_selection_parser_files(const char *target,
856 int format EINA_UNUSED)
858 Ecore_X_Selection_Data_Files *sel;
859 char *_data, *tmp, *t, **t2;
862 LOGFN(__FILE__, __LINE__, __FUNCTION__);
864 if ((strcmp(target, "text/uri-list")) &&
865 (strcmp(target, "_NETSCAPE_URL"))) return NULL;
867 if (!(_data = data)) return NULL;
869 sel = calloc(1, sizeof(Ecore_X_Selection_Data_Files));
870 if (!sel) return NULL;
872 ECORE_XCB_SELECTION_DATA(sel)->free = _ecore_xcb_selection_data_files_free;
874 if (_data && _data[size - 1])
877 t = realloc(_data, size);
894 while ((is < size) && (_data[is]))
896 if ((i == 0) && (_data[is] == '#'))
898 for (; ((_data[is]) && (_data[is] != '\n')); is++) ;
902 if ((_data[is] != '\r') && (_data[is] != '\n'))
903 tmp[i++] = _data[is++];
906 while ((_data[is] == '\r') || (_data[is] == '\n'))
910 t2 = realloc(sel->files, sel->num_files * sizeof(char *));
914 sel->files[sel->num_files - 1] = strdup(tmp);
925 t2 = realloc(sel->files, sel->num_files * sizeof(char *));
929 sel->files[sel->num_files - 1] = strdup(tmp);
933 if (_data) free(_data);
935 ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_FILES;
936 ECORE_XCB_SELECTION_DATA(sel)->length = sel->num_files;
938 return ECORE_XCB_SELECTION_DATA(sel);
942 _ecore_xcb_selection_parser_targets(const char *target EINA_UNUSED,
945 int format EINA_UNUSED)
947 Ecore_X_Selection_Data_Targets *sel;
951 LOGFN(__FILE__, __LINE__, __FUNCTION__);
954 if (!(targets = data)) return NULL;
956 sel = calloc(1, sizeof(Ecore_X_Selection_Data_Targets));
957 if (!sel) return NULL;
959 sel->num_targets = (size - 2);
960 sel->targets = malloc((size - 2) * sizeof(char *));
967 for (i = 2; i < size; i++)
969 xcb_get_atom_name_cookie_t cookie;
970 xcb_get_atom_name_reply_t *reply;
974 cookie = xcb_get_atom_name_unchecked(_ecore_xcb_conn, targets[i]);
975 reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookie, NULL);
978 len = xcb_get_atom_name_name_length(reply);
979 name = (char *)malloc(sizeof(char) * (len + 1));
982 memcpy(name, xcb_get_atom_name_name(reply), len);
984 sel->targets[i - 2] = name;
990 ECORE_XCB_SELECTION_DATA(sel)->free =
991 _ecore_xcb_selection_data_targets_free;
992 ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_TARGETS;
993 ECORE_XCB_SELECTION_DATA(sel)->length = size;
994 ECORE_XCB_SELECTION_DATA(sel)->data = data;
1001 _ecore_xcb_selection_data_free(void *data)
1003 Ecore_X_Selection_Data *sel;
1005 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1007 if (!(sel = data)) return 0;
1008 if (sel->data) free(sel->data);
1015 _ecore_xcb_selection_data_text_free(void *data)
1017 Ecore_X_Selection_Data_Text *sel;
1019 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1021 if (!(sel = data)) return 0;
1022 if (sel->text) free(sel->text);
1028 _ecore_xcb_selection_data_targets_free(void *data)
1030 Ecore_X_Selection_Data_Targets *sel;
1032 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1034 if (!(sel = data)) return 0;
1035 if (sel->targets) free(sel->targets);
1036 free(ECORE_XCB_SELECTION_DATA(sel)->data);
1042 _ecore_xcb_selection_data_files_free(void *data)
1044 Ecore_X_Selection_Data_Files *sel;
1046 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1048 if (!(sel = data)) return 0;
1053 for (i = 0; i < sel->num_files; i++)
1054 if (sel->files[i]) free(sel->files[i]);
1055 if (sel->files) free(sel->files);
1062 _ecore_xcb_selection_data_default_free(void *data)
1064 Ecore_X_Selection_Data *sel;
1066 if (!(sel = data)) return 1;
1073 _ecore_xcb_selection_target_atom_get(const char *target)
1075 Ecore_X_Atom x_target;
1077 if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT))
1078 x_target = ECORE_X_ATOM_TEXT;
1079 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_COMPOUND_TEXT))
1080 x_target = ECORE_X_ATOM_COMPOUND_TEXT;
1081 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_STRING))
1082 x_target = ECORE_X_ATOM_STRING;
1083 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_UTF8_STRING))
1084 x_target = ECORE_X_ATOM_UTF8_STRING;
1085 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_FILENAME))
1086 x_target = ECORE_X_ATOM_FILE_NAME;
1087 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_X_MOZ_URL))
1088 x_target = ECORE_X_ATOM_X_MOZ_URL;
1090 x_target = ecore_x_atom_get(target);
1096 _ecore_xcb_selection_target_get(Ecore_X_Atom target)
1098 if (target == ECORE_X_ATOM_FILE_NAME)
1099 return strdup(ECORE_X_SELECTION_TARGET_FILENAME);
1100 else if (target == ECORE_X_ATOM_STRING)
1101 return strdup(ECORE_X_SELECTION_TARGET_STRING);
1102 else if (target == ECORE_X_ATOM_UTF8_STRING)
1103 return strdup(ECORE_X_SELECTION_TARGET_UTF8_STRING);
1104 else if (target == ECORE_X_ATOM_TEXT)
1105 return strdup(ECORE_X_SELECTION_TARGET_TEXT);
1106 else if (target == ECORE_X_ATOM_X_MOZ_URL)
1107 return strdup(ECORE_X_SELECTION_TARGET_X_MOZ_URL);
1109 return ecore_x_atom_name_get(target);