apply formatting rules to e_comp_wl_data.c

This commit is contained in:
Mike Blumenkrantz 2016-04-19 17:38:22 -04:00
parent bfd204be71
commit 9dd36ff01c
1 changed files with 232 additions and 218 deletions

View File

@ -36,8 +36,8 @@
#endif #endif
#define ALL_ACTIONS (WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY | \ #define ALL_ACTIONS (WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY | \
WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE | \ WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE | \
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK) WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
static void static void
_mime_types_free(E_Comp_Wl_Data_Source *source) _mime_types_free(E_Comp_Wl_Data_Source *source)
@ -48,7 +48,7 @@ _mime_types_free(E_Comp_Wl_Data_Source *source)
eina_array_free(source->mime_types); eina_array_free(source->mime_types);
} }
static void 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) _e_comp_wl_data_offer_cb_accept(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t serial, const char *mime_type)
{ {
E_Comp_Wl_Data_Offer *offer; E_Comp_Wl_Data_Offer *offer;
@ -92,147 +92,157 @@ _e_comp_wl_data_offer_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl
static void static void
data_source_notify_finish(E_Comp_Wl_Data_Source *source) data_source_notify_finish(E_Comp_Wl_Data_Source *source)
{ {
if (!source->actions_set) if (!source->actions_set)
return; return;
if (source->offer->in_ask && if (source->offer->in_ask &&
wl_resource_get_version(source->resource) >= wl_resource_get_version(source->resource) >=
WL_DATA_SOURCE_ACTION_SINCE_VERSION) { WL_DATA_SOURCE_ACTION_SINCE_VERSION)
wl_data_source_send_action(source->resource, {
source->current_dnd_action); wl_data_source_send_action(source->resource,
} source->current_dnd_action);
}
if (wl_resource_get_version(source->resource) >= if (wl_resource_get_version(source->resource) >=
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) { WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION)
wl_data_source_send_dnd_finished(source->resource); {
} wl_data_source_send_dnd_finished(source->resource);
}
source->offer = NULL; source->offer = NULL;
} }
static uint32_t static uint32_t
data_offer_choose_action(E_Comp_Wl_Data_Offer *offer) data_offer_choose_action(E_Comp_Wl_Data_Offer *offer)
{ {
uint32_t available_actions, preferred_action = 0; uint32_t available_actions, preferred_action = 0;
uint32_t source_actions, offer_actions; uint32_t source_actions, offer_actions;
if (wl_resource_get_version(offer->resource) >= if (wl_resource_get_version(offer->resource) >=
WL_DATA_OFFER_ACTION_SINCE_VERSION) { WL_DATA_OFFER_ACTION_SINCE_VERSION)
offer_actions = offer->dnd_actions; {
preferred_action = offer->preferred_dnd_action; offer_actions = offer->dnd_actions;
} else { preferred_action = offer->preferred_dnd_action;
offer_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; }
} else
{
offer_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
}
if (wl_resource_get_version(offer->source->resource) >= if (wl_resource_get_version(offer->source->resource) >=
WL_DATA_SOURCE_ACTION_SINCE_VERSION) WL_DATA_SOURCE_ACTION_SINCE_VERSION)
source_actions = offer->source->dnd_actions; source_actions = offer->source->dnd_actions;
else else
source_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; source_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
available_actions = offer_actions & source_actions; available_actions = offer_actions & source_actions;
if (!available_actions) if (!available_actions)
return WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE; return WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
if (//offer->source->seat && if ( //offer->source->seat &&
offer->source->compositor_action & available_actions) offer->source->compositor_action & available_actions)
return offer->source->compositor_action; return offer->source->compositor_action;
/* If the dest side has a preferred DnD action, use it */ /* If the dest side has a preferred DnD action, use it */
if ((preferred_action & available_actions) != 0) if ((preferred_action & available_actions) != 0)
return preferred_action; return preferred_action;
/* Use the first found action, in bit order */ /* Use the first found action, in bit order */
return 1 << (ffs(available_actions) - 1); return 1 << (ffs(available_actions) - 1);
} }
static void static void
data_offer_update_action(E_Comp_Wl_Data_Offer *offer) data_offer_update_action(E_Comp_Wl_Data_Offer *offer)
{ {
uint32_t action; uint32_t action;
if (!offer->source || !offer->source->actions_set) if (!offer->source || !offer->source->actions_set)
return; return;
action = data_offer_choose_action(offer); action = data_offer_choose_action(offer);
if (offer->source->current_dnd_action == action) if (offer->source->current_dnd_action == action)
return; return;
offer->source->current_dnd_action = action; offer->source->current_dnd_action = action;
if (offer->in_ask) if (offer->in_ask)
return; return;
if (wl_resource_get_version(offer->source->resource) >= if (wl_resource_get_version(offer->source->resource) >=
WL_DATA_SOURCE_ACTION_SINCE_VERSION) WL_DATA_SOURCE_ACTION_SINCE_VERSION)
wl_data_source_send_action(offer->source->resource, action); wl_data_source_send_action(offer->source->resource, action);
if (wl_resource_get_version(offer->resource) >= if (wl_resource_get_version(offer->resource) >=
WL_DATA_OFFER_ACTION_SINCE_VERSION) WL_DATA_OFFER_ACTION_SINCE_VERSION)
wl_data_offer_send_action(offer->resource, action); wl_data_offer_send_action(offer->resource, action);
} }
static void static void
data_offer_set_actions(struct wl_client *client, data_offer_set_actions(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
uint32_t dnd_actions, uint32_t preferred_action) uint32_t dnd_actions, uint32_t preferred_action)
{ {
E_Comp_Wl_Data_Offer *offer = wl_resource_get_user_data(resource); E_Comp_Wl_Data_Offer *offer = wl_resource_get_user_data(resource);
if (dnd_actions & ~ALL_ACTIONS) { if (dnd_actions & ~ALL_ACTIONS)
wl_resource_post_error(offer->resource, {
WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK, wl_resource_post_error(offer->resource,
"invalid action mask %x", dnd_actions); WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK,
return; "invalid action mask %x", dnd_actions);
} return;
}
if (preferred_action && if (preferred_action &&
(!(preferred_action & dnd_actions) || (!(preferred_action & dnd_actions) ||
__builtin_popcount(preferred_action) > 1)) { __builtin_popcount(preferred_action) > 1))
wl_resource_post_error(offer->resource, {
WL_DATA_OFFER_ERROR_INVALID_ACTION, wl_resource_post_error(offer->resource,
"invalid action %x", preferred_action); WL_DATA_OFFER_ERROR_INVALID_ACTION,
return; "invalid action %x", preferred_action);
} return;
}
offer->dnd_actions = dnd_actions; offer->dnd_actions = dnd_actions;
offer->preferred_dnd_action = preferred_action; offer->preferred_dnd_action = preferred_action;
data_offer_update_action(offer); data_offer_update_action(offer);
} }
static void static void
data_offer_finish(struct wl_client *client, struct wl_resource *resource) data_offer_finish(struct wl_client *client, struct wl_resource *resource)
{ {
E_Comp_Wl_Data_Offer *offer = wl_resource_get_user_data(resource); E_Comp_Wl_Data_Offer *offer = wl_resource_get_user_data(resource);
if (!offer->source || offer->source->offer != offer) if (!offer->source || offer->source->offer != offer)
return; return;
/* Disallow finish while we have a grab driving drag-and-drop, or /* Disallow finish while we have a grab driving drag-and-drop, or
* if the negotiation is not at the right stage * if the negotiation is not at the right stage
*/ */
if (//offer->source->seat || if ( //offer->source->seat ||
!offer->source->accepted) { !offer->source->accepted)
wl_resource_post_error(offer->resource, {
WL_DATA_OFFER_ERROR_INVALID_FINISH, wl_resource_post_error(offer->resource,
"premature finish request"); WL_DATA_OFFER_ERROR_INVALID_FINISH,
return; "premature finish request");
} return;
}
switch (offer->source->current_dnd_action) { switch (offer->source->current_dnd_action)
case WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE: {
case WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK: case WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE:
wl_resource_post_error(offer->resource, case WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK:
WL_DATA_OFFER_ERROR_INVALID_OFFER, wl_resource_post_error(offer->resource,
"offer finished with an invalid action"); WL_DATA_OFFER_ERROR_INVALID_OFFER,
return; "offer finished with an invalid action");
default: return;
break;
}
data_source_notify_finish(offer->source); default:
break;
}
data_source_notify_finish(offer->source);
} }
/* called by wl_resource_destroy */ /* called by wl_resource_destroy */
@ -241,30 +251,33 @@ _e_comp_wl_data_offer_cb_resource_destroy(struct wl_resource *resource)
{ {
E_Comp_Wl_Data_Offer *offer = wl_resource_get_user_data(resource); E_Comp_Wl_Data_Offer *offer = wl_resource_get_user_data(resource);
if (!offer->source) if (!offer->source)
goto out; goto out;
wl_list_remove(&offer->source_destroy_listener.link); wl_list_remove(&offer->source_destroy_listener.link);
if (offer->source->offer != offer) if (offer->source->offer != offer)
goto out; goto out;
/* If the drag destination has version < 3, wl_data_offer.finish /* If the drag destination has version < 3, wl_data_offer.finish
* won't be called, so do this here as a safety net, because * won't be called, so do this here as a safety net, because
* we still want the version >=3 drag source to be happy. * we still want the version >=3 drag source to be happy.
*/ */
if (wl_resource_get_version(offer->resource) < if (wl_resource_get_version(offer->resource) <
WL_DATA_OFFER_ACTION_SINCE_VERSION) { WL_DATA_OFFER_ACTION_SINCE_VERSION)
data_source_notify_finish(offer->source); {
} else if (offer->source->resource && data_source_notify_finish(offer->source);
wl_resource_get_version(offer->source->resource) >= }
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) { else if (offer->source->resource &&
wl_data_source_send_cancelled(offer->source->resource); wl_resource_get_version(offer->source->resource) >=
} WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION)
{
wl_data_source_send_cancelled(offer->source->resource);
}
offer->source->offer = NULL; offer->source->offer = NULL;
out: out:
free(offer); free(offer);
} }
/* called by emission of source->destroy_signal */ /* called by emission of source->destroy_signal */
@ -314,36 +327,38 @@ _e_comp_wl_data_source_cb_destroy(struct wl_client *client EINA_UNUSED, struct w
static void static void
data_source_set_actions(struct wl_client *client, data_source_set_actions(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
uint32_t dnd_actions) uint32_t dnd_actions)
{ {
E_Comp_Wl_Data_Source *source = E_Comp_Wl_Data_Source *source =
wl_resource_get_user_data(resource); wl_resource_get_user_data(resource);
if (source->actions_set) { if (source->actions_set)
wl_resource_post_error(source->resource, {
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK, wl_resource_post_error(source->resource,
"cannot set actions more than once"); WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
return; "cannot set actions more than once");
} return;
}
if (dnd_actions & ~ALL_ACTIONS) { if (dnd_actions & ~ALL_ACTIONS)
wl_resource_post_error(source->resource, {
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK, wl_resource_post_error(source->resource,
"invalid action mask %x", dnd_actions); WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
return; "invalid action mask %x", dnd_actions);
} return;
}
/* FIXME /* FIXME
if (source->seat) { if (source->seat) {
wl_resource_post_error(source->resource, wl_resource_post_error(source->resource,
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK, WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
"invalid action change after " "invalid action change after "
"wl_data_device.start_drag"); "wl_data_device.start_drag");
return; return;
} }
*/ */
source->dnd_actions = dnd_actions; source->dnd_actions = dnd_actions;
source->actions_set = 1; source->actions_set = 1;
} }
/* called by wl_resource_destroy */ /* called by wl_resource_destroy */
@ -362,14 +377,14 @@ _e_comp_wl_data_source_cb_resource_destroy(struct wl_resource *resource)
} }
static void static void
_e_comp_wl_data_source_target_send(E_Comp_Wl_Data_Source *source, uint32_t serial EINA_UNUSED, const char* mime_type) _e_comp_wl_data_source_target_send(E_Comp_Wl_Data_Source *source, uint32_t serial EINA_UNUSED, const char *mime_type)
{ {
DBG("Data Source Target Send"); DBG("Data Source Target Send");
wl_data_source_send_target(source->resource, mime_type); wl_data_source_send_target(source->resource, mime_type);
} }
static void static void
_e_comp_wl_data_source_send_send(E_Comp_Wl_Data_Source *source, const char* mime_type, int32_t fd) _e_comp_wl_data_source_send_send(E_Comp_Wl_Data_Source *source, const char *mime_type, int32_t fd)
{ {
DBG("Data Source Source Send"); DBG("Data Source Source Send");
wl_data_source_send_send(source->resource, mime_type, fd); wl_data_source_send_send(source->resource, mime_type, fd);
@ -397,7 +412,7 @@ _e_comp_wl_data_device_destroy_selection_data_source(struct wl_listener *listene
struct wl_resource *data_device_res = NULL, *focus = NULL; struct wl_resource *data_device_res = NULL, *focus = NULL;
DBG("Data Device Destroy Selection Source"); DBG("Data Device Destroy Selection Source");
if (!(source = (E_Comp_Wl_Data_Source*)data)) if (!(source = (E_Comp_Wl_Data_Source *)data))
return; return;
e_comp_wl->selection.data_source = NULL; e_comp_wl->selection.data_source = NULL;
@ -409,7 +424,7 @@ _e_comp_wl_data_device_destroy_selection_data_source(struct wl_listener *listene
{ {
if (source->resource) if (source->resource)
data_device_res = data_device_res =
e_comp_wl_data_find_for_client(wl_resource_get_client(source->resource)); e_comp_wl_data_find_for_client(wl_resource_get_client(source->resource));
if (data_device_res) if (data_device_res)
wl_data_device_send_selection(data_device_res, NULL); wl_data_device_send_selection(data_device_res, NULL);
@ -418,7 +433,7 @@ _e_comp_wl_data_device_destroy_selection_data_source(struct wl_listener *listene
wl_signal_emit(&e_comp_wl->selection.signal, e_comp->wl_comp_data); wl_signal_emit(&e_comp_wl->selection.signal, e_comp->wl_comp_data);
} }
static struct wl_resource* static struct wl_resource *
_e_comp_wl_data_device_data_offer_create(E_Comp_Wl_Data_Source *source, struct wl_resource *data_device) _e_comp_wl_data_device_data_offer_create(E_Comp_Wl_Data_Source *source, struct wl_resource *data_device)
{ {
E_Comp_Wl_Data_Offer *offer; E_Comp_Wl_Data_Offer *offer;
@ -430,8 +445,8 @@ _e_comp_wl_data_device_data_offer_create(E_Comp_Wl_Data_Source *source, struct w
offer = E_NEW(E_Comp_Wl_Data_Offer, 1); offer = E_NEW(E_Comp_Wl_Data_Offer, 1);
if (!offer) return NULL; if (!offer) return NULL;
offer->resource = offer->resource =
wl_resource_create(wl_resource_get_client(data_device), wl_resource_create(wl_resource_get_client(data_device),
&wl_data_offer_interface, wl_resource_get_version(data_device), 0); &wl_data_offer_interface, wl_resource_get_version(data_device), 0);
if (!offer->resource) if (!offer->resource)
{ {
@ -439,12 +454,12 @@ _e_comp_wl_data_device_data_offer_create(E_Comp_Wl_Data_Source *source, struct w
return NULL; return NULL;
} }
wl_resource_set_implementation(offer->resource, wl_resource_set_implementation(offer->resource,
&_e_data_offer_interface, offer, &_e_data_offer_interface, offer,
_e_comp_wl_data_offer_cb_resource_destroy); _e_comp_wl_data_offer_cb_resource_destroy);
offer->source = source; offer->source = source;
source->offer = offer; source->offer = offer;
offer->source_destroy_listener.notify = offer->source_destroy_listener.notify =
_e_comp_wl_data_offer_cb_source_destroy; _e_comp_wl_data_offer_cb_source_destroy;
wl_signal_add(&source->destroy_signal, &offer->source_destroy_listener); wl_signal_add(&source->destroy_signal, &offer->source_destroy_listener);
@ -466,7 +481,7 @@ _e_comp_wl_data_device_selection_set(void *data EINA_UNUSED, E_Comp_Wl_Data_Sour
E_Comp_Wl_Data_Source *sel_source; E_Comp_Wl_Data_Source *sel_source;
struct wl_resource *offer_res, *data_device_res, *focus = NULL; struct wl_resource *offer_res, *data_device_res, *focus = NULL;
sel_source = (E_Comp_Wl_Data_Source*)e_comp_wl->selection.data_source; sel_source = (E_Comp_Wl_Data_Source *)e_comp_wl->selection.data_source;
if (sel_source && ((sel_source->serial != serial) || (sel_source != source))) if (sel_source && ((sel_source->serial != serial) || (sel_source != source)))
{ {
@ -503,9 +518,9 @@ _e_comp_wl_data_device_selection_set(void *data EINA_UNUSED, E_Comp_Wl_Data_Sour
if (source) if (source)
{ {
e_comp_wl->selection.data_source_listener.notify = e_comp_wl->selection.data_source_listener.notify =
_e_comp_wl_data_device_destroy_selection_data_source; _e_comp_wl_data_device_destroy_selection_data_source;
wl_signal_add(&source->destroy_signal, wl_signal_add(&source->destroy_signal,
&e_comp_wl->selection.data_source_listener); &e_comp_wl->selection.data_source_listener);
} }
} }
@ -543,39 +558,39 @@ _e_comp_wl_data_device_drag_finished(E_Drag *drag, int dropped)
} }
else else
#endif #endif
{ {
struct wl_resource *res; struct wl_resource *res;
E_Comp_Wl_Data_Source *data_source = e_comp_wl->drag_source; E_Comp_Wl_Data_Source *data_source = e_comp_wl->drag_source;
res = e_comp_wl_data_find_for_client(wl_resource_get_client(e_comp_wl->selection.target->comp_data->surface)); res = e_comp_wl_data_find_for_client(wl_resource_get_client(e_comp_wl->selection.target->comp_data->surface));
if (res) if (res)
{ {
if (data_source->accepted && data_source->current_dnd_action) if (data_source->accepted && data_source->current_dnd_action)
{ {
wl_data_device_send_drop(res); wl_data_device_send_drop(res);
if (wl_resource_get_version(data_source->resource) >= if (wl_resource_get_version(data_source->resource) >=
WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION) WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION)
wl_data_source_send_dnd_drop_performed(data_source->resource); wl_data_source_send_dnd_drop_performed(data_source->resource);
data_source->offer->in_ask = data_source->current_dnd_action == data_source->offer->in_ask = data_source->current_dnd_action ==
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK; WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
} }
else if (wl_resource_get_version(data_source->resource) >= else if (wl_resource_get_version(data_source->resource) >=
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION)
wl_data_source_send_cancelled(data_source->resource); wl_data_source_send_cancelled(data_source->resource);
wl_data_device_send_leave(res); wl_data_device_send_leave(res);
} }
#ifndef HAVE_WAYLAND_ONLY #ifndef HAVE_WAYLAND_ONLY
if (e_comp_util_has_xwayland()) if (e_comp_util_has_xwayland())
{ {
ecore_x_selection_owner_set(0, ECORE_X_ATOM_SELECTION_XDND, ecore_x_selection_owner_set(0, ECORE_X_ATOM_SELECTION_XDND,
ecore_x_current_time_get()); ecore_x_current_time_get());
ecore_x_window_hide(e_comp->cm_selection); ecore_x_window_hide(e_comp->cm_selection);
} }
#endif #endif
e_comp_wl->selection.target = NULL; e_comp_wl->selection.target = NULL;
e_comp_wl->drag_source = NULL; e_comp_wl->drag_source = NULL;
} }
} }
} }
@ -672,17 +687,18 @@ _e_comp_wl_data_device_cb_selection_set(struct wl_client *client EINA_UNUSED, st
DBG("Data Device Selection Set"); DBG("Data Device Selection Set");
if (!source_resource) return; if (!source_resource) return;
if (!(source = wl_resource_get_user_data(source_resource))) return; if (!(source = wl_resource_get_user_data(source_resource))) return;
if (source->actions_set) { if (source->actions_set)
wl_resource_post_error(source_resource, {
WL_DATA_SOURCE_ERROR_INVALID_SOURCE, wl_resource_post_error(source_resource,
"cannot set drag-and-drop source as selection"); WL_DATA_SOURCE_ERROR_INVALID_SOURCE,
return; "cannot set drag-and-drop source as selection");
} return;
}
_e_comp_wl_data_device_selection_set(e_comp->wl_comp_data, source, serial); _e_comp_wl_data_device_selection_set(e_comp->wl_comp_data, source, serial);
} }
static void static void
_e_comp_wl_data_device_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *resource) _e_comp_wl_data_device_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
{ {
DBG("Data Device Release"); DBG("Data Device Release");
@ -703,14 +719,13 @@ _e_comp_wl_data_device_cb_unbind(struct wl_resource *resource)
eina_hash_del_by_key(e_comp_wl->mgr.data_resources, &wc); eina_hash_del_by_key(e_comp_wl->mgr.data_resources, &wc);
} }
static void static void
_e_comp_wl_data_manager_cb_device_get(struct wl_client *client, struct wl_resource *manager_resource, uint32_t id, struct wl_resource *seat_resource EINA_UNUSED) _e_comp_wl_data_manager_cb_device_get(struct wl_client *client, struct wl_resource *manager_resource, uint32_t id, struct wl_resource *seat_resource EINA_UNUSED)
{ {
struct wl_resource *res; struct wl_resource *res;
DBG("Data Manager Device Get"); DBG("Data Manager Device Get");
/* try to create the data device resource */ /* try to create the data device resource */
res = wl_resource_create(client, &wl_data_device_interface, wl_resource_get_version(manager_resource), id); res = wl_resource_create(client, &wl_data_device_interface, wl_resource_get_version(manager_resource), id);
if (!res) if (!res)
@ -722,13 +737,13 @@ _e_comp_wl_data_manager_cb_device_get(struct wl_client *client, struct wl_resour
eina_hash_add(e_comp_wl->mgr.data_resources, &client, res); eina_hash_add(e_comp_wl->mgr.data_resources, &client, res);
wl_resource_set_implementation(res, &_e_data_device_interface, wl_resource_set_implementation(res, &_e_data_device_interface,
e_comp->wl_comp_data, e_comp->wl_comp_data,
_e_comp_wl_data_device_cb_unbind); _e_comp_wl_data_device_cb_unbind);
} }
static const struct wl_data_device_manager_interface _e_manager_interface = static const struct wl_data_device_manager_interface _e_manager_interface =
{ {
(void*)e_comp_wl_data_manager_source_create, (void *)e_comp_wl_data_manager_source_create,
_e_comp_wl_data_manager_cb_device_get _e_comp_wl_data_manager_cb_device_get
}; };
@ -744,14 +759,14 @@ static const struct wl_data_device_manager_interface _e_manager_interface =
/* e_comp_wl->mgr.resource = NULL; */ /* e_comp_wl->mgr.resource = NULL; */
/* } */ /* } */
static void static void
_e_comp_wl_data_cb_bind_manager(struct wl_client *client, void *data EINA_UNUSED, uint32_t version EINA_UNUSED, uint32_t id) _e_comp_wl_data_cb_bind_manager(struct wl_client *client, void *data EINA_UNUSED, uint32_t version EINA_UNUSED, uint32_t id)
{ {
struct wl_resource *res; struct wl_resource *res;
/* try to create data manager resource */ /* try to create data manager resource */
e_comp_wl->mgr.resource = res = e_comp_wl->mgr.resource = res =
wl_resource_create(client, &wl_data_device_manager_interface, 3, id); wl_resource_create(client, &wl_data_device_manager_interface, 3, id);
if (!res) if (!res)
{ {
ERR("Could not create data device manager"); ERR("Could not create data device manager");
@ -772,13 +787,13 @@ _e_comp_wl_clipboard_offer_load(void *data, Ecore_Fd_Handler *handler)
int len; int len;
int fd; int fd;
if (!(offer = (E_Comp_Wl_Clipboard_Offer*)data)) if (!(offer = (E_Comp_Wl_Clipboard_Offer *)data))
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
fd = ecore_main_fd_handler_fd_get(handler); fd = ecore_main_fd_handler_fd_get(handler);
size = offer->source->contents.size; size = offer->source->contents.size;
p = (char*)offer->source->contents.data; p = (char *)offer->source->contents.data;
len = write(fd, p + offer->offset, size - offer->offset); len = write(fd, p + offer->offset, size - offer->offset);
if (len > 0) offer->offset += len; if (len > 0) offer->offset += len;
@ -794,7 +809,7 @@ _e_comp_wl_clipboard_offer_load(void *data, Ecore_Fd_Handler *handler)
} }
static void static void
_e_comp_wl_clipboard_offer_create(E_Comp_Wl_Clipboard_Source* source, int fd) _e_comp_wl_clipboard_offer_create(E_Comp_Wl_Clipboard_Source *source, int fd)
{ {
E_Comp_Wl_Clipboard_Offer *offer; E_Comp_Wl_Clipboard_Offer *offer;
@ -804,9 +819,9 @@ _e_comp_wl_clipboard_offer_create(E_Comp_Wl_Clipboard_Source* source, int fd)
offer->source = source; offer->source = source;
source->ref++; source->ref++;
offer->fd_handler = offer->fd_handler =
ecore_main_fd_handler_add(fd, ECORE_FD_WRITE, ecore_main_fd_handler_add(fd, ECORE_FD_WRITE,
_e_comp_wl_clipboard_offer_load, offer, _e_comp_wl_clipboard_offer_load, offer,
NULL, NULL); NULL, NULL);
} }
static Eina_Bool static Eina_Bool
@ -816,8 +831,7 @@ _e_comp_wl_clipboard_source_save(void *data EINA_UNUSED, Ecore_Fd_Handler *handl
char *p; char *p;
int len, size; int len, size;
if (!(source = (E_Comp_Wl_Clipboard_Source *)e_comp_wl->clipboard.source))
if (!(source = (E_Comp_Wl_Clipboard_Source*)e_comp_wl->clipboard.source))
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
/* extend contents buffer */ /* extend contents buffer */
@ -827,7 +841,7 @@ _e_comp_wl_clipboard_source_save(void *data EINA_UNUSED, Ecore_Fd_Handler *handl
source->contents.size -= CLIPBOARD_CHUNK; source->contents.size -= CLIPBOARD_CHUNK;
} }
p = (char*)source->contents.data + source->contents.size; p = (char *)source->contents.data + source->contents.size;
size = source->contents.alloc - source->contents.size; size = source->contents.alloc - source->contents.size;
len = read(source->fd, p, size); len = read(source->fd, p, size);
@ -858,7 +872,7 @@ _e_comp_wl_clipboard_source_target_send(E_Comp_Wl_Data_Source *source EINA_UNUSE
static void static void
_e_comp_wl_clipboard_source_send_send(E_Comp_Wl_Data_Source *source, const char *mime_type, int fd) _e_comp_wl_clipboard_source_send_send(E_Comp_Wl_Data_Source *source, const char *mime_type, int fd)
{ {
E_Comp_Wl_Clipboard_Source* clip_source; E_Comp_Wl_Clipboard_Source *clip_source;
char *t; char *t;
clip_source = container_of(source, E_Comp_Wl_Clipboard_Source, data_source); clip_source = container_of(source, E_Comp_Wl_Clipboard_Source, data_source);
@ -884,8 +898,8 @@ _e_comp_wl_clipboard_selection_set(struct wl_listener *listener EINA_UNUSED, voi
int p[2]; int p[2];
char *mime_type; char *mime_type;
sel_source = (E_Comp_Wl_Data_Source*) e_comp_wl->selection.data_source; sel_source = (E_Comp_Wl_Data_Source *)e_comp_wl->selection.data_source;
clip_source = (E_Comp_Wl_Clipboard_Source*) e_comp_wl->clipboard.source; clip_source = (E_Comp_Wl_Clipboard_Source *)e_comp_wl->clipboard.source;
if (!sel_source) if (!sel_source)
{ {
@ -966,9 +980,8 @@ e_comp_wl_data_device_send_enter(E_Client *ec)
if (offer_res) if (offer_res)
{ {
if (wl_resource_get_version(offer_res) >= WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION) if (wl_resource_get_version(offer_res) >= WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION)
wl_data_offer_send_source_actions (offer_res, drag_source->dnd_actions); wl_data_offer_send_source_actions(offer_res, drag_source->dnd_actions);
} }
} }
e_comp_wl->selection.target = ec; e_comp_wl->selection.target = ec;
evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_DEL, evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_DEL,
@ -1057,7 +1070,7 @@ e_comp_wl_data_device_send_offer(E_Client *ec)
E_Comp_Wl_Data_Source *source; E_Comp_Wl_Data_Source *source;
data_device_res = data_device_res =
e_comp_wl_data_find_for_client(wl_resource_get_client(ec->comp_data->surface)); e_comp_wl_data_find_for_client(wl_resource_get_client(ec->comp_data->surface));
if (!data_device_res) return NULL; if (!data_device_res) return NULL;
source = e_comp_wl->drag_source; source = e_comp_wl->drag_source;
if (source) if (source)
@ -1086,7 +1099,7 @@ e_comp_wl_data_device_keyboard_focus_set(void)
ERR("No focused resource"); ERR("No focused resource");
return; return;
} }
source = (E_Comp_Wl_Data_Source*)e_comp_wl->selection.data_source; source = (E_Comp_Wl_Data_Source *)e_comp_wl->selection.data_source;
#ifndef HAVE_WAYLAND_ONLY #ifndef HAVE_WAYLAND_ONLY
do do
@ -1142,7 +1155,7 @@ e_comp_wl_data_manager_init(void)
return EINA_TRUE; return EINA_TRUE;
} }
EINTERN void EINTERN void
e_comp_wl_data_manager_shutdown(void) e_comp_wl_data_manager_shutdown(void)
{ {
/* destroy the global manager resource */ /* destroy the global manager resource */
@ -1258,3 +1271,4 @@ e_comp_wl_clipboard_source_unref(E_Comp_Wl_Clipboard_Source *source)
wl_array_release(&source->contents); wl_array_release(&source->contents);
free(source); free(source);
} }