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

@ -97,13 +97,15 @@ data_source_notify_finish(E_Comp_Wl_Data_Source *source)
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, wl_data_source_send_action(source->resource,
source->current_dnd_action); 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);
} }
@ -117,10 +119,13 @@ data_offer_choose_action(E_Comp_Wl_Data_Offer *offer)
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; offer_actions = offer->dnd_actions;
preferred_action = offer->preferred_dnd_action; preferred_action = offer->preferred_dnd_action;
} else { }
else
{
offer_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; offer_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
} }
@ -135,7 +140,7 @@ data_offer_choose_action(E_Comp_Wl_Data_Offer *offer)
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;
@ -181,7 +186,8 @@ data_offer_set_actions(struct wl_client *client,
{ {
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_resource_post_error(offer->resource,
WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK, WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK,
"invalid action mask %x", dnd_actions); "invalid action mask %x", dnd_actions);
@ -190,7 +196,8 @@ data_offer_set_actions(struct wl_client *client,
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_resource_post_error(offer->resource,
WL_DATA_OFFER_ERROR_INVALID_ACTION, WL_DATA_OFFER_ERROR_INVALID_ACTION,
"invalid action %x", preferred_action); "invalid action %x", preferred_action);
@ -213,21 +220,24 @@ data_offer_finish(struct wl_client *client, struct wl_resource *resource)
/* 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_resource_post_error(offer->resource,
WL_DATA_OFFER_ERROR_INVALID_FINISH, WL_DATA_OFFER_ERROR_INVALID_FINISH,
"premature finish request"); "premature finish request");
return; 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_NONE:
case WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK: case WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK:
wl_resource_post_error(offer->resource, wl_resource_post_error(offer->resource,
WL_DATA_OFFER_ERROR_INVALID_OFFER, WL_DATA_OFFER_ERROR_INVALID_OFFER,
"offer finished with an invalid action"); "offer finished with an invalid action");
return; return;
default: default:
break; break;
} }
@ -254,11 +264,14 @@ _e_comp_wl_data_offer_cb_resource_destroy(struct wl_resource *resource)
* 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); data_source_notify_finish(offer->source);
} else if (offer->source->resource && }
else if (offer->source->resource &&
wl_resource_get_version(offer->source->resource) >= wl_resource_get_version(offer->source->resource) >=
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) { WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION)
{
wl_data_source_send_cancelled(offer->source->resource); wl_data_source_send_cancelled(offer->source->resource);
} }
@ -320,14 +333,16 @@ data_source_set_actions(struct wl_client *client,
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_resource_post_error(source->resource,
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK, WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
"cannot set actions more than once"); "cannot set actions more than once");
return; return;
} }
if (dnd_actions & ~ALL_ACTIONS) { if (dnd_actions & ~ALL_ACTIONS)
{
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 mask %x", dnd_actions); "invalid action mask %x", dnd_actions);
@ -341,7 +356,7 @@ data_source_set_actions(struct wl_client *client,
"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;
} }
@ -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;
@ -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;
@ -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)))
{ {
@ -672,7 +687,8 @@ _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_resource_post_error(source_resource,
WL_DATA_SOURCE_ERROR_INVALID_SOURCE, WL_DATA_SOURCE_ERROR_INVALID_SOURCE,
"cannot set drag-and-drop source as selection"); "cannot set drag-and-drop source as selection");
@ -710,7 +726,6 @@ _e_comp_wl_data_manager_cb_device_get(struct wl_client *client, struct wl_resour
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)
@ -728,7 +743,7 @@ _e_comp_wl_data_manager_cb_device_get(struct wl_client *client, struct wl_resour
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
}; };
@ -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;
@ -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,
@ -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
@ -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);
} }