subsurface: add a dummy interface for handling a subsurface with invalid parent. 23/241223/2
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 13 May 2020 08:52:41 +0000 (17:52 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Sun, 23 Aug 2020 23:36:41 +0000 (23:36 +0000)
now that it uses dummy implementation for wl_subsurface_interface for
invalid parent, there is no need to check if user data of wl_resource
is valid in case of normal parent.

Change-Id: Ib7551574147b8d4358c1fdabf2587e1f6d94a4eb

src/bin/e_comp_wl_subsurface.c

index 867f336b5be7504b2f96f94b945bc54f269b2ec3..a71e73f34dc8ab982f6cea3e776ac6ee787bc36e 100644 (file)
@@ -6,6 +6,7 @@ static struct wl_global *global = NULL;
 static Eina_List *hooks = NULL;
 
 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_client *client, uint32_t id);
 
 static void
 _e_comp_wl_subsurface_restack_bg_rectangle(E_Client *ec)
@@ -514,8 +515,8 @@ _e_comp_wl_subsurface_cb_position_set(struct wl_client *client EINA_UNUSED, stru
 
    DBG("Subsurface Cb Position Set: %d", wl_resource_get_id(resource));
 
-   /* try to get the client from resource data */
-   if (!(ec = wl_resource_get_user_data(resource))) return;
+   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;
 
@@ -532,8 +533,8 @@ _e_comp_wl_subsurface_cb_place_above(struct wl_client *client EINA_UNUSED, struc
 
    DBG("Subsurface Cb Place Above: %d", wl_resource_get_id(resource));
 
-   /* try to get the client from resource data */
-   if (!(ec = wl_resource_get_user_data(resource))) return;
+   ec = wl_resource_get_user_data(resource);
+
    if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return;
    if (!ec->comp_data->sub.data) return;
 
@@ -562,8 +563,8 @@ _e_comp_wl_subsurface_cb_place_below(struct wl_client *client EINA_UNUSED, struc
 
    DBG("Subsurface Cb Place Below: %d", wl_resource_get_id(resource));
 
-   /* try to get the client from resource data */
-   if (!(ec = wl_resource_get_user_data(resource))) return;
+   ec = wl_resource_get_user_data(resource);
+
    if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return;
    if (!ec->comp_data->sub.data) return;
 
@@ -592,8 +593,8 @@ _e_comp_wl_subsurface_cb_sync_set(struct wl_client *client EINA_UNUSED, struct w
 
    DBG("Subsurface Cb Sync Set: %d", wl_resource_get_id(resource));
 
-   /* try to get the client from resource data */
-   if (!(ec = wl_resource_get_user_data(resource))) return;
+   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;
 
@@ -608,8 +609,8 @@ _e_comp_wl_subsurface_cb_desync_set(struct wl_client *client EINA_UNUSED, struct
 
    DBG("Subsurface Cb Desync Set: %d", wl_resource_get_id(resource));
 
-   /* try to get the client from resource data */
-   if (!(ec = wl_resource_get_user_data(resource))) return;
+   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;
 
@@ -881,23 +882,8 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_
 
    if (!epc || e_object_is_del(E_OBJECT(epc)))
      {
-        if (ec->comp_data->sub.watcher)
-          tizen_subsurface_watcher_send_message(ec->comp_data->sub.watcher, TIZEN_SUBSURFACE_WATCHER_MSG_PARENT_ID_INVALID);
-
-        /* We have to create a subsurface resource here even though it's error case
-         * because server will send the fatal error when a client destroy a subsurface object.
-         * Otherwise, server will kill a client by the fatal error.
-         */
-        if (!(res = wl_resource_create(client, &wl_subsurface_interface, 1, id)))
-          {
-             ERR("Failed to create subsurface resource");
-             wl_resource_post_no_memory(surface_resource);
-             return EINA_FALSE;
-          }
-
-        wl_resource_set_implementation(res, &_e_subsurface_interface, NULL, NULL);
-
         ERR("tizen_policy failed: invalid parent");
+        _e_comp_wl_subsurface_invalid_parent_handle(ec, client, id);
         return EINA_FALSE;
      }
 
@@ -1210,3 +1196,66 @@ e_comp_wl_subsurface_check_below_bg_rectangle(E_Client *ec)
 
    _e_comp_wl_subsurface_check_below_bg_rectangle(ec);
 }
+
+static void
+_e_comp_wl_subsurface_cb_dummy_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
+{
+   wl_resource_destroy(resource);
+}
+
+static void
+_e_comp_wl_subsurface_cb_dummy_position_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, int32_t x EINA_UNUSED, int32_t y EINA_UNUSED)
+{
+}
+
+static void
+_e_comp_wl_subsurface_cb_dummy_place_above(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, struct wl_resource *sibling_resource EINA_UNUSED)
+{
+}
+
+static void
+_e_comp_wl_subsurface_cb_dummy_place_below(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, struct wl_resource *sibling_resource EINA_UNUSED)
+{
+}
+
+static void
+_e_comp_wl_subsurface_cb_dummy_sync_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED)
+{
+}
+
+static void
+_e_comp_wl_subsurface_cb_dummy_desync_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED)
+{
+}
+
+static const struct wl_subsurface_interface _e_subsurface_dummy_interface =
+{
+   _e_comp_wl_subsurface_cb_dummy_destroy,
+   _e_comp_wl_subsurface_cb_dummy_position_set,
+   _e_comp_wl_subsurface_cb_dummy_place_above,
+   _e_comp_wl_subsurface_cb_dummy_place_below,
+   _e_comp_wl_subsurface_cb_dummy_sync_set,
+   _e_comp_wl_subsurface_cb_dummy_desync_set,
+};
+
+static void
+_e_comp_wl_subsurface_invalid_parent_handle(E_Client *ec, struct wl_client *client, uint32_t id)
+{
+   struct wl_resource *res;
+
+   if (ec->comp_data->sub.watcher)
+     tizen_subsurface_watcher_send_message(ec->comp_data->sub.watcher, TIZEN_SUBSURFACE_WATCHER_MSG_PARENT_ID_INVALID);
+
+   /* We have to create a subsurface resource here even though it's error case
+    * because server will send the fatal error when a client destroy a subsurface object.
+    * Otherwise, server will kill a client by the fatal error.
+    */
+   if (!(res = wl_resource_create(client, &wl_subsurface_interface, 1, id)))
+     {
+        ERR("Failed to create subsurface resource");
+        wl_client_post_no_memory(client);
+        return;
+     }
+
+   wl_resource_set_implementation(res, &_e_subsurface_dummy_interface, NULL, NULL);
+}