Check multi viewer window visibility 28/139328/2
authorHyunho Kang <hhstark.kang@samsung.com>
Tue, 18 Jul 2017 10:30:21 +0000 (19:30 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Tue, 18 Jul 2017 11:19:27 +0000 (20:19 +0900)
Viewer's visibility has to be decided based on
every viewer window include bind target window.

Change-Id: I1ec9299ab2ff23429cb6b214b39ecc422c747fc1
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h
screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c

index 65c7724..6b16d7d 100644 (file)
@@ -43,6 +43,7 @@ typedef enum {
        VISIBILITY_TYPE_UNOBSCURED,
        VISIBILITY_TYPE_PARTIALLY_OBSCURED,
        VISIBILITY_TYPE_FULLY_OBSCURED,
+       VISIBILITY_TYPE_UNKNOWN,
 } visibility_type;
 
 typedef void (*screen_connector_toolkit_evas_added_cb)(const char *appid, const char *instance_id, const int pid,
index 41a7926..d0b12dd 100644 (file)
@@ -48,6 +48,12 @@ struct _cur_buffer_info_h {
 };
 typedef struct _cur_buffer_info_h *cur_buffer_info_h;
 
+struct _viewer_visibility_h {
+       visibility_type visibility;
+       int win_id;
+};
+typedef struct _viewer_visibility_h *viewer_visibility_h;
+
 struct _screen_connector_toolkit_evas_h {
        screen_connector_toolkit_evas_ops *ops;
        screen_connector_toolkit_h toolkit_h;
@@ -60,6 +66,7 @@ struct _screen_connector_toolkit_evas_h {
        struct wl_buffer *cur_buffer;
        struct _screen_connector_type_evas_h *type_h;
        guint resuming_timer;
+       GList *viewer_visibility_list;
        void *data;
 };
 
@@ -77,6 +84,13 @@ static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info
 static void __rs_cb_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static void __obj_update_visibility(void *data, Evas *e, Evas_Object *obj, void *event_info);
 
+static gint __comp_win_id(gconstpointer a, gconstpointer b)
+{
+       viewer_visibility_h win = (viewer_visibility_h)a;
+
+       return !(win->win_id == GPOINTER_TO_INT(b));
+}
+
 static void __destroy_type_h(gpointer data)
 {
        screen_connector_type_evas_h type_h = (screen_connector_type_evas_h)data;
@@ -205,6 +219,9 @@ static void __destroy_toolkit_evas_h(gpointer data)
        if (toolkit_evas_h->resuming_timer > 0)
                g_source_remove(toolkit_evas_h->resuming_timer);
 
+       if (toolkit_evas_h->viewer_visibility_list)
+               g_list_free_full(toolkit_evas_h->viewer_visibility_list, free);
+
        free(toolkit_evas_h);
 }
 
@@ -883,9 +900,12 @@ EXPORT_API int screen_connector_toolkit_evas_update(const char *appid, const cha
 static void __send_visibility(gpointer key, gpointer value, gpointer user_data)
 {
        screen_connector_toolkit_evas_h toolkit_evas_h = (screen_connector_toolkit_evas_h)value;
-       unsigned int event = GPOINTER_TO_INT(user_data);
+       Ecore_Wl_Event_Window_Visibility_Change *ev = user_data;
        int ret;
        visibility_type type;
+       GList *tmp_list = NULL;
+       GList *iter;
+       viewer_visibility_h visibility_h;
 
        if (toolkit_evas_h->freeze)
                return;
@@ -893,11 +913,50 @@ static void __send_visibility(gpointer key, gpointer value, gpointer user_data)
        if (!__obj_is_visible(toolkit_evas_h))
                return;
 
-       if (event)
+       if (ev->fully_obscured)
                type = VISIBILITY_TYPE_FULLY_OBSCURED;
        else
                type = VISIBILITY_TYPE_UNOBSCURED;
 
+       if (toolkit_evas_h->viewer_visibility_list) {
+               tmp_list = g_list_find_custom(
+                               toolkit_evas_h->viewer_visibility_list,
+                               GINT_TO_POINTER(ev->win), __comp_win_id);
+       }
+
+       if (tmp_list == NULL) {
+               visibility_h = (viewer_visibility_h)calloc(1,
+                               sizeof(struct _viewer_visibility_h));
+               if (visibility_h == NULL) {
+                       LOGE("Out of memory fail to alloc");
+                       return;
+               }
+               visibility_h->win_id = ev->win;
+               visibility_h->visibility = type;
+               toolkit_evas_h->viewer_visibility_list =
+                               g_list_append(toolkit_evas_h->viewer_visibility_list,
+                                               visibility_h);
+       } else {
+               visibility_h = (viewer_visibility_h)tmp_list->data;
+               visibility_h->visibility = type;
+       }
+
+       type = VISIBILITY_TYPE_FULLY_OBSCURED;
+       iter = toolkit_evas_h->viewer_visibility_list;
+       while (iter != NULL) {
+               visibility_h = (viewer_visibility_h)iter->data;
+               if (visibility_h->visibility == VISIBILITY_TYPE_UNKNOWN) {
+                       LOGE("viewer not ready");
+                       return;
+               } else if (visibility_h->visibility ==
+                               VISIBILITY_TYPE_UNOBSCURED) {
+                       type = VISIBILITY_TYPE_UNOBSCURED;
+                       break;
+               }
+               iter = g_list_next(iter);
+       }
+
+       LOGW("set visibility to %d", type);
        ret = __set_visibility(toolkit_evas_h, type);
        if (ret == -1)
                LOGE("failed to set object visibility  set %p to %d", toolkit_evas_h->img_tbm, type);
@@ -920,8 +979,8 @@ static Eina_Bool __visibility_cb(void *data, int type, void *event)
        while (g_hash_table_iter_next(&iter, &key, &value)) {
                cur_type = (screen_connector_type_evas_h)value;
                if (cur_type->toolkit_table)
-                       g_hash_table_foreach(cur_type->toolkit_table, __send_visibility,
-                                       GINT_TO_POINTER(ev->fully_obscured));
+                       g_hash_table_foreach(cur_type->toolkit_table,
+                                       __send_visibility, ev);
        }
 
        return ECORE_CALLBACK_RENEW;
@@ -1180,6 +1239,7 @@ EXPORT_API int screen_connector_toolkit_evas_bind(screen_connector_toolkit_evas_
 {
        struct wl_surface *surface;
        Ecore_Wl_Window *wl_win;
+       viewer_visibility_h visibility_h;
 
        if (!h)
                return -1;
@@ -1196,6 +1256,18 @@ EXPORT_API int screen_connector_toolkit_evas_bind(screen_connector_toolkit_evas_
                return -1;
        }
 
+       visibility_h = (viewer_visibility_h)calloc(1,
+                       sizeof(struct _viewer_visibility_h));
+       if (visibility_h == NULL) {
+               LOGE("Out of memory fail to alloc");
+               return -1;
+       }
+       visibility_h->win_id = ecore_wl_window_id_get(wl_win);
+       visibility_h->visibility = VISIBILITY_TYPE_UNKNOWN;
+
+       h->viewer_visibility_list =
+                       g_list_append(h->viewer_visibility_list, visibility_h);
+
        return screen_connector_toolkit_bind(h->toolkit_h, surface);
 }