subsurface: add and use _e_comp_wl_subsurface_data_get() 27/241227/3
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 23 Jul 2020 02:37:39 +0000 (11:37 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Sun, 23 Aug 2020 23:36:58 +0000 (23:36 +0000)
Change-Id: Iec6bfcdea79b173e78a266703a421dfc5948c143

src/bin/e_comp_wl_subsurface.c

index 0358a2e02b8da7ca5190412b35ebf1288d0eb046..102d521e85949e8cb73cc6b8000ee78719c447a4 100644 (file)
@@ -5,6 +5,8 @@
 static struct wl_global *global = NULL;
 static Eina_List *hooks = NULL;
 
+static E_Comp_Wl_Subsurf_Data *_e_comp_wl_subsurface_data_get(E_Client *ec);
+
 static Eina_Bool  _e_comp_wl_subsurface_circular_reference_check(E_Client *ec, E_Client *parent);
 static void       _e_comp_wl_subsurface_invalid_parent_handle(E_Client *ec, struct wl_resource *resource);
 static void       _e_comp_wl_subsurface_parent_commit(E_Client *ec, Eina_Bool parent_synchronized);
@@ -173,7 +175,7 @@ _e_comp_wl_subsurface_check_below_bg_rectangle(E_Client *ec)
 {
    E_Client *topmost;
 
-   if (ec->comp_data->sub.data)
+   if (_e_comp_wl_subsurface_data_get(ec))
      {
          topmost = e_comp_wl_topmost_parent_get(ec);
          if (!topmost || e_object_is_del(E_OBJECT(topmost)) || !topmost->comp_data) return;
@@ -368,7 +370,9 @@ _e_comp_wl_subsurface_commit_to_cache(E_Client *ec)
    Eina_Rectangle *rect;
 
    if (!(cdata = ec->comp_data)) return;
-   if (!(sdata = cdata->sub.data)) return;
+
+   sdata = _e_comp_wl_subsurface_data_get(ec);
+   if (!sdata) return;
 
    DBG("Subsurface Commit to Cache");
 
@@ -438,11 +442,10 @@ _e_comp_wl_subsurface_commit_to_cache(E_Client *ec)
 static void
 _e_comp_wl_subsurface_commit_from_cache(E_Client *ec)
 {
-   E_Comp_Client_Data *cdata;
    E_Comp_Wl_Subsurf_Data *sdata;
 
-   if (!(cdata = ec->comp_data)) return;
-   if (!(sdata = cdata->sub.data)) return;
+   sdata = _e_comp_wl_subsurface_data_get(ec);
+   if (!sdata) return;
 
    DBG("Subsurface Commit from Cache");
 
@@ -474,7 +477,7 @@ _e_comp_wl_subsurface_synchronized_commit(E_Client *ec)
    E_Client *subc;
    Eina_List *l;
 
-   sdata = ec->comp_data->sub.data;
+   sdata = _e_comp_wl_subsurface_data_get(ec);
 
    if (sdata->cached.has_data)
      _e_comp_wl_subsurface_commit_from_cache(ec);
@@ -498,7 +501,9 @@ _e_comp_wl_subsurface_parent_commit(E_Client *ec, Eina_Bool parent_synchronized)
    E_Comp_Wl_Subsurf_Data *sdata;
 
    if (!ec || e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return;
-   if (!(sdata = ec->comp_data->sub.data)) return;
+
+   sdata = _e_comp_wl_subsurface_data_get(ec);
+   if (!sdata) return;
    if (!(parent = sdata->parent)) return;
 
    if (sdata->position.set)
@@ -529,7 +534,9 @@ _e_comp_wl_subsurface_cb_position_set(struct wl_client *client EINA_UNUSED, stru
    ec = wl_resource_get_user_data(resource);
 
    if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return;
-   if (!(sdata = ec->comp_data->sub.data)) return;
+
+   sdata = _e_comp_wl_subsurface_data_get(ec);
+   if (!sdata) return;
 
    sdata->position.x = x;
    sdata->position.y = y;
@@ -607,7 +614,9 @@ _e_comp_wl_subsurface_cb_sync_set(struct wl_client *client EINA_UNUSED, struct w
    ec = wl_resource_get_user_data(resource);
 
    if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return;
-   if (!(sdata = ec->comp_data->sub.data)) return;
+
+   sdata = _e_comp_wl_subsurface_data_get(ec);
+   if (!sdata) return;
 
    sdata->synchronized = EINA_TRUE;
 }
@@ -623,7 +632,9 @@ _e_comp_wl_subsurface_cb_desync_set(struct wl_client *client EINA_UNUSED, struct
    ec = wl_resource_get_user_data(resource);
 
    if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return;
-   if (!(sdata = ec->comp_data->sub.data)) return;
+
+   sdata = _e_comp_wl_subsurface_data_get(ec);
+   if (!sdata) return;
 
    if (sdata->synchronized)
      {
@@ -821,7 +832,7 @@ _e_comp_wl_subsurface_synchronized_get(E_Comp_Wl_Subsurf_Data *sdata)
         if (!sdata->parent->comp_data) return EINA_FALSE;
         if (e_object_is_del(E_OBJECT(sdata->parent))) return EINA_FALSE;
 
-        sdata = sdata->parent->comp_data->sub.data;
+        sdata = _e_comp_wl_subsurface_data_get(sdata->parent);
      }
 
    return EINA_FALSE;
@@ -1024,7 +1035,9 @@ e_comp_wl_subsurface_commit(E_Client *ec)
 
    /* check for valid subcompositor data */
    if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return EINA_FALSE;
-   if (!(sdata = ec->comp_data->sub.data)) return EINA_FALSE;
+
+   sdata = _e_comp_wl_subsurface_data_get(ec);
+   if (!sdata) return EINA_FALSE;
 
    if (_e_comp_wl_subsurface_synchronized_get(sdata))
      _e_comp_wl_subsurface_commit_to_cache(ec);
@@ -1070,13 +1083,13 @@ e_comp_wl_subsurface_commit(E_Client *ec)
 EINTERN Eina_Bool
 e_comp_wl_subsurface_can_show(E_Client *ec)
 {
-   E_Comp_Wl_Subsurf_Data *sdata = ec->comp_data->sub.data;
+   E_Comp_Wl_Subsurf_Data *sdata;
    E_Client *invisible_parent;
    E_Client *topmost;
 
    /* if it's not subsurface */
-   if (!sdata)
-     return EINA_FALSE;
+   sdata = _e_comp_wl_subsurface_data_get(ec);
+   if (!sdata) return EINA_FALSE;
 
    invisible_parent = _e_comp_wl_subsurface_invisible_parent_get(ec);
    topmost = e_comp_wl_topmost_parent_get(ec);
@@ -1272,3 +1285,9 @@ _e_comp_wl_subsurface_remove_from_parent(E_Client *parent, E_Client *subc)
    parent->comp_data->sub.below_list_pending =
       eina_list_remove(parent->comp_data->sub.below_list_pending, subc);
 }
+
+static E_Comp_Wl_Subsurf_Data *
+_e_comp_wl_subsurface_data_get(E_Client *ec)
+{
+   return (ec->comp_data) ? (ec->comp_data->sub.data) : NULL;
+}