desktop_shell: Add reference to E_Client 20/323420/1
authorSeunghun Lee <shiin.lee@samsung.com>
Fri, 25 Apr 2025 05:20:05 +0000 (14:20 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 28 Apr 2025 07:44:54 +0000 (16:44 +0900)
To avoid repeated calls to e_surface_ec_get, this patch adds a reference
to E_Client to E_Desktop_Surface.

Change-Id: Ib7c659f93e050948e4e6a16bc54c0339a7dcb8fb

src/bin/server/e_desktop_shell.c
src/bin/server/e_desktop_shell_private.h

index 38ca104f3090dbb2ea627985d60b22daf7fd988b..0dab1c9352cc2f4e35c05bb77ae47ccac0d682b2 100644 (file)
@@ -152,6 +152,10 @@ static void
 _surface_init(E_Desktop_Surface *surface, E_Surface *e_surface, E_Desktop_Surface_Interface *iface)
 {
    surface->iface = iface;
+
+   surface->ec = e_surface_ec_get(e_surface);
+   assert(surface->ec);
+
    surface->surface = e_surface;
    surface->surface_destroy.notify = _surface_cb_surface_destroy;
    e_surface_destroy_listener_add(e_surface, &surface->surface_destroy);
@@ -163,7 +167,7 @@ _surface_finish(E_Desktop_Surface *surface)
    if (!surface->surface)
      return;
 
-   e_shell_e_client_destroy(e_surface_ec_get(surface->surface));
+   e_shell_e_client_destroy(surface->ec);
    wl_list_remove(&surface->surface_destroy.link);
    surface->iface = NULL;
    surface->surface = NULL;
@@ -206,7 +210,7 @@ e_desktop_surface_configure(E_Desktop_Surface *surface, int32_t x, int32_t y, in
    if (surface->iface->configure)
      surface->iface->configure(surface->iface, x, y, width, height);
    else
-     e_client_util_move_resize_without_frame(e_surface_ec_get(surface->surface), x, y, width, height);
+     e_client_util_move_resize_without_frame(surface->ec, x, y, width, height);
 }
 
 EINTERN void
@@ -218,7 +222,7 @@ e_desktop_surface_map(E_Desktop_Surface *surface)
    if (surface->iface->map)
      surface->iface->map(surface->iface);
    else
-     e_shell_e_client_map(e_surface_ec_get(surface->surface));
+     e_shell_e_client_map(surface->ec);
 }
 
 EINTERN void
@@ -230,16 +234,14 @@ e_desktop_surface_unmap(E_Desktop_Surface *surface)
    if (surface->iface->unmap)
      surface->iface->unmap(surface->iface);
    else
-     e_shell_e_client_unmap(e_surface_ec_get(surface->surface));
+     e_shell_e_client_unmap(surface->ec);
 }
 
 static void
 _toplevel_init(E_Desktop_Toplevel *toplevel, struct wl_resource *shell_surface_resource)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   e_shell_e_client_shsurface_assign(ec, shell_surface_resource, NULL);
-   e_shell_e_client_toplevel_set(ec);
+   e_shell_e_client_shsurface_assign(toplevel->surface.ec, shell_surface_resource, NULL);
+   e_shell_e_client_toplevel_set(toplevel->surface.ec);
 }
 
 EINTERN void
@@ -270,52 +272,43 @@ e_desktop_toplevel_try_from_surface(E_Surface *e_surface)
 EINTERN void
 e_desktop_toplevel_title_set(E_Desktop_Toplevel *toplevel, const char *title)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   e_shell_e_client_name_title_set(ec, title, title);
+   e_shell_e_client_name_title_set(toplevel->surface.ec, title, title);
 }
 
 EINTERN void
 e_desktop_toplevel_app_id_set(E_Desktop_Toplevel *toplevel, const char *app_id)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   e_shell_e_client_app_id_set(ec, app_id);
+   e_shell_e_client_app_id_set(toplevel->surface.ec, app_id);
 }
 
 EINTERN void
 e_desktop_toplevel_parent_set(E_Desktop_Toplevel *toplevel, E_Desktop_Toplevel *parent)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
    E_Client *epc = NULL;
 
    if (parent)
-     epc = e_surface_ec_get(parent->surface.surface);
+     epc = parent->surface.ec;
 
-   e_client_parent_set(ec, epc);
-   EC_CHANGED(ec);
+   e_client_parent_set(toplevel->surface.ec, epc);
+   EC_CHANGED(toplevel->surface.ec);
 }
 
 EINTERN void
 e_desktop_toplevel_interactive_move_begin(E_Desktop_Toplevel *toplevel, struct wl_resource *seat_resource)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   e_shell_e_client_interactive_move(ec, seat_resource);
+   e_shell_e_client_interactive_move(toplevel->surface.ec, seat_resource);
 }
 
 EINTERN void
 e_desktop_toplevel_interactive_resize_begin(E_Desktop_Toplevel *toplevel, struct wl_resource *toplevel_resource, struct wl_resource *seat_resource, int32_t edges)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   e_shell_e_client_interactive_resize(ec, toplevel_resource, seat_resource, edges);
