#define E_COMP_WL
#include "e.h"
+static void
+_mime_types_free(E_Comp_Wl_Data_Source *source)
+{
+ if (!source->mime_types) return;
+ while (eina_array_count(source->mime_types))
+ eina_stringshare_del(eina_array_pop(source->mime_types));
+ eina_array_free(source->mime_types);
+}
+
static void
_e_comp_wl_data_offer_cb_accept(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t serial, const char *mime_type)
{
if (!(source = wl_resource_get_user_data(resource)))
return;
- source->mime_types =
- eina_list_append(source->mime_types, eina_stringshare_add(mime_type));
+ eina_array_push(source->mime_types, eina_stringshare_add(mime_type));
}
/* called by wl_data_source_destroy */
_e_comp_wl_data_source_cb_resource_destroy(struct wl_resource *resource)
{
E_Comp_Wl_Data_Source *source;
- char *t;
if (!(source = wl_resource_get_user_data(resource)))
return;
wl_signal_emit(&source->destroy_signal, source);
- EINA_LIST_FREE(source->mime_types, t)
- eina_stringshare_del(t);
-
+ _mime_types_free(source);
free(source);
}
_e_comp_wl_data_device_data_offer_create(E_Comp_Wl_Data_Source *source, struct wl_resource *data_device_res)
{
E_Comp_Wl_Data_Offer *offer;
- Eina_List *l;
+ Eina_Iterator *it;
char *t;
DBG("Data Offer Create");
wl_data_device_send_data_offer(data_device_res, offer->resource);
- EINA_LIST_FOREACH(source->mime_types, l, t)
- wl_data_offer_send_offer(offer->resource, t);
+ it = eina_array_iterator_new(source->mime_types);
+ EINA_ITERATOR_FOREACH(it, t)
+ wl_data_offer_send_offer(offer->resource, t);
+ eina_iterator_free(it);
return offer->resource;
}
clip_source = container_of(source, E_Comp_Wl_Clipboard_Source, data_source);
if (!clip_source) return;
- t = eina_list_nth(source->mime_types, 0);
+ t = eina_array_data_get(source->mime_types, 0);
if (!strcmp(mime_type, t))
_e_comp_wl_clipboard_offer_create(clip_source, fd);
else
e_comp_wl_clipboard_source_unref(clip_source);
e_comp->wl_comp_data->clipboard.source = NULL;
- mime_type = eina_list_nth(sel_source->mime_types, 0);
+ mime_type = eina_array_data_get(sel_source->mime_types, 0);
if (pipe2(p, O_CLOEXEC) == -1)
return;
{
int d1 = 0x5UL, d2, d3, d4;
E_Comp_Wl_Data_Source *source;
- Eina_List *l;
d2 = d3 = d4 = 0;
source = e_comp->wl_comp_data->drag_source;
- if (eina_list_count(source->mime_types) > 3)
+ if (eina_array_count(source->mime_types) > 3)
{
- const char *type, *types[eina_list_count(source->mime_types)];
+ const char *type, *types[eina_array_count(source->mime_types)];
int i = 0;
+ Eina_Iterator *it;
d1 |= 0x1UL;
- EINA_LIST_FOREACH(source->mime_types, l, type)
+ it = eina_array_iterator_new(source->mime_types);
+ EINA_ITERATOR_FOREACH(it, type)
types[i++] = type;
+ eina_iterator_free(it);
ecore_x_dnd_types_set(e_comp->cm_selection, types, i);
}
- else
+ else if (source->mime_types)
{
- l = source->mime_types;
-
- if (source->mime_types)
- d2 = ecore_x_atom_get(e_comp->wl_comp_data->drag->types[0]);
- if (eina_list_count(source->mime_types) > 1)
- {
- l = eina_list_next(l);
- d3 = ecore_x_atom_get(eina_list_data_get(l));
- }
- if (eina_list_count(source->mime_types) > 2)
- {
- l = eina_list_next(l);
- d4 = ecore_x_atom_get(eina_list_data_get(l));
- }
+ if (eina_array_count(source->mime_types))
+ d2 = ecore_x_atom_get(eina_array_data_get(source->mime_types, 0));
+ if (eina_array_count(source->mime_types) > 1)
+ d3 = ecore_x_atom_get(eina_array_data_get(source->mime_types, 1));
+ if (eina_array_count(source->mime_types) > 2)
+ d4 = ecore_x_atom_get(eina_array_data_get(source->mime_types, 2));
}
ecore_x_client_message32_send(e_client_util_win_get(ec),
source->serial = serial;
if (mime_type)
- source->data_source.mime_types =
- eina_list_append(source->data_source.mime_types,
- eina_stringshare_add(mime_type));
+ {
+ if (!source->data_source.mime_types)
+ source->data_source.mime_types = eina_array_new(1);
+ eina_array_push(source->data_source.mime_types, eina_stringshare_add(mime_type));
+ }
if (fd > 0)
{
close(source->fd);
}
- E_FREE_LIST(source->data_source.mime_types, eina_stringshare_del);
+ _mime_types_free(&source->data_source);
wl_signal_emit(&source->data_source.destroy_signal, &source->data_source);
wl_array_release(&source->contents);
int x, y, num;
unsigned char *data;
const char **names = NULL;
- Eina_List *namelist = NULL;
+ Eina_Array *namelist = NULL;
E_Comp_Wl_Data_Source *source;
if (ecore_x_window_prop_property_get(ev->owner,
Ecore_X_Atom *types = (void*)data;
names = malloc(num * sizeof(void*));
+ namelist = eina_array_new(num);
for (i = 0; i < num; i++)
{
const char *name;
if (types[i] == string_atom)
{
name = names[i] = "UTF8_STRING";
- namelist = eina_list_append(namelist, eina_stringshare_add(WL_TEXT_STR));
+ eina_array_push(namelist, eina_stringshare_add(WL_TEXT_STR));
}
else
names[i] = name = ecore_x_atom_name_get(types[i]);
- namelist = eina_list_append(namelist, eina_stringshare_add(name));
+ eina_array_push(namelist, eina_stringshare_add(name));
}
if (num > 3)
{
source = e_comp_wl_clipboard_source_create(NULL, 0, -1);
dsource = e_comp_wl_data_manager_source_create(e_comp->wl_comp_data->xwl_client,
e_comp->wl_comp_data->mgr.resource, 1);
+ source->data_source.mime_types = eina_array_new(tgs->num_targets);
for (i = 0; i < tgs->num_targets; i++)
if (tgs->targets[i])
- source->data_source.mime_types = eina_list_append(source->data_source.mime_types, eina_stringshare_add(tgs->targets[i]));
+ eina_array_push(source->data_source.mime_types, eina_stringshare_add(tgs->targets[i]));
e_comp->wl_comp_data->clipboard.source = source;
e_comp->wl_comp_data->selection.data_source = &source->data_source;
source->data_source.resource = dsource->resource;
{
E_Comp_Wl_Data_Source *source;
const char *type;
- Eina_List *l;
+ Eina_Iterator *it = NULL;
if (e_comp->wl_comp_data->drag_source)
source = e_comp->wl_comp_data->drag_source;
Ecore_X_Atom *atoms;
int i = 0;
- atoms = alloca((2 + eina_list_count(source->mime_types)) * sizeof(void*));
- EINA_LIST_FOREACH(source->mime_types, l, type)
+ atoms = alloca((2 + eina_array_count(source->mime_types)) * sizeof(void*));
+ it = eina_array_iterator_new(source->mime_types);
+ EINA_ITERATOR_FOREACH(it, type)
atoms[i++] = ecore_x_atom_get(type);
atoms[i++] = timestamp_atom;
atoms[i++] = ECORE_X_ATOM_SELECTION_TARGETS;
Pipe *p;
name = ecore_x_atom_name_get(ev->target);
- EINA_LIST_FOREACH(source->mime_types, l, type)
+ it = eina_array_iterator_new(source->mime_types);
+ EINA_ITERATOR_FOREACH(it, type)
if (eina_streq(name, type))
{
E_Client *ec;
break;
}
}
+ eina_iterator_free(it);
return ECORE_CALLBACK_RENEW;
}