struct livebox_buffer_data {
int is_pd;
int accelerated;
+
+ /* for Buffer event wrapper */
+ int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *);
+ void *cbdata;
};
PUBLIC const int DONE = 0x00;
return LB_STATUS_ERROR_NOT_EXIST;
}
+/*!
+ * \note
+ * The last "data" argument is same with "user_data" which is managed by "provider_set_user_data).
+ */
+static inline int event_handler_wrapper(struct livebox_buffer *buffer, enum buffer_event event, double timestamp, double x, double y, void *data)
+{
+ const char *pkgname;
+ const char *id;
+ struct livebox_buffer_data *cbdata = data;
+ int ret;
+
+ pkgname = provider_buffer_pkgname(buffer);
+ id = provider_buffer_pkgname(buffer);
+
+ ret = cbdata->handler(buffer, event, timestamp, x, y, cbdata->cbdata);
+
+ switch (event) {
+ case BUFFER_EVENT_HIGHLIGHT:
+ case BUFFER_EVENT_HIGHLIGHT_NEXT:
+ case BUFFER_EVENT_HIGHLIGHT_PREV:
+ case BUFFER_EVENT_ACTIVATE:
+ case BUFFER_EVENT_ACTION_UP:
+ case BUFFER_EVENT_ACTION_DOWN:
+ case BUFFER_EVENT_SCROLL_UP:
+ case BUFFER_EVENT_SCROLL_MOVE:
+ case BUFFER_EVENT_SCROLL_DOWN:
+ case BUFFER_EVENT_UNHIGHLIGHT:
+ if (ret < 0)
+ (void)provider_send_access_status(pkgname, id, LB_ACCESS_STATUS_ERROR);
+ else
+ (void)provider_send_access_status(pkgname, id, ret);
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+static inline int default_event_handler(struct livebox_buffer *buffer, enum buffer_event event, double timestamp, double x, double y, void *data)
+{
+ /* NOP */
+ return 0;
+}
+
PUBLIC struct livebox_buffer *livebox_acquire_buffer(const char *filename, int is_pd, int width, int height, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *), void *data)
{
struct livebox_buffer_data *user_data;
struct livebox_buffer *handle;
char *uri;
int uri_len;
+ struct event_cbdata *cbdata;
if (!filename || !width || !height) {
ErrPrint("Invalid argument: %p(%dx%d)\n", filename, width, height);
}
user_data->is_pd = is_pd;
+ user_data->handler = handler ? handler : default_event_handler;
+ user_data->cbdata = data;
uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1;
uri = malloc(uri_len);
return NULL;
}
- handle = provider_buffer_acquire((!!is_pd) ? TYPE_PD : TYPE_LB, pkgname, uri, width, height, sizeof(int), handler, data);
+ handle = provider_buffer_acquire((!!is_pd) ? TYPE_PD : TYPE_LB, pkgname, uri, width, height, sizeof(int), event_handler_wrapper, user_data);
DbgPrint("Acquire buffer for PD(%s), %s, %p\n", pkgname, uri, handle);
free(uri);
+ if (!handle) {
+ free(user_data);
+ return NULL;
+ }
(void)provider_buffer_set_user_data(handle, user_data);
return handle;
#include <Elementary.h>
+#include <string.h>
#include <Ecore_Evas.h>
#include <Evas.h>
#include <dlog.h>
#include <livebox-errno.h>
+#include <livebox-service.h>
#include "livebox.h"
struct livebox_buffer *handle; /*!< Livebox buffer handle */
Evas_Object *window; /*!< Parent evas object - WARN: Incompatible with the elm_win object */
int is_hw; /*!< 1 if a buffer is created on the H/W accelerated place or 0 */
-
- Evas_Object *elm_parent;
};
/*!
*/
static int event_handler_cb(struct livebox_buffer *handler, enum buffer_event evt, double timestamp, double x, double y, void *data)
{
- Elm_Access_Action_Info *info;
- Elm_Access_Action_Type action;
struct info *info = data;
+ Elm_Access_Action_Info action_info;
+ Elm_Access_Action_Type action_type;
Evas *e;
+ Ecore_Evas *ee;
+ Evas_Object *parent_elm;
int ix;
int iy;
+ int ret = 0;
if (!info->handle) {
/* Just ignore this event */
ix = info->width * x;
iy = info->height * y;
+ memset(&action_info, 0, sizeof(action_info));
+
e = evas_object_evas_get(info->window);
+ ee = ecore_evas_ecore_evas_get(e);
+ parent_elm = ecore_evas_data_get(ee, "parent,elm");
/*!
* \note
evas_event_feed_mouse_out(e, timestamp + 0.01f, NULL); /* + 0.1f just for fake event */
break;
case BUFFER_EVENT_HIGHLIGHT:
- if (!info->elm_parent)
- return LB_ACCESS_STATUS_ERROR;
-
- action = ELM_ACCESS_ACTION_HIGHLIGHT;
- info->x = x;
- info->y = y;
- ret = elm_access_action(info->elm_parent, action, info);
- DbgPrint("ACCESS_HIGHLIGHT: %dx%d returns %d\n", x, y, ret);
+ if (!parent_elm) {
+ ret = LB_ACCESS_STATUS_ERROR;
+ break;
+ }
+ action_type = ELM_ACCESS_ACTION_HIGHLIGHT;
+ action_info.x = ix;
+ action_info.y = iy;
+ ret = elm_access_action(parent_elm, action_type, &action_info);
ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
break;
case BUFFER_EVENT_HIGHLIGHT_NEXT:
- if (!info->elm_parent)
- return LB_ACCESS_STATUS_ERROR;
- action = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
- info->highlight_cycle = EINA_FALSE;
- ret = elm_access_action(info->elm_parent, action, info);
- DbgPrint("ACCESS_HIGHLIGHT_NEXT, returns %d\n", ret);
+ if (!parent_elm) {
+ ret = LB_ACCESS_STATUS_ERROR;
+ break;
+ }
+ action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
+ action_info.highlight_cycle = EINA_FALSE;
+ ret = elm_access_action(parent_elm, action_type, &action_info);
ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_LAST : LB_ACCESS_STATUS_DONE;
break;
case BUFFER_EVENT_HIGHLIGHT_PREV:
- if (!info->elm_parent)
- return LB_ACCESS_STATUS_ERROR;
- action = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
- info->highlight_cycle = EINA_FALSE;
- ret = elm_access_action(info->elm_parent, action, info);
- DbgPrint("ACCESS_HIGHLIGHT_PREV, returns %d\n", ret);
+ if (!parent_elm) {
+ ret = LB_ACCESS_STATUS_ERROR;
+ break;
+ }
+ action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
+ action_info.highlight_cycle = EINA_FALSE;
+ ret = elm_access_action(parent_elm, action_type, &action_info);
ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_FIRST : LB_ACCESS_STATUS_DONE;
break;
case BUFFER_EVENT_ACTIVATE:
- if (!info->elm_parent)
- return LB_ACCESS_STATUS_ERROR;
- action = ELM_ACCESS_ACTION_ACTIVATE;
- ret = elm_access_action(info->elm_parent, action, info);
- DbgPrint("ACCESS_ACTIVATE, returns %d\n", ret);
+ if (!parent_elm) {
+ ret = LB_ACCESS_STATUS_ERROR;
+ break;
+ }
+ action_type = ELM_ACCESS_ACTION_ACTIVATE;
+ ret = elm_access_action(parent_elm, action_type, &action_info);
ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
break;
case BUFFER_EVENT_ACTION_UP:
- if (!info->elm_parent)
- return LB_ACCESS_STATUS_ERROR;
- action = ELM_ACCESS_ACTION_UP;
- ret = elm_access_action(info->elm_parent, action, info);
- DbgPrint("ACCESS_ACTION(%d), returns %d\n", down, ret);
+ if (!parent_elm) {
+ ret = LB_ACCESS_STATUS_ERROR;
+ break;
+ }
+ action_type = ELM_ACCESS_ACTION_UP;
+ ret = elm_access_action(parent_elm, action_type, &action_info);
+ ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
break;
case BUFFER_EVENT_ACTION_DOWN:
- if (!info->elm_parent)
- return LB_ACCESS_STATUS_ERROR;
- action = ELM_ACCESS_ACTION_DOWN;
- ret = elm_access_action(info->elm_parent, action, info);
- DbgPrint("ACCESS_ACTION(%d), returns %d\n", down, ret);
+ if (!parent_elm) {
+ ret = LB_ACCESS_STATUS_ERROR;
+ break;
+ }
+ action_type = ELM_ACCESS_ACTION_DOWN;
+ ret = elm_access_action(parent_elm, action_type, &action_info);
ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
break;
case BUFFER_EVENT_SCROLL_UP:
- if (!info->elm_parent)
- return LB_ACCESS_STATUS_ERROR;
- action = ELM_ACCESS_ACTION_SCROLL;
- info->x = ix;
- info->y = iy;
- info->mouse_type = 0;
- ret = elm_access_action(info->elm_parent, action, info);
- DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret);
+ if (!parent_elm) {
+ ret = LB_ACCESS_STATUS_ERROR;
+ break;
+ }
+ action_type = ELM_ACCESS_ACTION_SCROLL;
+ action_info.x = ix;
+ action_info.y = iy;
+ action_info.mouse_type = 0;
+ ret = elm_access_action(parent_elm, action_type, &action_info);
ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
break;
case BUFFER_EVENT_SCROLL_MOVE:
- if (!info->elm_parent)
- return LB_ACCESS_STATUS_ERROR;
- action = ELM_ACCESS_ACTION_SCROLL;
- info->x = ix;
- info->y = iy;
- info->mouse_type = -1;
- ret = elm_access_action(info->elm_parent, action, info);
- DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret);
+ if (!parent_elm) {
+ ret = LB_ACCESS_STATUS_ERROR;
+ break;
+ }
+ action_info.x = ix;
+ action_info.y = iy;
+ action_info.mouse_type = 1;
+ ret = elm_access_action(parent_elm, action_type, &action_info);
ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
break;
case BUFFER_EVENT_SCROLL_DOWN:
- if (!info->elm_parent)
- return LB_ACCESS_STATUS_ERROR;
- action = ELM_ACCESS_ACTION_SCROLL;
- info->x = ix;
- info->y = iy;
- info->mouse_type = 1;
- ret = elm_access_action(info->elm_parent, action, info);
- DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret);
+ if (!parent_elm) {
+ ret = LB_ACCESS_STATUS_ERROR;
+ break;
+ }
+ action_info.mouse_type = 2;
+ ret = elm_access_action(parent_elm, action_type, &action_info);
ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
break;
case BUFFER_EVENT_UNHIGHLIGHT:
- if (!info->elm_parent)
- return LB_ACCESS_STATUS_ERROR;
- action = ELM_ACCESS_ACTION_UNHIGHLIGHT;
- ret = elm_access_action(info->elm_parent, action, info);
- DbgPrint("ACCESS_UNHIGHLIGHT, returns %d\n", ret);
+ if (!parent_elm) {
+ ret = LB_ACCESS_STATUS_ERROR;
+ break;
+ }
+ action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
+ ret = elm_access_action(parent_elm, action_type, &action_info);
ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
break;
default:
LOGD("Unhandled buffer event (%d)\n", evt);
- return -EINVAL;
+ break;
}
- return 0;
+ return ret;
}
static void *alloc_fb(void *data, int size)
Ecore_Evas *ee;
struct info *info = data;
- evas_object_del(obj, "info");
-
ee = ecore_evas_ecore_evas_get(e);
if (!ee)
return;
- LOGD("Try to release the ECORE_EVAS\n");
ecore_evas_free(ee);
free(info->id);
free(info);
- LOGD("ECORE_EVAS is released\n");
}
static void pre_render_cb(void *data, Evas *e, void *event_info)
livebox_sync_buffer(info->handle);
}
-PUBLIC Evas_Object *livebox_virtual_window_add(const char *id, int width, int height)
+PUBLIC Evas_Object *virtual_window_create(const char *id, int width, int height)
{
Ecore_Evas *ee;
Evas *e;
evas_object_color_set(info->window, 0, 0, 0, 0);
evas_object_event_callback_add(info->window, EVAS_CALLBACK_DEL, del_cb, info);
evas_object_event_callback_add(info->window, EVAS_CALLBACK_RESIZE, resize_cb, info);
- evas_object_data_set(info->window, "info", info);
return info->window;
}
-PUBLIC int livebox_virtual_window_set_parent_elm(Evas_Object *win, Evas_Object *parent_elm)
+PUBLIC int virtual_window_set_parent_elm(Evas_Object *win, Evas_Object *parent)
{
- struct info *info;
- info = evas_object_data_get(win, "info");
- if (!info)
+ Evas *e;
+ Ecore_Evas *ee;
+
+ if (!win)
return LB_STATUS_ERROR_INVALID;
- if (info->parent_elm)
- DbgPrint("Parent object will be replaced: %p\n", info->parent_elm);
+ e = evas_object_evas_get(win);
+ if (!e)
+ return LB_STATUS_ERROR_FAULT;
- info->parent_elm = parent_elm;
- return 0;
-}
+ ee = ecore_evas_ecore_evas_get(e);
+ if (!ee)
+ return LB_STATUS_ERROR_FAULT;
-PUBLIC int livebox_virtual_window_del(Evas_Object *virtual_win)
-{
- evas_object_del(virtual_win);
- return LB_STATUS_SUCCESS;
+ ecore_evas_data_set(ee, "parent,elm", parent);
+ return 0;
}
/* End of a file */