e_pixmap: Delete win id for surface resource 13/316313/1
authorSeunghun Lee <shiin.lee@samsung.com>
Mon, 12 Aug 2024 07:39:38 +0000 (16:39 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 19 Aug 2024 08:09:01 +0000 (17:09 +0900)
From outside of e_pixmap doesn't know how id is used and managed. So,
deleting window id from outside is not easily understandable. I think
that since e_pixmap knows when surface resource is destroyed it's better
to delete window id by itself for readability.

Change-Id: I0e4d77879953ffe0f49c63f03be7cf4d91a154e9

src/bin/core/e_pixmap.c
src/bin/server/e_comp_wl.c
src/bin/server/e_compositor.c

index e4283fe62214b5457a08d9fe389fa3a6e244ae73..f2e59e2a8e103eff389ede57426a6febb376ecd6 100644 (file)
@@ -45,6 +45,8 @@ struct _E_Pixmap
 
    uint32_t single_pixel;
 
+   struct wl_listener surface_resource_destroy;
+
    struct {
       struct wl_signal buffer_clear;
       struct wl_signal buffer_clear_done;
@@ -145,6 +147,7 @@ _e_pixmap_free(E_Pixmap *cp)
    if (cp->buffer)
      wl_list_remove(&cp->buffer_destroy_listener.link);
 
+   wl_list_remove(&cp->surface_resource_destroy.link);
    free(cp);
 }
 
@@ -229,6 +232,33 @@ e_pixmap_ref(E_Pixmap *cp)
    return cp;
 }
 
+static void
+_e_pixmap_cb_surface_resource_destroy(struct wl_listener *listener, void *data)
+{
+   E_Pixmap *cp = wl_container_of(listener, cp, surface_resource_destroy);
+
+   e_pixmap_win_id_del(cp);
+   wl_list_remove(&cp->surface_resource_destroy.link);
+   wl_list_init(&cp->surface_resource_destroy.link);
+}
+
+static void
+_e_pixmap_id_setup(E_Pixmap *cp, uintptr_t id)
+{
+   cp->win = id;
+   eina_hash_add(pixmaps[cp->type], &id, cp);
+
+   if (cp->type == E_PIXMAP_TYPE_WL)
+     {
+        cp->surface_resource_destroy.notify = _e_pixmap_cb_surface_resource_destroy;
+        wl_resource_add_destroy_listener((struct wl_resource *)id, &cp->surface_resource_destroy);
+     }
+   else
+     {
+        wl_list_init(&cp->surface_resource_destroy.link);
+     }
+}
+
 E_API E_Pixmap *
 e_pixmap_new(E_Pixmap_Type type, ...)
 {
@@ -268,8 +298,7 @@ e_pixmap_new(E_Pixmap_Type type, ...)
         return NULL;
      }
 
-   cp->win = id;
-   eina_hash_add(pixmaps[type], &id, cp);
+   _e_pixmap_id_setup(cp, id);
    uuid_generate(cp->uuid);
 
    if (!res_ids)
index 1e0e9409481aa8b2817d5052ed66be582b81536f..704f26b23eb7007da7539755a7f96a36a43bb0b7 100644 (file)
@@ -3080,7 +3080,6 @@ e_comp_wl_client_surface_finish(E_Client *ec)
    e_comp_wl_client_surface_set(ec, NULL);
 
    ec->comp_data->wl_surface = NULL;
-   e_pixmap_win_id_del(ec->pixmap);
 
    _e_comp_wl_surface_render_stop(ec);
    e_object_del(E_OBJECT(ec));
index a47e36485bc13807cf88e1f247bbd2ab915ca94d..21376898944522b9ec56756117b280ca3cde28fb 100644 (file)
@@ -731,11 +731,6 @@ _e_compositor_cb_new_surface(struct wl_listener *listener, void *data)
         internal = 1;
         ec = e_pixmap_find_client(E_PIXMAP_TYPE_WL, (uintptr_t)wl_resource_get_id(surface_resource));
      }
-   else if ((ep = e_pixmap_find(E_PIXMAP_TYPE_WL, (uintptr_t)surface_resource)))
-     {
-        ERR("There is e_pixmap already, Delete old e_pixmap %p", ep);
-        e_pixmap_win_id_del(ep);
-     }
 
    if (!ec)
      {