summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunho Kang <hhstark.kang@samsung.com>2016-12-13 20:03:06 +0900
committerHyunho Kang <hhstark.kang@samsung.com>2016-12-14 18:56:15 +0900
commit741ccffd461cc26a02e67dcc408ee4c5bd1c7a67 (patch)
treed67a1f62a78f775b6a0f5f5507aa14555230db38
parentdc26810390cdae597c70952c6a9a05b80e078747 (diff)
downloadscreen-connector-741ccffd461cc26a02e67dcc408ee4c5bd1c7a67.tar.gz
screen-connector-741ccffd461cc26a02e67dcc408ee4c5bd1c7a67.tar.bz2
screen-connector-741ccffd461cc26a02e67dcc408ee4c5bd1c7a67.zip
Add APIs and divide Evas dependant APIssubmit/tizen_3.0/20161219.021901
Added APIs - _compositor_set_handler_by_rid -> screen_connector_watcher_evas_add_by_rid - _compositor_get_rid -> screen_connector_watcher_evas_get_rid - _compositor_get_pid -> screen_connector_watcher_evas_get_pid Evas dependant APIs should be devided for none evas APIs like dali. Change-Id: I5806013d68262becc1b6d69bbccdffea757cfaf0 Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
-rw-r--r--screen_connector_watcher/include/screen_connector_watcher.h35
-rw-r--r--screen_connector_watcher/src/screen_connector_watcher.c758
-rw-r--r--screen_connector_watcher_evas/include/screen_connector_watcher_evas.h18
-rw-r--r--screen_connector_watcher_evas/src/screen_connector_watcher_evas.c637
4 files changed, 797 insertions, 651 deletions
diff --git a/screen_connector_watcher/include/screen_connector_watcher.h b/screen_connector_watcher/include/screen_connector_watcher.h
index 24aa3c4..0bfde94 100644
--- a/screen_connector_watcher/include/screen_connector_watcher.h
+++ b/screen_connector_watcher/include/screen_connector_watcher.h
@@ -17,43 +17,36 @@
#ifndef __SCREEN_CONNECTOR_WATCHER_H__
#define __SCREEN_CONNECTOR_WATCHER_H__
-#include <Evas.h>
#include <wayland-client.h>
#include <wayland-tbm-client.h>
#ifdef __cplusplus
extern "C" {
#endif
-typedef enum {
- VISIBILITY_TYPE_UNOBSCURED = 0,
- VISIBILITY_TYPE_PARTIALLY_OBSCURED,
- VISIBILITY_TYPE_FULLY_OBSCURED,
-} visibility_type;
-
-typedef void (*screen_connector_watcher_added_cb)(const char *appid, Evas_Object *image, void *data);
-typedef void (*screen_connector_watcher_removed_cb)(const char *appid, Evas_Object *image, void *data);
-typedef void (*screen_connector_watcher_updated_cb)(const char *appid, Evas_Object *image, void *data);
+typedef void (*screen_connector_watcher_update_cb)(struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time, void *data);
+typedef void (*screen_connector_watcher_missing_cb)(struct tizen_remote_surface *trs, void *data);
+typedef void (*screen_connector_watcher_change_cb)(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm,
+ int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data);
typedef struct _screen_connector_watcher_ops {
- screen_connector_watcher_added_cb added;
- screen_connector_watcher_removed_cb removed;
- screen_connector_watcher_updated_cb updated;
+ screen_connector_watcher_update_cb update_cb;
+ screen_connector_watcher_missing_cb missing_cb;
+ screen_connector_watcher_change_cb change_cb;
} screen_connector_watcher_ops;
typedef struct _screen_connector_watcher_h *screen_connector_watcher_h;
-int screen_connector_watcher_init(Evas_Object *win);
+int screen_connector_watcher_init();
int screen_connector_watcher_fini();
screen_connector_watcher_h screen_connector_watcher_add(screen_connector_watcher_ops *ops, char *id, void *data);
int screen_connector_watcher_remove(screen_connector_watcher_h h);
int screen_connector_watcher_update(const char *appid);
-
-int screen_connector_watcher_start_visibility_notify();
-int screen_connector_watcher_stop_visibility_notify();
-int screen_connector_watcher_freeze_visibility(Evas_Object *obj, visibility_type type);
-int screen_connector_watcher_thaw_visibility(Evas_Object *obj);
-int screen_connector_watcher_send_mouse_up(Evas_Object *obj);
-int screen_connector_watcher_send_touch_cancel(Evas_Object *obj);
+char *screen_connector_watcher_get_appid(screen_connector_watcher_h h);
+int screen_connector_watcher_get_pid(screen_connector_watcher_h h);
+int screen_connector_watcher_get_resource_id(screen_connector_watcher_h h);
+struct tizen_remote_surface *screen_connector_watcher_get_trs(screen_connector_watcher_h h);
+screen_connector_watcher_h screen_connector_watcher_create_handle(char *id, int pid, screen_connector_watcher_ops *ops, void *data);
+void screen_connector_watcher_redirect_surface(screen_connector_watcher_h watcher_h);
#ifdef __cplusplus
}
diff --git a/screen_connector_watcher/src/screen_connector_watcher.c b/screen_connector_watcher/src/screen_connector_watcher.c
index a22e5f8..02210c6 100644
--- a/screen_connector_watcher/src/screen_connector_watcher.c
+++ b/screen_connector_watcher/src/screen_connector_watcher.c
@@ -17,7 +17,6 @@
#include <stdio.h>
#include <errno.h>
#include <glib.h>
-#include <sys/mman.h>
#include <dlog.h>
#include <wayland-client.h>
@@ -35,387 +34,51 @@
#define LOG_TAG "SC_WATCHER"
-struct _screen_connector_watcher_h{
- void *surface_info;
-};
-
-typedef struct _screen_connector_surface_info {
- int pid;
- int surface_id;
+struct _screen_connector_watcher_h {
char *appid;
- struct tizen_remote_surface *surface;
- int freeze;
- bool is_init;
- bool cancel_touch;
- Evas_Object *img_tbm;
- Evas_Object *img_file;
- screen_connector_watcher_ops *ops;
+ int pid;
+ void (*update_cb)(struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time, void *data);
+ void (*missing_cb)(struct tizen_remote_surface *trs, void *data);
+ void (*change_cb)(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm,
+ int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data);
void *data;
-}screen_connector_surface_info;
+ struct tizen_remote_surface *surface;
+ int resource_id;
+};
+
+typedef struct _screen_connector_watcher_h *screen_connector_watcher_h;
-static Ecore_Event_Handler *__visibility_listener;
static struct tizen_remote_surface_manager *__rsm;
static struct wayland_tbm_client *__tbm_client;
static struct wl_tbm *__tbm;
-static int __init_count;
-static Evas_Object *__viewer_win;
-static GHashTable *__surface_tbl;
-static GList *__surface_list;
-static GList *__pending_surface_list;
+static bool __is_init = false;
+static GList *__watcher_list;
+static GList *__pending_watcher_list;
static aul_screen_viewer_handler __aul_cbs;
-static bool __obj_is_visible(Evas_Object *obj)
-{
- int x, y, w, h;
- Ecore_Wl_Window *window = NULL;
- int window_x, window_y, window_w, window_h;
- int rotation;
-
- window = elm_win_wl_window_get(__viewer_win);
- ecore_wl_window_geometry_get(window, &window_x, &window_y, &window_w, &window_h);
- evas_object_geometry_get(obj, &x, &y, &w, &h);
- rotation = ecore_wl_window_rotation_get(window);
-
- if (x >= 0 && x < window_w &&
- y >= 0 && y < window_h &&
- (rotation == 0 || rotation == 180)) {
- LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d",
- x, y, w, h, window_w, window_h, rotation);
- return true;
- } else if (x >= 0 && x < window_h &&
- y >= 0 && y < window_w &&
- (rotation == 90 || rotation == 270)) {
- LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d",
- x, y, w, h, window_w, window_h, rotation);
- return true;
- }
- return false;
-}
-
-static int __set_visibility(screen_connector_surface_info *surface_info, visibility_type type)
-{
- int obscured;
-
- if (!surface_info) {
- LOGE("obj not found");
- return -1;
- }
-
- switch (type) {
- case VISIBILITY_TYPE_UNOBSCURED:
- case VISIBILITY_TYPE_PARTIALLY_OBSCURED:
- obscured = TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE;
- break;
- case VISIBILITY_TYPE_FULLY_OBSCURED:
- obscured = TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_INVISIBLE;
- break;
- default:
- return -1;
- }
-
- if (surface_info->surface)
- tizen_remote_surface_transfer_visibility(surface_info->surface, obscured);
-
- return 0;
-}
-
-static void __obj_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data;
-
- if (!surface_info->is_init) {
- surface_info->is_init = true;
- return;
- }
-
- if (__obj_is_visible(obj))
- __set_visibility(surface_info, VISIBILITY_TYPE_UNOBSCURED);
- else
- __set_visibility(surface_info, VISIBILITY_TYPE_FULLY_OBSCURED);
-}
-
-static void __rs_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data;
- Evas_Event_Mouse_Down *ev = event_info;
- const char *desc = evas_device_description_get(ev->dev);
- int x;
- int y;
- int w;
- int h;
-
- evas_object_geometry_get(obj, &x, &y, &w, &h);
-
- LOGD("mouse down: %d %d", ev->canvas.x - x, ev->canvas.y - y);
-
- if (desc == NULL)
- desc = "";
-
- tizen_remote_surface_transfer_mouse_event(surface_info->surface,
- TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_DOWN,
- 0,
- ev->button,
- ev->canvas.x - x,
- ev->canvas.y - y,
- wl_fixed_from_double(ev->radius_x),
- wl_fixed_from_double(ev->radius_y),
- wl_fixed_from_double(ev->pressure),
- wl_fixed_from_double(ev->angle),
- evas_device_class_get(ev->dev),
- evas_device_subclass_get(ev->dev),
- desc,
- ev->timestamp);
-}
-
-static void __rs_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data;
- Evas_Event_Mouse_Up *ev = event_info;
- const char *desc = evas_device_description_get(ev->dev);
- int x;
- int y;
- int w;
- int h;
-
- evas_object_geometry_get(obj, &x, &y, &w, &h);
-
- LOGD("mouse up: %d %d", ev->canvas.x - x, ev->canvas.y - y);
-
- if (desc == NULL)
- desc = "";
-
- tizen_remote_surface_transfer_mouse_event(surface_info->surface,
- TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP,
- 0,
- ev->button,
- ev->canvas.x - x,
- ev->canvas.y - y,
- wl_fixed_from_double(ev->radius_x),
- wl_fixed_from_double(ev->radius_y),
- wl_fixed_from_double(ev->pressure),
- wl_fixed_from_double(ev->angle),
- evas_device_class_get(ev->dev),
- evas_device_subclass_get(ev->dev),
- desc,
- ev->timestamp);
-
-}
-
-static void __rs_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data;
- Evas_Event_Mouse_Move *ev = event_info;
- const char *desc = evas_device_description_get(ev->dev);
- int x;
- int y;
- int w;
- int h;
-
- evas_object_geometry_get(obj, &x, &y, &w, &h);
-
- LOGD("mouse move: %d %d", ev->cur.canvas.x - x, ev->cur.canvas.y - y);
-
- if (desc == NULL)
- desc = "";
-
- tizen_remote_surface_transfer_mouse_event(surface_info->surface,
- TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_MOVE,
- 0,
- 0,
- ev->cur.canvas.x - x,
- ev->cur.canvas.y - y,
- wl_fixed_from_double(ev->radius_x),
- wl_fixed_from_double(ev->radius_y),
- wl_fixed_from_double(ev->pressure),
- wl_fixed_from_double(ev->angle),
- evas_device_class_get(ev->dev),
- evas_device_subclass_get(ev->dev),
- desc,
- ev->timestamp);
-
-}
-
-static void __rs_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data;
- Evas_Event_Mouse_Wheel *ev = event_info;
- const char *desc = evas_device_description_get(ev->dev);
-
- LOGD("mouse wheel");
-
- if (desc == NULL)
- desc = "";
-
- tizen_remote_surface_transfer_mouse_wheel(surface_info->surface,
- ev->direction,
- ev->z,
- evas_device_class_get(ev->dev),
- evas_device_subclass_get(ev->dev),
- desc,
- ev->timestamp);
-
-}
-
-static void __rs_cb_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
+static void __buffer_updated(void *data, struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time)
{
- LOGD("show");
+ screen_connector_watcher_h watcher_h = (screen_connector_watcher_h)data;
+ if (watcher_h)
+ watcher_h->update_cb(trs, buffer, time, watcher_h->data);
}
-static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
+static void __buffer_missing(void *data, struct tizen_remote_surface *trs)
{
- LOGD("hide");
+ screen_connector_watcher_h watcher_h = (screen_connector_watcher_h)data;
+ if (watcher_h)
+ watcher_h->missing_cb(trs, watcher_h->data);
}
+#if 0
static void __buffer_changed(void *data, struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm,
int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys)
{
- screen_connector_surface_info *surface_info;
- bool is_added = false;
- Evas_Native_Surface ns;
- tbm_surface_h tbm_surface;
- int width, height;
- char *map;
- char format[] = "png";
- char plug_id[256];
-
- surface_info = (screen_connector_surface_info *)data;
- if (surface_info->img_tbm == NULL) {
-
- LOGD("first added !!!! %d, %d %s", (surface_info->img_tbm == NULL), type, surface_info->appid);
- surface_info->img_tbm = evas_object_image_filled_add(
- evas_object_evas_get(__viewer_win));
-
- /* Image alpha set */
- evas_object_image_alpha_set(surface_info->img_tbm, 1);
-
- evas_object_event_callback_add(surface_info->img_tbm,
- EVAS_CALLBACK_MOUSE_DOWN,
- __rs_cb_mouse_down, surface_info);
- evas_object_event_callback_add(surface_info->img_tbm,
- EVAS_CALLBACK_MOUSE_UP,
- __rs_cb_mouse_up, surface_info);
- evas_object_event_callback_add(surface_info->img_tbm,
- EVAS_CALLBACK_MOUSE_MOVE,
- __rs_cb_mouse_move, surface_info);
- evas_object_event_callback_add(surface_info->img_tbm,
- EVAS_CALLBACK_MOUSE_WHEEL,
- __rs_cb_mouse_wheel, surface_info);
- evas_object_event_callback_add(surface_info->img_tbm,
- EVAS_CALLBACK_SHOW,
- __rs_cb_show, surface_info);
- evas_object_event_callback_add(surface_info->img_tbm,
- EVAS_CALLBACK_HIDE,
- __rs_cb_hide, surface_info);
-
- /* Store surface_info */
- g_hash_table_insert(__surface_tbl, surface_info->img_tbm, surface_info);
-
- /* Set data to use in accessibility */
- snprintf(plug_id, sizeof(plug_id), "%s:%d", surface_info->appid, surface_info->pid);
- evas_object_data_set(surface_info->img_tbm, "___PLUGID", strdup(plug_id));
- evas_object_event_callback_add(surface_info->img_tbm,
- EVAS_CALLBACK_MOVE, __obj_move_cb, surface_info);
-
- is_added = true;
- }
-
- /* check type of given buffer */
- if (type == 0) {//if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM) {
-
- /* get tbm surface from buffer */
- tbm_surface = wl_buffer_get_user_data(tbm);
- width = tbm_surface_get_width(tbm_surface);
- height = tbm_surface_get_height(tbm_surface);
-
- memset(&ns, 0, sizeof(Evas_Native_Surface));
- ns.version = EVAS_NATIVE_SURFACE_VERSION;
- ns.type = EVAS_NATIVE_SURFACE_TBM;
- ns.data.tbm.buffer = tbm_surface;
-
- evas_object_resize(surface_info->img_tbm, width, height);
- evas_object_image_size_set(surface_info->img_tbm, width, height);
- evas_object_image_native_surface_set(surface_info->img_tbm, &ns); /* set native surface */
- evas_object_image_pixels_dirty_set(surface_info->img_tbm, EINA_TRUE); /* set dirty for image updating */
-
- //evas_object_del(surface_info->img_file); /* delete previous object for the image file type */
-
- } else if (type == 1) {//} else if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE) {
-
- if (!surface_info->img_file) {
- surface_info->img_file = evas_object_image_filled_add(
- evas_object_evas_get(__viewer_win));
- }
-
- map = mmap(NULL, img_file_size, PROT_READ, MAP_SHARED, img_file_fd, 0);
- evas_object_image_memfile_set(surface_info->img_file, map, img_file_size, format, NULL);
- evas_object_image_size_get(surface_info->img_tbm, &width, &height);
- evas_object_image_fill_set(surface_info->img_file, 0, 0, width, height);
- evas_object_resize(surface_info->img_file, width, height);
- munmap(map, img_file_size);
- close(img_file_fd); /* close passed fd */
-
- evas_object_image_native_surface_set(surface_info->img_tbm, NULL); /* set null to previous object for the tbm type */
- }
-
- if (is_added) {
- LOGD("call added !!!! %s", surface_info->appid);
- surface_info->ops->added(surface_info->appid, surface_info->img_tbm,
- surface_info->data);
- } else {
- LOGD("call updated !!!! %s", surface_info->appid);
- surface_info->ops->updated(surface_info->appid, surface_info->img_tbm,
- surface_info->data);
- }
-
+ screen_connector_watcher_h watcher_h = (screen_connector_watcher_h)data;
+ if (watcher_h)
+ watcher_h->change_cb(trs, type, tbm, img_file_fd, img_file_size, time, keys, watcher_h->data);
}
-static void __buffer_updated(void *data, struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time)
-{
- __buffer_changed(data, trs, 0, buffer, 0, 0, 0, NULL);
-}
-
-static void __free_surface_info(screen_connector_surface_info *surface_info)
-{
- if (!surface_info)
- return;
-
- if (surface_info->appid)
- free(surface_info->appid);
-
- if (surface_info->img_tbm) {
- evas_object_del(surface_info->img_tbm);
- surface_info->img_tbm = NULL;
- }
-
- if (surface_info->ops)
- free(surface_info->ops);
-
- free(surface_info);
-}
-
-static void __buffer_missing(void *data, struct tizen_remote_surface *trs)
-{
- screen_connector_surface_info *surface_info;
- char *plug_id;
-
- LOGD("missing");
- surface_info = (screen_connector_surface_info *)data;
- if (!surface_info) {
- LOGE("Null surface_info");
- return;
- }
-
- g_hash_table_remove(__surface_tbl, surface_info->img_tbm);
-
- /* Remove data used in accessibility */
- plug_id = evas_object_data_del(surface_info->img_tbm, "___PLUGID");
- free(plug_id);
-
- surface_info->ops->removed(surface_info->appid, surface_info->img_tbm, surface_info->data);
- __free_surface_info(surface_info);
-}
-
-#if 0
static const struct tizen_remote_surface_listener __rs_listener = {
__buffer_updated,
__buffer_missing,
@@ -428,238 +91,79 @@ static const struct tizen_remote_surface_listener __rs_listener = {
};
#endif
-
static void __app_removed(const char *appid, const int pid, void *data)
{
}
-static void __redirect_surface(screen_connector_surface_info *surface_info)
+EXPORT_API void screen_connector_watcher_redirect_surface(screen_connector_watcher_h watcher_h)
{
- surface_info->surface =
- tizen_remote_surface_manager_create_surface(__rsm, (uint32_t)surface_info->surface_id, __tbm);
-
- LOGD("surface_id : %d, (%p)", surface_info->surface_id, surface_info->surface);
- tizen_remote_surface_add_listener(surface_info->surface, &__rs_listener,
- surface_info);
- tizen_remote_surface_redirect(surface_info->surface);
+ watcher_h->surface =
+ tizen_remote_surface_manager_create_surface(__rsm, (uint32_t)watcher_h->resource_id, __tbm);
+ LOGD("resource_id : %d, (%p)", watcher_h->resource_id, watcher_h->surface);
+ tizen_remote_surface_add_listener(watcher_h->surface, &__rs_listener,
+ watcher_h);
+ tizen_remote_surface_redirect(watcher_h->surface);
}
-static screen_connector_surface_info *__create_surface_info(char *appid)
+static screen_connector_watcher_h __create_watcher_handle_info(char *appid)
{
- screen_connector_surface_info *surface_info = NULL;
- surface_info = (screen_connector_surface_info *)calloc(1, sizeof(screen_connector_surface_info));
- if (surface_info == NULL) {
- LOGE("surface_info calloc fail");
+ screen_connector_watcher_h watcher_h = NULL;
+ watcher_h = (screen_connector_watcher_h)calloc(1, sizeof(struct _screen_connector_watcher_h));
+ if (watcher_h == NULL) {
+ LOGE("watcher_h calloc fail");
return NULL;
}
+ watcher_h->appid = strdup(appid);
- surface_info->img_file = NULL;
- surface_info->img_tbm = NULL;
- surface_info->appid = strdup(appid);
-
- return surface_info;
+ return watcher_h;
}
-static void __app_added(const char *appid, const int pid, const unsigned int surface_id, void *data)
+static void __app_added(const char *appid, const int pid, const unsigned int resource_id, void *data)
{
- LOGD("__app_added pid: %d, surface_id: %d, appid: %s", pid, surface_id, appid);
- screen_connector_surface_info *surface_info = NULL;
- screen_connector_surface_info *cur_info = NULL;
- GList *surface_list = __surface_list;
-
- for (; surface_list != NULL; surface_list = surface_list->next) {
- cur_info = (screen_connector_surface_info *)surface_list->data;
- if (strcmp(cur_info->appid, appid) == 0) {
- surface_info = cur_info;
- __surface_list = g_list_remove(__surface_list, cur_info);
+ LOGD("__app_added pid: %d, resource_id: %d, appid: %s", pid, resource_id, appid);
+ screen_connector_watcher_h watcher_h = NULL;
+ screen_connector_watcher_h cur_h = NULL;
+ GList *watcher_list = __watcher_list;
+
+ for (; watcher_list != NULL; watcher_list = watcher_list->next) {
+ cur_h = (screen_connector_watcher_h)watcher_list->data;
+ if (strcmp(cur_h->appid, appid) == 0) {
+ watcher_h = cur_h;
+ __watcher_list = g_list_remove(__watcher_list, cur_h);
break;
}
}
- if (surface_info == NULL) {
- surface_info = __create_surface_info((char *)appid);
- surface_info->pid = pid;
- surface_info->surface_id = surface_id;
- __pending_surface_list = g_list_append(__pending_surface_list, surface_info);
+ if (watcher_h == NULL) {
+ watcher_h = __create_watcher_handle_info((char *)appid);
+ watcher_h->pid = pid;
+ watcher_h->resource_id = resource_id;
+ __pending_watcher_list = g_list_append(__pending_watcher_list, watcher_h);
- LOGD("add pending list: %d, surface_id: %d, appid: %s", pid, surface_id, appid);
+ LOGD("add pending list: %d, resource_id: %d, appid: %s", pid, resource_id, appid);
return;
}
- surface_info->surface_id = surface_id;
- surface_info->pid = pid;
- if (surface_id > 0)
- __redirect_surface(surface_info);
+ watcher_h->resource_id = resource_id;
+ watcher_h->pid = pid;
+ if (resource_id > 0)
+ screen_connector_watcher_redirect_surface(watcher_h);
else
LOGE("bad tbm message received. missing arguments");
}
-static void __send_visibility(gpointer key, gpointer value, gpointer user_data)
-{
- screen_connector_surface_info *surface_info = (screen_connector_surface_info *)value;
- Evas_Object *evas_obj = (Evas_Object *)key;
- unsigned int event = GPOINTER_TO_INT(user_data);
- int ret;
- visibility_type type;
-
- if (surface_info->freeze)
- return;
-
- if (!__obj_is_visible(evas_obj))
- return;
-
- if (event)
- type = VISIBILITY_TYPE_FULLY_OBSCURED;
- else
- type = VISIBILITY_TYPE_UNOBSCURED;
-
- ret = __set_visibility(surface_info, type);
- if (ret == -1)
- LOGE("failed to set object visibility set %p to %d", evas_obj, type);
-}
-
-static Eina_Bool __visibility_cb(void *data, int type, void *event)
-{
- Ecore_Wl_Event_Window_Visibility_Change *ev = event;
-
- LOGD("visibility change: %d %d", (unsigned int)ev->win,
- (unsigned int)ev->fully_obscured);
-
- if (!__surface_tbl)
- return ECORE_CALLBACK_RENEW;
-
- g_hash_table_foreach(__surface_tbl, __send_visibility,
- GINT_TO_POINTER(ev->fully_obscured));
-
- return ECORE_CALLBACK_RENEW;
-}
-
-EXPORT_API int screen_connector_watcher_start_visibility_notify()
-{
- if (__visibility_listener)
- return 0;
-
- __visibility_listener = ecore_event_handler_add(
- ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, __visibility_cb, NULL);
-
- return 0;
-}
-
-
-EXPORT_API int screen_connector_watcher_stop_visibility_notify()
-{
- if (!__visibility_listener)
- return 0;
-
- ecore_event_handler_del(__visibility_listener);
- __visibility_listener = NULL;
-
- return 0;
-}
-
-EXPORT_API int screen_connector_watcher_freeze_visibility(Evas_Object *obj, visibility_type type)
-{
- screen_connector_surface_info *surface_info;
-
- surface_info = (screen_connector_surface_info *)g_hash_table_lookup(__surface_tbl, obj);
- if (!surface_info) {
- LOGE("obj not found");
- return -1;
- }
- surface_info->freeze = 1;
-
- return __set_visibility(surface_info, type);
-}
-
-EXPORT_API int screen_connector_watcher_thaw_visibility(Evas_Object *obj)
-{
- screen_connector_surface_info *surface_info;
-
- surface_info = (screen_connector_surface_info *)g_hash_table_lookup(__surface_tbl, obj);
- if (!surface_info) {
- LOGE("obj not found");
- return -1;
- }
- surface_info->freeze = 0;
-
- return 0;
-}
-
-EXPORT_API int screen_connector_watcher_send_mouse_up(Evas_Object *obj)
-{
- screen_connector_surface_info *surface_info;
- int x;
- int y;
- int w;
- int h;
- unsigned int timestamp;
-
- surface_info = g_hash_table_lookup(__surface_tbl, obj);
- if (!surface_info) {
- LOGE("unknown object. not widget object.");
- return -1;
- }
-
- if (!surface_info->img_tbm) {
- LOGE("surface not yet initialized.");
- return -1;
- }
-
- evas_object_geometry_get(obj, &x, &y, &w, &h);
- timestamp = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff);
- tizen_remote_surface_transfer_mouse_event(surface_info->surface,
- TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP,
- 0,
- 1,
- w / 2,
- h / 2,
- 0,
- 0,
- 0,
- 0,
- TIZEN_INPUT_DEVICE_CLAS_MOUSE,
- TIZEN_INPUT_DEVICE_SUBCLAS_NONE,
- "",
- timestamp);
-
- return 0;
-}
-
-EXPORT_API int screen_connector_watcher_send_touch_cancel(Evas_Object *obj)
-{
- screen_connector_surface_info *surface_info;
-
- surface_info = g_hash_table_lookup(__surface_tbl, obj);
- if (!surface_info) {
- LOGE("unknown object. not widget object.");
- return -1;
- }
-
- if (surface_info->img_tbm) {
- tizen_remote_surface_transfer_touch_cancel(surface_info->surface);
- surface_info->cancel_touch = true;
- } else {
- LOGE("surface not yet initialized.");
- return -1;
- }
-
- return 0;
-}
-
-EXPORT_API int screen_connector_watcher_init(Evas_Object *win)
+EXPORT_API int screen_connector_watcher_init()
{
int ret = 0;
struct wl_registry *registry;
Ecore_Wl_Global *global;
Eina_Inlist *globals;
- __viewer_win = win;
-
- if (__init_count > 0) {
+ if (__is_init)
return 0;
- }
+
ecore_wl_init(NULL);
registry = ecore_wl_registry_get();
@@ -695,100 +199,136 @@ EXPORT_API int screen_connector_watcher_init(Evas_Object *win)
return -1;
}
- __surface_tbl = g_hash_table_new(g_direct_hash, g_direct_equal);
- if (!__surface_tbl) {
- LOGE("failed to create table");
- return -1;
- }
-
__aul_cbs.app_added = __app_added;
__aul_cbs.app_removed = __app_removed;
aul_screen_connector_add_screen_viewer(&__aul_cbs, NULL);
- __init_count++;
+ __is_init = true;
return ret;
}
EXPORT_API int screen_connector_watcher_fini()
{
- int ret = 0;
-
- if (__init_count > 1)
+ if (!__is_init)
return 0;
+ if (aul_screen_connector_remove_app_screen() != 0)
+ return -1;
+
if (__tbm_client)
wayland_tbm_client_deinit(__tbm_client);
if (__rsm)
tizen_remote_surface_manager_destroy(__rsm);
- if (__surface_tbl)
- g_hash_table_destroy(__surface_tbl);
-
ecore_wl_shutdown();
- __init_count--;
- return ret;
+ __is_init = false;
+ return 0;
}
-EXPORT_API screen_connector_watcher_h screen_connector_watcher_add(screen_connector_watcher_ops *ops, char *id, void *data)
+static void __destroy_watcher_h(screen_connector_watcher_h handle)
{
+ if (!handle)
+ return;
- screen_connector_watcher_h w_handle;
- screen_connector_watcher_ops *watcher_ops;
- screen_connector_surface_info *surface_info = NULL;
- screen_connector_surface_info *cur_info = NULL;
- GList *surface_list = __pending_surface_list;
+ if (handle->appid)
+ free(handle->appid);
- watcher_ops = (screen_connector_watcher_ops *)calloc(1, sizeof(screen_connector_watcher_ops *));
- if (watcher_ops == NULL) {
- LOGE("watcher_ops calloc fail");
- return NULL;
- }
+ free(handle);
+}
- watcher_ops->added = ops->added;
- watcher_ops->removed = ops->removed;
- watcher_ops->updated = ops->updated;
+EXPORT_API screen_connector_watcher_h screen_connector_watcher_create_handle(char *id, int pid, screen_connector_watcher_ops *ops, void *data)
+{
+ screen_connector_watcher_h watcher_h = NULL;
- w_handle = (screen_connector_watcher_h)calloc(1, sizeof(struct _screen_connector_watcher_h));
- if (watcher_ops == NULL) {
- LOGE("w_handle calloc fail");
- return NULL;
- }
+ watcher_h = __create_watcher_handle_info(id);
+ watcher_h->update_cb = ops->update_cb;
+ watcher_h->change_cb = ops->change_cb;
+ watcher_h->missing_cb = ops->missing_cb;
+ watcher_h->pid = pid;
+ watcher_h->data = data;
- for (; surface_list != NULL; surface_list = surface_list->next) {
- cur_info = (screen_connector_surface_info *)surface_list->data;
- if (strcmp(cur_info->appid, id) == 0) {
- surface_info = cur_info;
- __pending_surface_list = g_list_remove(__pending_surface_list, cur_info);
+ return watcher_h;
+}
+
+EXPORT_API screen_connector_watcher_h screen_connector_watcher_add(screen_connector_watcher_ops *ops, char *id, void *data)
+{
+
+ screen_connector_watcher_h watcher_h = NULL;
+ screen_connector_watcher_h cur_h = NULL;
+ GList *watcher_list = __pending_watcher_list;
+
+ for (; watcher_list != NULL; watcher_list = watcher_list->next) {
+ cur_h = (screen_connector_watcher_h)watcher_list->data;
+ if (strcmp(cur_h->appid, id) == 0) {
+ watcher_h = cur_h;
+ __pending_watcher_list = g_list_remove(__pending_watcher_list, cur_h);
break;
}
}
- if (surface_info != NULL) {
- surface_info->ops = watcher_ops;
- surface_info->data = data;
- __redirect_surface(surface_info);
+ if (watcher_h != NULL) {
+ watcher_h->update_cb = ops->update_cb;
+ watcher_h->change_cb = ops->change_cb;
+ watcher_h->missing_cb = ops->missing_cb;
+ watcher_h->data = data;
+ screen_connector_watcher_redirect_surface(watcher_h);
} else {
- surface_info = __create_surface_info(id);
- surface_info->ops = watcher_ops;
- surface_info->data = data;
- __surface_list = g_list_append(__surface_list, surface_info);
+ watcher_h = __create_watcher_handle_info(id);
+ watcher_h->update_cb = ops->update_cb;
+ watcher_h->change_cb = ops->change_cb;
+ watcher_h->missing_cb = ops->missing_cb;
+ watcher_h->data = data;
+ __watcher_list = g_list_append(__watcher_list, watcher_h);
}
- w_handle->surface_info = surface_info;
- return w_handle;
+ return watcher_h;
}
EXPORT_API int screen_connector_watcher_remove(screen_connector_watcher_h h)
{
int ret = 0;
+ __destroy_watcher_h(h);
return ret;
}
EXPORT_API int screen_connector_watcher_update(const char *appid)
{
int ret = 0;
+ ret = aul_screen_connector_update_app_screen(appid);
return ret;
}
+
+EXPORT_API char *screen_connector_watcher_get_appid(screen_connector_watcher_h h)
+{
+ if (h == NULL)
+ return NULL;
+
+ return h->appid;
+}
+
+EXPORT_API int screen_connector_watcher_get_pid(screen_connector_watcher_h h)
+{
+ if (h == NULL)
+ return -1;
+
+ return h->pid;
+}
+
+EXPORT_API int screen_connector_watcher_get_resource_id(screen_connector_watcher_h h)
+{
+ if (h == NULL)
+ return -1;
+
+ return h->resource_id;
+}
+
+EXPORT_API struct tizen_remote_surface *screen_connector_watcher_get_trs(screen_connector_watcher_h h)
+{
+ if (h == NULL)
+ return NULL;
+
+ return h->surface;
+}
diff --git a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h
index 9407fee..efbe06a 100644
--- a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h
+++ b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h
@@ -21,8 +21,6 @@
#include <tizen.h>
#include <tizen_type.h>
-#include "screen_connector_watcher.h"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -38,6 +36,12 @@ extern "C" {
* @{
*/
+typedef enum {
+ VISIBILITY_TYPE_UNOBSCURED = 0,
+ VISIBILITY_TYPE_PARTIALLY_OBSCURED,
+ VISIBILITY_TYPE_FULLY_OBSCURED,
+} visibility_type;
+
typedef void (*screen_connector_watcher_evas_added_cb)(const char *appid, Evas_Object *image, void *data);
typedef void (*screen_connector_watcher_evas_removed_cb)(const char *appid, Evas_Object *image, void *data);
typedef void (*screen_connector_watcher_evas_updated_cb)(const char *appid, Evas_Object *image, void *data);
@@ -56,6 +60,16 @@ screen_connector_watcher_evas_h screen_connector_watcher_evas_add(screen_connect
int screen_connector_watcher_evas_remove(screen_connector_watcher_evas_h handle);
int screen_connector_watcher_evas_update(const char *appid);
+int screen_connector_watcher_evas_start_visibility_notify();
+int screen_connector_watcher_evas_stop_visibility_notify();
+int screen_connector_watcher_evas_freeze_visibility(Evas_Object *obj, visibility_type type);
+int screen_connector_watcher_evas_thaw_visibility(Evas_Object *obj);
+int screen_connector_watcher_evas_send_mouse_up(Evas_Object *obj);
+int screen_connector_watcher_evas_send_touch_cancel(Evas_Object *obj);
+int screen_connector_watcher_evas_get_pid(Evas_Object *obj, int *pid);
+int screen_connector_watcher_evas_add_by_rid(screen_connector_watcher_evas_ops *ops, int res_id, void *data);
+int screen_connector_watcher_evas_get_rid(Evas_Object *obj, int *resource_id);
+
/**
* @}
*/
diff --git a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c
index 3c97241..8f36025 100644
--- a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c
+++ b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c
@@ -18,8 +18,13 @@
#include <stdio.h>
#include <errno.h>
#include <glib.h>
+#include <sys/mman.h>
#include <dlog.h>
+#include <Elementary.h>
+#include <Ecore_Wayland.h>
+#include <wayland-extension/tizen-extension-client-protocol.h>
+#include <tizen-remote-surface-client-protocol.h>
#include "screen_connector_watcher.h"
#include "screen_connector_watcher_evas.h"
@@ -33,8 +38,16 @@
struct _screen_connector_watcher_evas_h {
screen_connector_watcher_evas_ops *ops;
screen_connector_watcher_h watcher_h;
+ int freeze;
+ bool is_init;
+ bool cancel_touch;
+ Evas_Object *img_tbm;
+ Evas_Object *img_file;
void *data;
};
+static Evas_Object *__viewer_win;
+static Ecore_Event_Handler *__visibility_listener;
+static GHashTable *__watcher_tbl;
static void __destroy_watcher_evas_handle(screen_connector_watcher_evas_h h)
{
@@ -47,51 +60,407 @@ static void __destroy_watcher_evas_handle(screen_connector_watcher_evas_h h)
EXPORT_API int screen_connector_watcher_evas_init(Evas_Object *win)
{
int ret = 0;
- ret = screen_connector_watcher_init(win);
+ __viewer_win = win;
+
+ __watcher_tbl = g_hash_table_new(g_direct_hash, g_direct_equal);
+ if (!__watcher_tbl) {
+ LOGE("failed to create table");
+ return -1;
+ }
+
+ ret = screen_connector_watcher_init();
return ret;
}
EXPORT_API int screen_connector_watcher_evas_fini()
{
int ret = 0;
+
+ if (__watcher_tbl)
+ g_hash_table_destroy(__watcher_tbl);
+
ret = screen_connector_watcher_fini();
return ret;
}
-static void __watcher_added_cb(const char *appid, Evas_Object *image, void *data)
+static bool __obj_is_visible(Evas_Object *obj)
{
- screen_connector_watcher_evas_h handle;
+ int x, y, w, h;
+ Ecore_Wl_Window *window = NULL;
+ int window_x, window_y, window_w, window_h;
+ int rotation;
- handle = (screen_connector_watcher_evas_h)data;
- handle->ops->added(appid, image, handle->data);
+ window = elm_win_wl_window_get(__viewer_win);
+ ecore_wl_window_geometry_get(window, &window_x, &window_y, &window_w, &window_h);
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ rotation = ecore_wl_window_rotation_get(window);
+
+ if (x >= 0 && x < window_w &&
+ y >= 0 && y < window_h &&
+ (rotation == 0 || rotation == 180)) {
+ LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d",
+ x, y, w, h, window_w, window_h, rotation);
+ return true;
+ } else if (x >= 0 && x < window_h &&
+ y >= 0 && y < window_w &&
+ (rotation == 90 || rotation == 270)) {
+ LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d",
+ x, y, w, h, window_w, window_h, rotation);
+ return true;
+ }
+ return false;
}
-static void __watcher_removed_cb(const char *appid, Evas_Object *image, void *data)
+static int __set_visibility(screen_connector_watcher_evas_h watcher_evas_h, visibility_type type)
{
- screen_connector_watcher_evas_h handle;
+ int obscured;
+ struct tizen_remote_surface *surface;
+
+ if (!watcher_evas_h) {
+ LOGE("obj not found");
+ return -1;
+ }
+
+ switch (type) {
+ case VISIBILITY_TYPE_UNOBSCURED:
+ case VISIBILITY_TYPE_PARTIALLY_OBSCURED:
+ obscured = TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE;
+ break;
+ case VISIBILITY_TYPE_FULLY_OBSCURED:
+ obscured = TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_INVISIBLE;
+ break;
+ default:
+ return -1;
+ }
+
+ surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h);
+ if (surface)
+ tizen_remote_surface_transfer_visibility(surface, obscured);
- handle = (screen_connector_watcher_evas_h)data;
- handle->ops->removed(appid, image, handle->data);
+ return 0;
}
-static void __watcher_updated_cb(const char *appid, Evas_Object *image, void *data)
+static void __obj_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- screen_connector_watcher_evas_h handle;
+ screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data;
+
+ if (!watcher_evas_h->is_init) {
+ watcher_evas_h->is_init = true;
+ return;
+ }
+
+ if (__obj_is_visible(obj))
+ __set_visibility(watcher_evas_h, VISIBILITY_TYPE_UNOBSCURED);
+ else
+ __set_visibility(watcher_evas_h, VISIBILITY_TYPE_FULLY_OBSCURED);
+}
+
+static void __rs_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data;
+ Evas_Event_Mouse_Down *ev = event_info;
+ const char *desc = evas_device_description_get(ev->dev);
+ int x;
+ int y;
+ int w;
+ int h;
+ struct tizen_remote_surface *surface;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+
+ LOGD("mouse down: %d %d", ev->canvas.x - x, ev->canvas.y - y);
+
+ if (desc == NULL)
+ desc = "";
+
+ surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h);
+ tizen_remote_surface_transfer_mouse_event(surface,
+ TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_DOWN,
+ 0,
+ ev->button,
+ ev->canvas.x - x,
+ ev->canvas.y - y,
+ wl_fixed_from_double(ev->radius_x),
+ wl_fixed_from_double(ev->radius_y),
+ wl_fixed_from_double(ev->pressure),
+ wl_fixed_from_double(ev->angle),
+ evas_device_class_get(ev->dev),
+ evas_device_subclass_get(ev->dev),
+ desc,
+ ev->timestamp);
+}
+
+static void __rs_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data;
+ Evas_Event_Mouse_Up *ev = event_info;
+ const char *desc = evas_device_description_get(ev->dev);
+ int x;
+ int y;
+ int w;
+ int h;
+ struct tizen_remote_surface *surface;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+
+ LOGD("mouse up: %d %d", ev->canvas.x - x, ev->canvas.y - y);
+
+ if (desc == NULL)
+ desc = "";
+
+ surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h);
+ tizen_remote_surface_transfer_mouse_event(surface,
+ TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP,
+ 0,
+ ev->button,
+ ev->canvas.x - x,
+ ev->canvas.y - y,
+ wl_fixed_from_double(ev->radius_x),
+ wl_fixed_from_double(ev->radius_y),
+ wl_fixed_from_double(ev->pressure),
+ wl_fixed_from_double(ev->angle),
+ evas_device_class_get(ev->dev),
+ evas_device_subclass_get(ev->dev),
+ desc,
+ ev->timestamp);
+
+}
+
+static void __rs_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data;
+ Evas_Event_Mouse_Move *ev = event_info;
+ const char *desc = evas_device_description_get(ev->dev);
+ int x;
+ int y;
+ int w;
+ int h;
+ struct tizen_remote_surface *surface;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+
+ LOGD("mouse move: %d %d", ev->cur.canvas.x - x, ev->cur.canvas.y - y);
+
+ if (desc == NULL)
+ desc = "";
+
+ surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h);
+ tizen_remote_surface_transfer_mouse_event(surface,
+ TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_MOVE,
+ 0,
+ 0,
+ ev->cur.canvas.x - x,
+ ev->cur.canvas.y - y,
+ wl_fixed_from_double(ev->radius_x),
+ wl_fixed_from_double(ev->radius_y),
+ wl_fixed_from_double(ev->pressure),
+ wl_fixed_from_double(ev->angle),
+ evas_device_class_get(ev->dev),
+ evas_device_subclass_get(ev->dev),
+ desc,
+ ev->timestamp);
+
+}
+
+static void __rs_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data;
+ Evas_Event_Mouse_Wheel *ev = event_info;
+ const char *desc = evas_device_description_get(ev->dev);
+ struct tizen_remote_surface *surface;
+
+ LOGD("mouse wheel");
+
+ if (desc == NULL)
+ desc = "";
+
+ surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h);
+ tizen_remote_surface_transfer_mouse_wheel(surface,
+ ev->direction,
+ ev->z,
+ evas_device_class_get(ev->dev),
+ evas_device_subclass_get(ev->dev),
+ desc,
+ ev->timestamp);
- handle = (screen_connector_watcher_evas_h)data;
- handle->ops->updated(appid, image, handle->data);
}
+static void __rs_cb_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ LOGD("show");
+}
+
+static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ LOGD("hide");
+}
+
+static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm,
+ int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data)
+{
+
+ bool is_added = false;
+ Evas_Native_Surface ns;
+ tbm_surface_h tbm_surface;
+ int width, height;
+ char *map;
+ char format[] = "png";
+ char plug_id[256];
+ screen_connector_watcher_evas_h watcher_evas_h;
+ char *appid;
+ char pid;
+
+ watcher_evas_h = (screen_connector_watcher_evas_h)data;
+ appid = screen_connector_watcher_get_appid(watcher_evas_h->watcher_h);
+ pid = screen_connector_watcher_get_pid(watcher_evas_h->watcher_h);
+ if (watcher_evas_h->img_tbm == NULL) {
+
+ LOGD("first added !!!! %d, %d %s", (watcher_evas_h->img_tbm == NULL), type, appid);
+ watcher_evas_h->img_tbm = evas_object_image_filled_add(
+ evas_object_evas_get(__viewer_win));
+
+ /* Image alpha set */
+ evas_object_image_alpha_set(watcher_evas_h->img_tbm, 1);
+
+ evas_object_event_callback_add(watcher_evas_h->img_tbm,
+ EVAS_CALLBACK_MOUSE_DOWN,
+ __rs_cb_mouse_down, watcher_evas_h);
+ evas_object_event_callback_add(watcher_evas_h->img_tbm,
+ EVAS_CALLBACK_MOUSE_UP,
+ __rs_cb_mouse_up, watcher_evas_h);
+ evas_object_event_callback_add(watcher_evas_h->img_tbm,
+ EVAS_CALLBACK_MOUSE_MOVE,
+ __rs_cb_mouse_move, watcher_evas_h);
+ evas_object_event_callback_add(watcher_evas_h->img_tbm,
+ EVAS_CALLBACK_MOUSE_WHEEL,
+ __rs_cb_mouse_wheel, watcher_evas_h);
+ evas_object_event_callback_add(watcher_evas_h->img_tbm,
+ EVAS_CALLBACK_SHOW,
+ __rs_cb_show, watcher_evas_h);
+ evas_object_event_callback_add(watcher_evas_h->img_tbm,
+ EVAS_CALLBACK_HIDE,
+ __rs_cb_hide, watcher_evas_h);
+
+ /* Store watcher_evas_h */
+ g_hash_table_insert(__watcher_tbl, watcher_evas_h->img_tbm, watcher_evas_h);
+
+ /* Set data to use in accessibility */
+ snprintf(plug_id, sizeof(plug_id), "%s:%d", appid, pid);
+ evas_object_data_set(watcher_evas_h->img_tbm, "___PLUGID", strdup(plug_id));
+ evas_object_event_callback_add(watcher_evas_h->img_tbm,
+ EVAS_CALLBACK_MOVE, __obj_move_cb, watcher_evas_h);
+
+ is_added = true;
+ }
+
+ /* check type of given buffer */
+ if (type == 0) {//if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM) {
+
+ /* get tbm surface from buffer */
+ tbm_surface = wl_buffer_get_user_data(tbm);
+ width = tbm_surface_get_width(tbm_surface);
+ height = tbm_surface_get_height(tbm_surface);
+
+ memset(&ns, 0, sizeof(Evas_Native_Surface));
+ ns.version = EVAS_NATIVE_SURFACE_VERSION;
+ ns.type = EVAS_NATIVE_SURFACE_TBM;
+ ns.data.tbm.buffer = tbm_surface;
+
+ evas_object_resize(watcher_evas_h->img_tbm, width, height);
+ evas_object_image_size_set(watcher_evas_h->img_tbm, width, height);
+ evas_object_image_native_surface_set(watcher_evas_h->img_tbm, &ns); /* set native surface */
+ evas_object_image_pixels_dirty_set(watcher_evas_h->img_tbm, EINA_TRUE); /* set dirty for image updating */
+
+ //evas_object_del(watcher_evas_h->img_file); /* delete previous object for the image file type */
+
+ } else if (type == 1) {//} else if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE) {
+
+ if (!watcher_evas_h->img_file) {
+ watcher_evas_h->img_file = evas_object_image_filled_add(
+ evas_object_evas_get(__viewer_win));
+ }
+
+ map = mmap(NULL, img_file_size, PROT_READ, MAP_SHARED, img_file_fd, 0);
+ evas_object_image_memfile_set(watcher_evas_h->img_file, map, img_file_size, format, NULL);
+ evas_object_image_size_get(watcher_evas_h->img_tbm, &width, &height);
+ evas_object_image_fill_set(watcher_evas_h->img_file, 0, 0, width, height);
+ evas_object_resize(watcher_evas_h->img_file, width, height);
+ munmap(map, img_file_size);
+ close(img_file_fd); /* close passed fd */
+
+ evas_object_image_native_surface_set(watcher_evas_h->img_tbm, NULL); /* set null to previous object for the tbm type */
+ }
+
+ if (is_added) {
+ LOGD("call added !!!! %s", appid);
+ watcher_evas_h->ops->added(appid, watcher_evas_h->img_tbm,
+ watcher_evas_h->data);
+ } else {
+ LOGD("call updated !!!! %s", appid);
+ watcher_evas_h->ops->updated(appid, watcher_evas_h->img_tbm,
+ watcher_evas_h->data);
+ }
+
+}
+
+static void __watcher_update_cb(struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time, void *data)
+{
+ __watcher_change_cb(trs, 0, buffer, 0, 0, 0, NULL, data);
+}
+
+static void __free_watcher_evas_h(screen_connector_watcher_evas_h watcher_evas_h)
+{
+ if (!watcher_evas_h)
+ return;
+
+ if (watcher_evas_h->watcher_h)
+ screen_connector_watcher_remove(watcher_evas_h->watcher_h);
+
+ if (watcher_evas_h->img_tbm) {
+ evas_object_del(watcher_evas_h->img_tbm);
+ watcher_evas_h->img_tbm = NULL;
+ }
+
+ if (watcher_evas_h->ops)
+ free(watcher_evas_h->ops);
+
+ free(watcher_evas_h);
+}
+
+static void __watcher_missing_cb(struct tizen_remote_surface *trs, void *data)
+{
+ screen_connector_watcher_evas_h watcher_evas_h;
+ char *plug_id;
+ char *appid;
+
+ LOGD("missing");
+ watcher_evas_h = (screen_connector_watcher_evas_h)data;
+ if (!watcher_evas_h) {
+ LOGE("Null watcher_evas_h");
+ return;
+ }
+
+ g_hash_table_remove(__watcher_tbl, watcher_evas_h->img_tbm);
+
+ /* Remove data used in accessibility */
+ plug_id = evas_object_data_del(watcher_evas_h->img_tbm, "___PLUGID");
+ free(plug_id);
+
+ appid = screen_connector_watcher_get_appid(watcher_evas_h->watcher_h);
+ watcher_evas_h->ops->removed(appid, watcher_evas_h->img_tbm, watcher_evas_h->data);
+ __free_watcher_evas_h(watcher_evas_h);
+}
+
+
EXPORT_API screen_connector_watcher_evas_h screen_connector_watcher_evas_add(screen_connector_watcher_evas_ops *ops, char *id, void *data)
{
screen_connector_watcher_evas_h handle;
screen_connector_watcher_evas_ops *evas_ops;
- screen_connector_watcher_ops *watcher_ops;
+ screen_connector_watcher_ops watcher_ops;
- watcher_ops = (screen_connector_watcher_ops *)calloc(1, sizeof(screen_connector_watcher_ops));
- watcher_ops->added = __watcher_added_cb;
- watcher_ops->removed = __watcher_removed_cb;
- watcher_ops->updated = __watcher_updated_cb;
+ watcher_ops.change_cb = __watcher_change_cb;
+ watcher_ops.missing_cb = __watcher_missing_cb;
+ watcher_ops.update_cb = __watcher_update_cb;
evas_ops = (screen_connector_watcher_evas_ops *)calloc(1, sizeof(screen_connector_watcher_evas_ops));
if (evas_ops == NULL) {
@@ -107,7 +476,7 @@ EXPORT_API screen_connector_watcher_evas_h screen_connector_watcher_evas_add(scr
}
handle->ops = evas_ops;
handle->data = data;
- handle->watcher_h = screen_connector_watcher_add(watcher_ops, id, handle);
+ handle->watcher_h = screen_connector_watcher_add(&watcher_ops, id, handle);
return handle;
}
@@ -126,4 +495,234 @@ EXPORT_API int screen_connector_watcher_evas_update(const char *appid)
ret = screen_connector_watcher_update(appid);
return ret;
}
+
+
+static void __send_visibility(gpointer key, gpointer value, gpointer user_data)
+{
+ screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)value;
+ Evas_Object *evas_obj = (Evas_Object *)key;
+ unsigned int event = GPOINTER_TO_INT(user_data);
+ int ret;
+ visibility_type type;
+
+ if (watcher_evas_h->freeze)
+ return;
+
+ if (!__obj_is_visible(evas_obj))
+ return;
+
+ if (event)
+ type = VISIBILITY_TYPE_FULLY_OBSCURED;
+ else
+ type = VISIBILITY_TYPE_UNOBSCURED;
+
+ ret = __set_visibility(watcher_evas_h, type);
+ if (ret == -1)
+ LOGE("failed to set object visibility set %p to %d", evas_obj, type);
+}
+
+static Eina_Bool __visibility_cb(void *data, int type, void *event)
+{
+ Ecore_Wl_Event_Window_Visibility_Change *ev = event;
+
+ LOGD("visibility change: %d %d", (unsigned int)ev->win,
+ (unsigned int)ev->fully_obscured);
+
+ if (!__watcher_tbl)
+ return ECORE_CALLBACK_RENEW;
+
+ g_hash_table_foreach(__watcher_tbl, __send_visibility,
+ GINT_TO_POINTER(ev->fully_obscured));
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+EXPORT_API int screen_connector_watcher_evas_start_visibility_notify()
+{
+ if (__visibility_listener)
+ return 0;
+
+ __visibility_listener = ecore_event_handler_add(
+ ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, __visibility_cb, NULL);
+
+ return 0;
+}
+
+
+EXPORT_API int screen_connector_watcher_evas_stop_visibility_notify()
+{
+ if (!__visibility_listener)
+ return 0;
+
+ ecore_event_handler_del(__visibility_listener);
+ __visibility_listener = NULL;
+
+ return 0;
+}
+
+EXPORT_API int screen_connector_watcher_evas_freeze_visibility(Evas_Object *obj, visibility_type type)
+{
+ screen_connector_watcher_evas_h watcher_evas_h;
+
+ watcher_evas_h = (screen_connector_watcher_evas_h)g_hash_table_lookup(__watcher_tbl, obj);
+ if (!watcher_evas_h) {
+ LOGE("obj not found");
+ return -1;
+ }
+ watcher_evas_h->freeze = 1;
+
+ return __set_visibility(watcher_evas_h, type);
+}
+
+EXPORT_API int screen_connector_watcher_evas_thaw_visibility(Evas_Object *obj)
+{
+ screen_connector_watcher_evas_h watcher_evas_h;
+
+ watcher_evas_h = (screen_connector_watcher_evas_h)g_hash_table_lookup(__watcher_tbl, obj);
+ if (!watcher_evas_h) {
+ LOGE("obj not found");
+ return -1;
+ }
+ watcher_evas_h->freeze = 0;
+
+ return 0;
+}
+
+EXPORT_API int screen_connector_watcher_evas_send_mouse_up(Evas_Object *obj)
+{
+ screen_connector_watcher_evas_h watcher_evas_h;
+ int x;
+ int y;
+ int w;
+ int h;
+ unsigned int timestamp;
+ struct tizen_remote_surface *surface;
+
+ watcher_evas_h = g_hash_table_lookup(__watcher_tbl, obj);
+ if (!watcher_evas_h) {
+ LOGE("unknown object. not widget object.");
+ return -1;
+ }
+
+ if (!watcher_evas_h->img_tbm) {
+ LOGE("surface not yet initialized.");
+ return -1;
+ }
+
+ surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h);
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ timestamp = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff);
+ tizen_remote_surface_transfer_mouse_event(surface,
+ TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP,
+ 0,
+ 1,
+ w / 2,
+ h / 2,
+ 0,
+ 0,
+ 0,
+ 0,
+ TIZEN_INPUT_DEVICE_CLAS_MOUSE,
+ TIZEN_INPUT_DEVICE_SUBCLAS_NONE,
+ "",
+ timestamp);
+
+ return 0;
+}
+
+EXPORT_API int screen_connector_watcher_evas_send_touch_cancel(Evas_Object *obj)
+{
+ screen_connector_watcher_evas_h watcher_evas_h;
+ struct tizen_remote_surface *surface;
+
+ watcher_evas_h = g_hash_table_lookup(__watcher_tbl, obj);
+ if (!watcher_evas_h) {
+ LOGE("unknown object. not widget object.");
+ return -1;
+ }
+
+ if (watcher_evas_h->img_tbm) {
+ surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h);
+ tizen_remote_surface_transfer_touch_cancel(surface);
+ watcher_evas_h->cancel_touch = true;
+ } else {
+ LOGE("surface not yet initialized.");
+ return -1;
+ }
+
+ return 0;
+}
+
+EXPORT_API int screen_connector_watcher_evas_add_by_rid(screen_connector_watcher_evas_ops *ops, int res_id, void *data)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+ screen_connector_watcher_evas_h watcher_evas_h;
+ screen_connector_watcher_evas_h cur_h = NULL;
+ screen_connector_watcher_evas_ops *evas_ops;
+ char *appid = NULL;
+ int pid = 0;
+ screen_connector_watcher_ops watcher_ops;
+
+ watcher_ops.change_cb = __watcher_change_cb;
+ watcher_ops.missing_cb = __watcher_missing_cb;
+ watcher_ops.update_cb = __watcher_update_cb;
+
+ g_hash_table_iter_init(&iter, __watcher_tbl);
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ cur_h = (screen_connector_watcher_evas_h)value;
+ if (screen_connector_watcher_get_resource_id(cur_h->watcher_h) == res_id) {
+ appid = screen_connector_watcher_get_appid(cur_h->watcher_h);
+ pid = screen_connector_watcher_get_pid(cur_h->watcher_h);
+ break;
+ }
+ }
+
+ evas_ops = (screen_connector_watcher_evas_ops *)calloc(1, sizeof(screen_connector_watcher_evas_ops));
+ if (evas_ops == NULL) {
+ LOGE("evas_ops calloc fail");
+ return -1;
+ }
+
+ memcpy(evas_ops, ops, sizeof(screen_connector_watcher_evas_ops));
+ watcher_evas_h = (screen_connector_watcher_evas_h)calloc(1, sizeof(struct _screen_connector_watcher_evas_h));
+ if (watcher_evas_h == NULL) {
+ LOGE("handle calloc fail");
+ return -1;
+ }
+ watcher_evas_h->ops = evas_ops;
+ watcher_evas_h->data = data;
+ watcher_evas_h->watcher_h = screen_connector_watcher_create_handle(appid, pid, &watcher_ops, watcher_evas_h);
+ screen_connector_watcher_redirect_surface(watcher_evas_h->watcher_h);
+ return 0;
+}
+
+EXPORT_API int screen_connector_watcher_evas_get_rid(Evas_Object *obj, int *resource_id)
+{
+
+ screen_connector_watcher_evas_h watcher_evas_h;
+
+ watcher_evas_h = (screen_connector_watcher_evas_h)g_hash_table_lookup(__watcher_tbl, obj);
+ if (!watcher_evas_h) {
+ LOGE("unknown object. not widget object");
+ return -1;
+ }
+
+ return screen_connector_watcher_get_resource_id(watcher_evas_h->watcher_h);
+}
+
+
+EXPORT_API int screen_connector_watcher_evas_get_pid(Evas_Object *obj, int *pid)
+{
+ screen_connector_watcher_evas_h watcher_evas_h;
+
+ watcher_evas_h = (screen_connector_watcher_evas_h)g_hash_table_lookup(__watcher_tbl, obj);
+ if (!watcher_evas_h) {
+ LOGE("unknown object. not widget object");
+ return -1;
+ }
+
+ return screen_connector_watcher_get_pid(watcher_evas_h->watcher_h);
+}
+
/* End of a file */