video: Emit 'E_EVENT_CLIENT_VISIBILITY_CHANGE' event to video client.
authorSeunghun <shiin.lee@samsung.com>
Wed, 27 Feb 2019 07:42:50 +0000 (16:42 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 12 Apr 2019 10:00:22 +0000 (19:00 +0900)
'E_EVENT_CLIENT_VISIBILITY_CHANGE' will be raised for video client if
follow_topmost_visibility flag is set. This will set enlightenment
module free to handle changing visibility.

Change-Id: I8721877b21579389fd43a047070f5da1884e7680

src/bin/video/e_comp_wl_video.c
src/bin/video/iface/e_video_hwc_windows.c

index 5f999ec5d96b0dfad59526457b23aba96cfde0ba..aae621a9fe3dce04f6d75d323f56c4a03ce180c5 100644 (file)
@@ -29,10 +29,9 @@ struct _E_Video
    struct wl_resource *surface;
    E_Client *ec;
    Ecore_Window window;
+   Ecore_Event_Handler *vis_eh;
 
-   Eina_Bool  follow_topmost_visibility;
    Eina_Bool  allowed_attribute;
-
 };
 
 static Eina_List *video_list = NULL;
@@ -154,6 +153,8 @@ _e_video_destroy(E_Video *video)
 
    wl_resource_set_destructor(video->video_object, NULL);
 
+   E_FREE_FUNC(video->vis_eh, ecore_event_handler_del);
+
    e_client_video_unset(video->ec);
 
    free(video);
@@ -229,6 +230,33 @@ _e_comp_wl_video_object_cb_set_attribute(struct wl_client *client,
    e_client_video_property_set(video->ec, id, v);
 }
 
+static Eina_Bool
+_e_comp_wl_video_cb_visibility_change(void *data, int type, void *event)
+{
+   E_Video *video;
+   E_Client *ec;
+   E_Event_Client *ev;
+
+   ev = event;
+   video = data;
+   if (video->ec != ev->ec)
+     return ECORE_CALLBACK_PASS_ON;
+
+   ec = ev->ec;
+   switch (ec->visibility.obscured)
+     {
+      case E_VISIBILITY_FULLY_OBSCURED:
+         evas_object_hide(ec->frame);
+         break;
+      default:
+      case E_VISIBILITY_UNOBSCURED:
+         evas_object_show(ec->frame);
+         break;
+     }
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
 static void
 _e_comp_wl_video_object_cb_follow_topmost_visibility(struct wl_client *client,
                                                      struct wl_resource *resource)
@@ -238,13 +266,20 @@ _e_comp_wl_video_object_cb_follow_topmost_visibility(struct wl_client *client,
    video = wl_resource_get_user_data(resource);
    EINA_SAFETY_ON_NULL_RETURN(video);
 
-   if(!video->ec || video->follow_topmost_visibility)
+   if(!video->ec)
      return;
 
    VIN("set follow_topmost_visibility");
 
-   video->follow_topmost_visibility= EINA_TRUE;
    e_client_video_topmost_visibility_follow(video->ec);
+
+   if (!video->vis_eh)
+     {
+        video->vis_eh =
+           ecore_event_handler_add(E_EVENT_CLIENT_VISIBILITY_CHANGE,
+                                   (Ecore_Event_Handler_Cb)_e_comp_wl_video_cb_visibility_change,
+                                   video);
+     }
 }
 
 static void
@@ -256,13 +291,13 @@ _e_comp_wl_video_object_cb_unfollow_topmost_visibility(struct wl_client *client,
    video = wl_resource_get_user_data(resource);
    EINA_SAFETY_ON_NULL_RETURN(video);
 
-   if(!video->ec || !video->follow_topmost_visibility)
+   if(!video->ec)
      return;
 
    VIN("set unfollow_topmost_visibility");
 
-   video->follow_topmost_visibility= EINA_FALSE;
    e_client_video_topmost_visibility_unfollow(video->ec);
+   E_FREE_FUNC(video->vis_eh, ecore_event_handler_del);
 }
 
 static void
index 8334367258d640e86fff22fc8fccbfd5c3ddc1d0..fc460481bb5a2c96918cd27650a550c1e5fb2ce9 100644 (file)
@@ -1733,38 +1733,54 @@ _e_video_cb_ec_visibility_change(void *data, int type, void *event)
    return ECORE_CALLBACK_PASS_ON;
 }
 
+static void
+_e_video_ec_visibility_event_free(void *d EINA_UNUSED, E_Event_Client *ev)
+{
+   e_object_unref(E_OBJECT(ev->ec));
+   free(ev);
+}
+
+static void
+_e_video_ec_visibility_event_send(E_Client *ec)
+{
+   E_Event_Client *ev;
+   int obscured;
+
+   obscured = ec->visibility.obscured;
+   ELOGF("VIDEO <INF>", "Signal visibility change event of video, type %d",
+         ec, obscured);
+
+   ev = E_NEW(E_Event_Client, 1);
+   if (!ev) return;
+   ev->ec = ec;
+   e_object_ref(E_OBJECT(ec));
+   ecore_event_add(E_EVENT_CLIENT_VISIBILITY_CHANGE, ev,
+                   (Ecore_End_Cb)_e_video_ec_visibility_event_free, NULL);
+}
+
 static Eina_Bool
 _e_video_cb_topmost_ec_visibility_change(void *data, int type, void *event)
 {
-   E_Event_Client *ev = event;
-   E_Client *ec = ev->ec;
    E_Video_Hwc_Windows *evhw;
-   Eina_List *l = NULL;
+   E_Event_Client *ev;
+   E_Client *topmost;
 
-   EINA_LIST_FOREACH(video_list, l, evhw)
-     {
-        E_Client *topmost = e_comp_wl_topmost_parent_get(evhw->ec);
-        if (!topmost) continue;
-        if (topmost == evhw->ec) continue;
-        if (topmost != ec) continue;
-        if (evhw->follow_topmost_visibility)
-          {
-             switch (ec->visibility.obscured)
-               {
-                case E_VISIBILITY_FULLY_OBSCURED:
-                   VIN("follow_topmost_visibility: fully_obscured");
-                   _e_video_cb_evas_hide(evhw, NULL, NULL, NULL);
-                   break;
-                case E_VISIBILITY_UNOBSCURED:
-                   VIN("follow_topmost_visibility: UNOBSCURED");
-                   _e_video_cb_evas_show(evhw, NULL, NULL, NULL);
-                   break;
-                default:
-                   return ECORE_CALLBACK_PASS_ON;
-               }
-          }
-     }
+   ev = event;
+   evhw = data;
+   if (!evhw->follow_topmost_visibility)
+       goto end;
+
+   topmost = e_comp_wl_topmost_parent_get(evhw->ec);
+   if (!topmost) goto end;
+   if (topmost != ev->ec) goto end;
+   if (topmost == evhw->ec) goto end;
+   if (evhw->ec->visibility.obscured == topmost->visibility.obscured) goto end;
+
+   /* Update visibility of video client by changing visibility of topmost client */
+   evhw->ec->visibility.obscured = topmost->visibility.obscured;
+   _e_video_ec_visibility_event_send(evhw->ec);
 
+end:
    return ECORE_CALLBACK_PASS_ON;
 }