subsurface: Add and use function for checking sub-surface 99/260199/5
authorSeunghun Lee <shiin.lee@samsung.com>
Mon, 21 Jun 2021 06:40:00 +0000 (15:40 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Tue, 22 Jun 2021 04:51:37 +0000 (13:51 +0900)
This lets us check if a E_Client is for sub-surface without accessing
particular data of sub-surface. And it should help with readability.

Note that DO NOT use this function to ensure the safety of accessing
"comp_data->sub.data". So, you cannot assume the validation by using
e_comp_wl_subsurface_check().
The function, by its name, doesn't imply anything about the safety at
all. It does only check whether given E_Client is for sub-surface.

Change-Id: I15f32c124ecf9a95a77b61095b0d855379d9c800

14 files changed:
src/bin/e_client.c
src/bin/e_comp_object.c
src/bin/e_comp_wl.c
src/bin/e_comp_wl_rsm.c
src/bin/e_comp_wl_shell.c
src/bin/e_comp_wl_subsurface.c
src/bin/e_comp_wl_subsurface.h
src/bin/e_desk.c
src/bin/e_desk_group.c
src/bin/e_foreign_shell.c
src/bin/e_info_server.c
src/bin/e_output.c
src/bin/e_policy.c
src/bin/e_policy_wl.c

index 70e451c4c28fab4902ee90879d01a1a3be41693d..8a87e08fe24eac0e07e271a88b7bec29a24e29c9 100644 (file)
@@ -3370,9 +3370,8 @@ _e_client_visibility_zone_calculate(E_Zone *zone)
         if (!ec->frame) continue;
         if (ec->visibility.skip) continue;
         if (ec->is_cursor) continue;
-        /* if ec is subsurface, skip this */
         cdata = e_client_cdata_get(ec);
-        if (cdata && cdata->sub.data) continue;
+        if (e_comp_wl_subsurface_check(ec)) continue;
         if ((!ec->first_mapped) &&
             (e_comp_object_content_type_get(ec->frame) == E_COMP_OBJECT_CONTENT_TYPE_INT_IMAGE)) continue;
 
@@ -7130,8 +7129,8 @@ e_client_transform_apply(E_Client *ec, double angle, double zoom, int cx, int cy
    E_Client *subc;
    Eina_List *l;
 
-   /* check if it's subsurface */
-   if (cdata->sub.data) return;
+   if (e_comp_wl_subsurface_check(ec))
+     return;
 
    /* check if it's different with current state */
    if ((ec->transform.angle == angle) &&
@@ -7722,7 +7721,6 @@ E_API Eina_Bool
 e_client_base_output_resolution_update(E_Client *ec)
 {
    E_Appinfo *eai = NULL;
-   E_Comp_Wl_Client_Data *cdata;
    int configured_width, configured_height;
    int width, height;
 
@@ -7736,8 +7734,8 @@ e_client_base_output_resolution_update(E_Client *ec)
    * Transform for subsurface will be applied when toplevel surface does by
    * implementation of e_client_transform_core.
    */
-  cdata = e_client_cdata_get(ec);
-  if (cdata && cdata->sub.data) return EINA_FALSE;
+  if (e_comp_wl_subsurface_check(ec))
+    return EINA_FALSE;
 
   configured_width = e_config->configured_output_resolution.w;
   configured_height = e_config->configured_output_resolution.h;
@@ -8423,4 +8421,4 @@ e_client_map_enable_set(E_Client *ec, Eina_Bool enable)
    evas_object_map_enable_set(ec->frame, enable);
 
    return EINA_TRUE;
-}
\ No newline at end of file
+}
index 1b481b82e55f48badba3207aad3c150391a00686..d6ac114448d5a5104d7700cb823fef23d5fced3c 100644 (file)
@@ -673,7 +673,7 @@ _e_comp_object_map_transform_pos(E_Client *ec, int sx, int sy, int *dx, int *dy)
    e_pixmap_size_get(ec->pixmap, &bw, &bh);
 
    /* for subsurface, it should be swap 90 and 270 */
-   if (cdata->sub.data)
+   if (e_comp_wl_subsurface_check(ec))
      switch (transform)
        {
         case WL_OUTPUT_TRANSFORM_90:          transform = WL_OUTPUT_TRANSFORM_270;         break;
@@ -1773,7 +1773,7 @@ static void
 _e_comp_intercept_layer_set(void *data, Evas_Object *obj, int layer)
 {
    E_Comp_Object *cw = data;
-   E_Comp_Wl_Client_Data *cdata, *child_cdata;
+   E_Comp_Wl_Client_Data *child_cdata;
    unsigned int l = e_comp_canvas_layer_map(layer);
    int oldraise;
 
@@ -1794,15 +1794,14 @@ _e_comp_intercept_layer_set(void *data, Evas_Object *obj, int layer)
                   e_comp_render_queue();
                }
              ec = e_client_above_get(cw->ec);
-             cdata = e_client_cdata_get(ec);
              /* skip subsurface: stacking subsurface is handled by e_comp_wl */
-             while ((ec) && (cdata) && (cdata->sub.data))
+             while ((ec) && (e_comp_wl_subsurface_check(ec)))
                ec = e_client_above_get(ec);
              if (ec && (evas_object_layer_get(ec->frame) != evas_object_layer_get(obj)))
                {
                   ec = e_client_below_get(cw->ec);
                   /* skip subsurface: stacking subsurface is handled by e_comp_wl */
-                  while ((ec) && (cdata) && (cdata->sub.data))
+                  while ((ec) && (e_comp_wl_subsurface_check(ec)))
                     ec = e_client_below_get(ec);
                   if (ec && (evas_object_layer_get(ec->frame) == evas_object_layer_get(cw->smart_obj)))
                     {
index 951ff5c5488a2b0dfe765e512befbba91f1e3acc..831ef139c456c1d4bb267a305965bcd1ff50bd1d 100644 (file)
@@ -268,7 +268,7 @@ e_comp_wl_output_buffer_transform_get(E_Client *ec)
    if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
 
    vp = &ec->comp_data->scaler.buffer_viewport;
-   if (ec->comp_data->sub.data)
+   if (e_comp_wl_subsurface_check(ec))
      return vp->buffer.transform;
 
    buffer = ec->comp_data->buffer_ref.buffer;
@@ -304,7 +304,7 @@ e_comp_wl_output_pending_buffer_transform_get(E_Client *ec)
    if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL;
 
    vp = &ec->comp_data->pending.buffer_viewport;
-   if (ec->comp_data->sub.data)
+   if (e_comp_wl_subsurface_check(ec))
      return vp->buffer.transform;
 
    buffer = ec->comp_data->pending.buffer;
@@ -2246,7 +2246,7 @@ _e_comp_wl_cb_client_rot_change_begin(void *d EINA_UNUSED, int t EINA_UNUSED, E_
    if (!ec) return ECORE_CALLBACK_PASS_ON;
    if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
    if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
-   if (ec->comp_data->sub.data) return ECORE_CALLBACK_PASS_ON;
+   if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
    if (ec->e.state.rot.ang.next < 0) return ECORE_CALLBACK_PASS_ON;
 
    vp = &ec->comp_data->scaler.buffer_viewport;
@@ -2266,7 +2266,7 @@ _e_comp_wl_cb_client_rot_change_cancel(void *d EINA_UNUSED, int t EINA_UNUSED, E
    if (!ec) return ECORE_CALLBACK_PASS_ON;
    if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
    if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
-   if (ec->comp_data->sub.data) return ECORE_CALLBACK_PASS_ON;
+   if (e_comp_wl_subsurface_check(ec)) return ECORE_CALLBACK_PASS_ON;
 
    vp = &ec->comp_data->scaler.buffer_viewport;
    vp->wait_for_transform_change = 0;
@@ -2544,7 +2544,7 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
                   cdata->shell.unmap(cdata->shell.surface);
                }
              else if ((ec->internal) ||
-                      (cdata->sub.data) ||
+                      (e_comp_wl_subsurface_check(ec)) ||
                       (ec == e_comp_wl->drag_client))
                {
                   ELOGF("COMP", "Try to unmap. Hide window. internal:%d, sub:%p, drag:%d",
@@ -2838,7 +2838,7 @@ _e_comp_wl_surface_cb_attach(struct wl_client *client EINA_UNUSED, struct wl_res
    if (!ec->comp_data->mapped)
      {
         if (ec->comp_data->shell.surface &&
-            !ec->internal && !ec->comp_data->sub.data && !ec->remote_surface.provider)
+            !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
           {
              ELOGF("COMP", "Current unmapped. ATTACH buffer:%p", ec, buffer);
           }
@@ -3023,7 +3023,7 @@ _e_comp_wl_surface_cb_commit(struct wl_client *client EINA_UNUSED, struct wl_res
    if (!ec->comp_data->mapped)
      {
         if (ec->comp_data->shell.surface && ec->comp_data->pending.new_attach &&
-            !ec->internal && !ec->comp_data->sub.data && !ec->remote_surface.provider)
+            !ec->internal && !e_comp_wl_subsurface_check(ec) && !ec->remote_surface.provider)
           {
              ELOGF("COMP", "Current unmapped. COMMIT. pixmap_usable:%d", ec, e_pixmap_usable_get(ec->pixmap));
 
@@ -4368,7 +4368,7 @@ e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer)
    e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, buffer);
 
    /* set usable early because shell module checks this */
-   if (ec->comp_data->shell.surface || ec->comp_data->sub.data)
+   if (ec->comp_data->shell.surface || e_comp_wl_subsurface_check(ec))
      e_pixmap_usable_set(ec->pixmap, (buffer != NULL));
 
    e_pixmap_resource_set(ec->pixmap, buffer);
@@ -4419,7 +4419,7 @@ e_comp_wl_surface_commit(E_Client *ec)
                   ELOGF("COMP", "Try to unmap2. Call shell.unmap.", ec);
                   ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
                }
-             else if (ec->internal || ec->comp_data->sub.data ||
+             else if (ec->internal || e_comp_wl_subsurface_check(ec) ||
                       (ec == e_comp_wl->drag_client))
                {
                   ELOGF("COMP", "Try to unmap2. Hide window. internal:%d, sub:%p, drag:%d",
index 14f17c0ede7bc4266450bacbcefca3a8b23a1dea..2ff17d9756b74283145cefc870f04cd914c0ec60 100644 (file)
@@ -305,7 +305,6 @@ _remote_provider_onscreen_parent_calculate(E_Comp_Wl_Remote_Provider *provider)
    Evas_Object *o;
    E_Client *ec, *_ec;
    E_Comp_Wl_Remote_Surface *surface, *parent = NULL;
-   E_Comp_Wl_Client_Data *cdata;
    Eina_List *l;
 
    if (!provider) return;
@@ -331,9 +330,7 @@ _remote_provider_onscreen_parent_calculate(E_Comp_Wl_Remote_Provider *provider)
         if ((_ec->visibility.obscured != E_VISIBILITY_UNOBSCURED) &&
             (_ec->visibility.obscured != E_VISIBILITY_PARTIALLY_OBSCURED))
           continue;
-        /* if _ec is subsurface, skip this */
-        cdata = (E_Comp_Wl_Client_Data *)_ec->comp_data;
-        if (cdata && cdata->sub.data) continue;
+        if (e_comp_wl_subsurface_check(_ec)) continue;
 
         if (!E_INTERSECTS(_ec->x, _ec->y, _ec->w, _ec->h, ec->zone->x, ec->zone->y, ec->zone->w, ec->zone->h))
           continue;
@@ -2441,7 +2438,7 @@ _remote_manager_cb_surface_create(struct wl_client *client,
 
         if (version >= TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_SINCE_VERSION)
           {
-             if ((ec->comp_data) && (ec->comp_data->sub.data))
+             if (e_comp_wl_subsurface_check(ec))
                {
                   ERR("Subsurface could not be source client");
                   goto fail;
@@ -2605,7 +2602,7 @@ _remote_manager_cb_surface_create_with_wl_surface(struct wl_client *client,
 
         if (version >= TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_SINCE_VERSION)
           {
-             if ((provider_ec->comp_data) && (provider_ec->comp_data->sub.data))
+             if (e_comp_wl_subsurface_check(provider_ec))
                {
                   ERR("Subsurface could not be source client");
                   goto fail;
index 18a98d1358b3cfb4add7d28424b8f6eaba1d2fc8..12bdb3ade6ff6e2f3855b9cb76a3cd3c1ed076ea 100644 (file)
@@ -740,7 +740,7 @@ _e_shell_client_map_common_post(E_Client *ec)
              ec->post_raise = EINA_FALSE;
           }
 
-        if (!ec->comp_data->sub.data)
+        if (!e_comp_wl_subsurface_check(ec))
           {
              if (ec->post_lower)
                {
index bb8f9f9f3661cef1f1b2e1576c646f725f312fcf..173c3d26535b6b7f29e75a047f4022f67c331ed6 100644 (file)
@@ -1319,6 +1319,13 @@ e_comp_wl_subsurface_check_below_bg_rectangle(E_Client *ec)
    _e_comp_wl_subsurface_check_below_bg_rectangle(ec);
 }
 
+EINTERN Eina_Bool
+e_comp_wl_subsurface_check(E_Client *ec)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
+   return ec->comp_data ? !!ec->comp_data->sub.data : EINA_FALSE;
+}
+
 static void
 _e_comp_wl_subsurface_cb_dummy_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
 {
index fd39475c36d88540f55a78f2b3eeb59dff4d6dc8..18d1c4dc81d58bc5e9e4416bac7d4e9197fbbff8 100644 (file)
@@ -23,5 +23,6 @@ EINTERN void          e_comp_wl_subsurface_restack(E_Client *ec);
 EINTERN Eina_Bool     e_comp_wl_video_subsurface_has(E_Client *ec);
 EINTERN Eina_Bool     e_comp_wl_normal_subsurface_has(E_Client *ec);
 EINTERN void          e_comp_wl_subsurface_check_below_bg_rectangle(E_Client *ec);
+EINTERN Eina_Bool     e_comp_wl_subsurface_check(E_Client *ec);
 
 #endif
index 18f7ac960533de40e0c35f61a4f36d7b34600708..2d0dd071aa5e5f97a84830547494e62e6ff3e7d3 100644 (file)
@@ -836,7 +836,6 @@ E_API void
 e_desk_geometry_set(E_Desk *desk, int x, int y, int w, int h)
 {
    E_Client *ec;
-   E_Comp_Wl_Client_Data *cdata;
    E_Maximize max;
    Eina_List *l = NULL, *ll = NULL;
    Evas_Object *m;
@@ -865,7 +864,6 @@ e_desk_geometry_set(E_Desk *desk, int x, int y, int w, int h)
 
    EINA_LIST_FOREACH(sd->clients, l, ec)
      {
-        cdata = e_client_cdata_get(ec);
         /* even if the desktop geometry is chagned, the system partial windows such as virtual
          * keyboard and clipboard should be placed at the bottom of the desktop. */
         /* QUICK FIX */
@@ -873,7 +871,7 @@ e_desk_geometry_set(E_Desk *desk, int x, int y, int w, int h)
           {
              continue;
           }
-        else if (cdata && cdata->sub.data)
+        else if (e_comp_wl_subsurface_check(ec))
            {
               continue;
            }
@@ -927,7 +925,6 @@ _animator_cb(void *data, double pos)
 {
    E_Desk *desk;
    E_Client *ec;
-   E_Comp_Wl_Client_Data *cdata;
    Eina_List *l;
    int cx, cy;
    double zoomx, zoomy;
@@ -952,9 +949,8 @@ _animator_cb(void *data, double pos)
 
    EINA_LIST_FOREACH(sd->clients, l, ec)
      {
-        cdata = e_client_cdata_get(ec);
         if ((ec->visibility.obscured == E_VISIBILITY_UNOBSCURED) ||
-            (cdata && cdata->sub.data))
+            (e_comp_wl_subsurface_check(ec)))
           _e_desk_client_zoom(ec, zoomx, zoomy, cx, cy);
      }
 
index 4ba4bb976249580e28b7e8e1e688091880fc314e..5e0c64cd86b0206a1b33d49cc7bd8f82a71bb3d9 100644 (file)
@@ -189,15 +189,12 @@ e_desk_group_del(E_Desk_Group *edg)
 
 void _e_desk_group_ec_geometry_apply(E_Desk_Group *edg, E_Client *ec)
 {
-   E_Comp_Wl_Client_Data *cdata;
    E_Util_Transform *transform;
 
    transform = ec->desk_group.transform;
    if (!transform) return;
 
-   // skip subsurface
-   cdata = e_client_cdata_get(ec);
-   if (cdata && cdata->sub.data)
+   if (e_comp_wl_subsurface_check(ec))
      return;
 
    e_util_transform_move(transform, edg->x, edg->y, 0);
index 7575fa35f772465536e5cb7e03f1af30b5d611fa..b61377aae50ead368e925c15915e2cb1002b3c1e 100644 (file)
@@ -136,8 +136,7 @@ e_foreign_shell_export(struct wl_resource *exporter, struct wl_resource *resourc
      }
 
    esc = wl_resource_get_user_data(surface);
-   if ((!esc->comp_data) ||
-       (!esc->comp_data->sub.data))
+   if (!e_comp_wl_subsurface_check(esc))
      {
         wl_resource_post_error(exporter,
                                WTZ_EXPORTER_ERROR_INVALID_ROLE,
index d0bcec093dbe055a63ea60eae4941577aac01c7e..8646db7b63d3b6eb3077ffba0253bb8713998e4a 100644 (file)
@@ -3027,7 +3027,7 @@ _e_info_server_cb_subsurface(const Eldbus_Service_Interface *iface EINA_UNUSED,
         else
           {
              if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) continue;
-             if (!ec->comp_data->sub.data &&
+             if (!e_comp_wl_subsurface_check(ec) &&
                  !ec->comp_data->sub.list && !ec->comp_data->sub.list_pending &&
                  !ec->comp_data->sub.below_list && !ec->comp_data->sub.below_list_pending)
                continue;
index 552a5c8e6d92934d1fe824d8ab2c50857f07eaf3..770fc33f029b54febca8880005dcb052ef11f6a6 100644 (file)
@@ -210,7 +210,6 @@ _e_output_zoom_top_visible_ec_get()
 {
    E_Client *ec;
    Evas_Object *o;
-   E_Comp_Wl_Client_Data *cdata;
 
    for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
      {
@@ -225,9 +224,7 @@ _e_output_zoom_top_visible_ec_get()
         if (!(ec->visibility.obscured == 0 || ec->visibility.obscured == 1)) continue;
         if (!ec->frame) continue;
         if (!evas_object_visible_get(ec->frame)) continue;
-        /* if ec is subsurface, skip this */
-        cdata = e_client_cdata_get(ec);
-        if (cdata && cdata->sub.data) continue;
+        if (e_comp_wl_subsurface_check(ec)) continue;
 
         return ec;
      }
@@ -563,7 +560,6 @@ _e_output_top_visible_ec_get()
 {
    E_Client *ec;
    Evas_Object *o;
-   E_Comp_Wl_Client_Data *cdata;
 
    for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
      {
@@ -578,9 +574,7 @@ _e_output_top_visible_ec_get()
         if (!(ec->visibility.obscured == 0 || ec->visibility.obscured == 1)) continue;
         if (!ec->frame) continue;
         if (!evas_object_visible_get(ec->frame)) continue;
-        /* if ec is subsurface, skip this */
-        cdata = e_client_cdata_get(ec);
-        if (cdata && cdata->sub.data) continue;
+        if (e_comp_wl_subsurface_check(ec)) continue;
 
         return ec;
      }
@@ -724,8 +718,8 @@ _e_output_visible_client_check(E_Output *output)
               if (ec->is_cursor) continue;
               if (!ec->visible) continue;
               if (!evas_object_visible_get(ec->frame)) continue;
+              if (e_comp_wl_subsurface_check(ec)) continue;
               cdata = e_client_cdata_get(ec);
-              if (cdata && cdata->sub.data) continue; /* skip subsurface */
               if (cdata && !cdata->mapped) continue;
               if (ec->iconic) continue;
               e_client_geometry_get(ec, &x, &y, &w, &h);
index b9376c3936b7ade64e6ba7d8613804254ffc3bba..7ae133663f48ccbba23cb712d00d80c3e122e981 100644 (file)
@@ -1847,13 +1847,10 @@ e_policy_client_is_noti(E_Client *ec)
 Eina_Bool
 e_policy_client_is_subsurface(E_Client *ec)
 {
-   E_Comp_Wl_Client_Data *cd;
-
    E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
    E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, EINA_FALSE);
 
-   cd = (E_Comp_Wl_Client_Data *)ec->comp_data;
-   if (cd && cd->sub.data)
+   if (e_comp_wl_subsurface_check(ec))
      return EINA_TRUE;
 
    return EINA_FALSE;
index d5b9164bfb4c4dda054f48f22eef0e94c11545dc..b947adffd5e491fb4447b048df3af9cb64bf498c 100644 (file)
@@ -2122,9 +2122,8 @@ _tzpol_iface_cb_subsurface_get(struct wl_client *client, struct wl_resource *res
 
    if (e_object_is_del(E_OBJECT(ec))) return;
 
-   cdata = e_client_cdata_get(ec);
    /* check if this surface is already a sub-surface */
-   if (cdata && cdata->sub.data)
+   if (e_comp_wl_subsurface_check(ec))
      {
         wl_resource_post_error(resource,
                                WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE,
@@ -2164,6 +2163,7 @@ _tzpol_iface_cb_subsurface_get(struct wl_client *client, struct wl_resource *res
      }
 
    /* ec's parent comes from another process */
+   cdata = e_client_cdata_get(ec);
    if (cdata)
      cdata->has_extern_parent = EINA_TRUE;
 }
@@ -4464,7 +4464,6 @@ _e_tzsh_indicator_find_topvisible_client(E_Zone *zone)
 {
    E_Client *ec;
    Evas_Object *o;
-   E_Comp_Wl_Client_Data *cdata;
    int ex, ey, ew, eh;
 
    o = evas_object_top_get(e_comp->evas);
@@ -4486,9 +4485,7 @@ _e_tzsh_indicator_find_topvisible_client(E_Zone *zone)
             (!eina_list_data_find(e_comp->launchscrns, ec)))
           continue;
 
-        /* if ec is subsurface, skip this */
-        cdata = e_client_cdata_get(ec);
-        if (cdata && cdata->sub.data) continue;
+        if (e_comp_wl_subsurface_check(ec)) continue;
 
         e_client_geometry_get(ec, &ex, &ey, &ew, &eh);
         if (!E_CONTAINS(ex, ey, ew, eh, zone->x, zone->y, zone->w, zone->h))