summaryrefslogtreecommitdiff
path: root/screen_connector_watcher_evas
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 /screen_connector_watcher_evas
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>
Diffstat (limited to 'screen_connector_watcher_evas')
-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
2 files changed, 634 insertions, 21 deletions
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 */