+   e_shell_e_client_interactive_resize(toplevel->surface.ec, toplevel_resource, seat_resource, edges);
 }
 
 EINTERN void
 e_desktop_toplevel_fullscreen_request(E_Desktop_Toplevel *toplevel)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
+   E_Client *ec = toplevel->surface.ec;
 
    if (ec->lock_user_fullscreen)
      return;
@@ -326,7 +319,7 @@ e_desktop_toplevel_fullscreen_request(E_Desktop_Toplevel *toplevel)
 EINTERN void
 e_desktop_toplevel_unfullscreen_request(E_Desktop_Toplevel *toplevel)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
+   E_Client *ec = toplevel->surface.ec;
 
    if (ec->lock_user_fullscreen)
      return;
@@ -337,7 +330,7 @@ e_desktop_toplevel_unfullscreen_request(E_Desktop_Toplevel *toplevel)
 EINTERN void
 e_desktop_toplevel_maximize_request(E_Desktop_Toplevel *toplevel)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
+   E_Client *ec = toplevel->surface.ec;
    E_Maximize max = ec->maximize_type | E_MAXIMIZE_BOTH;
 
    if (ec->lock_user_maximize)
@@ -354,7 +347,7 @@ e_desktop_toplevel_maximize_request(E_Desktop_Toplevel *toplevel)
 EINTERN void
 e_desktop_toplevel_unmaximize_request(E_Desktop_Toplevel *toplevel)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
+   E_Client *ec = toplevel->surface.ec;
 
    e_client_layout_apply(ec, EINA_FALSE);
 
@@ -366,7 +359,7 @@ e_desktop_toplevel_unmaximize_request(E_Desktop_Toplevel *toplevel)
 EINTERN void
 e_desktop_toplevel_minimize_request(E_Desktop_Toplevel *toplevel)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
+   E_Client *ec = toplevel->surface.ec;
 
    if (ec->lock_client_iconify)
      return;
@@ -377,15 +370,13 @@ e_desktop_toplevel_minimize_request(E_Desktop_Toplevel *toplevel)
 EINTERN void
 e_desktop_toplevel_window_geometry_set(E_Desktop_Toplevel *toplevel, int x, int y, int width, int height)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   EINA_RECTANGLE_SET(&ec->comp_data->shell.window, x, y, width, height);
+   EINA_RECTANGLE_SET(&toplevel->surface.ec->comp_data->shell.window, x, y, width, height);
 }
 
 EINTERN void
 e_desktop_toplevel_min_size_set(E_Desktop_Toplevel *toplevel, int width, int height)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
+   E_Client *ec = toplevel->surface.ec;
 
    if (ec->lock_client_size)
      return;
@@ -397,7 +388,7 @@ e_desktop_toplevel_min_size_set(E_Desktop_Toplevel *toplevel, int width, int hei
 EINTERN void
 e_desktop_toplevel_max_size_set(E_Desktop_Toplevel *toplevel, int width, int height)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
+   E_Client *ec = toplevel->surface.ec;
 
    if (ec->lock_client_size)
      return;
@@ -409,46 +400,36 @@ e_desktop_toplevel_max_size_set(E_Desktop_Toplevel *toplevel, int width, int hei
 EINTERN bool
 e_desktop_toplevel_is_fullscreen(E_Desktop_Toplevel *toplevel)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   return ec->fullscreen;
+   return toplevel->surface.ec->fullscreen;
 }
 
 EINTERN bool
 e_desktop_toplevel_is_maximized(E_Desktop_Toplevel *toplevel)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   return !!ec->maximized;
+   return !!toplevel->surface.ec->maximized;
 }
 
 EINTERN bool
 e_desktop_toplevel_is_activated(E_Desktop_Toplevel *toplevel)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   return ec == e_client_focused_get();
+   return toplevel->surface.ec == e_client_focused_get();
 }
 
 EINTERN void
 e_desktop_toplevel_fullscreen_size_get(E_Desktop_Toplevel *toplevel, int32_t *width, int32_t *height)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   e_client_base_output_resolution_useful_geometry_get(ec, NULL, NULL, width, height);
+   e_client_base_output_resolution_useful_geometry_get(toplevel->surface.ec, NULL, NULL, width, height);
 }
 
 EINTERN void
 e_desktop_toplevel_maximized_size_get(E_Desktop_Toplevel *toplevel, int32_t *width, int32_t *height)
 {
-   E_Client *ec = e_surface_ec_get(toplevel->surface.surface);
-
-   e_client_maximized_geometry_get(ec, NULL, NULL, width, height);
+   e_client_maximized_geometry_get(toplevel->surface.ec, NULL, NULL, width, height);
 }
 
 EINTERN E_Client *
 e_desktop_toplevel_ec_get(E_Desktop_Toplevel *toplevel)
 {
-   return e_surface_ec_get(toplevel->surface.surface);
+   return toplevel->surface.ec;
 }
 
index b3b0ab233d81caa4ddcb0158c9da9f9f6ccd4ecb..52880fb2c2496e2b37a3ed0524bd8492ec5eb6f3 100644 (file)
@@ -17,6 +17,7 @@ struct _E_Desktop_Surface
 {
    E_Surface *surface;
    E_Desktop_Surface_Interface *iface;
+   E_Client *ec;
 
    struct wl_listener surface_destroy;
 };