From 14552e916007685278b2ae9aa7e9d61fda1b3a8e Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Tue, 5 Dec 2023 11:01:00 +0900 Subject: [PATCH] e_client: Add e_client_shell APIs and refactor This commit introduces a new set of APIs under the `e_client_shell` namespace, which are designed to provide an easier and more intuitive way to interact with the shell component in the e_client. These APIs replace the previous approach of directly accessing `ec->comp_data->shell`, resulting in improved code organization and maintainability. Change-Id: Iec4c951b8e0acc51cbccc310fcc8edf40232fd95 --- src/bin/e_client.c | 65 +++++++++++++++++++++++++++++++++++++++ src/bin/e_client_intern.h | 6 ++++ src/bin/e_comp_wl.c | 38 ++++++++--------------- src/bin/e_comp_wl_rsm.c | 7 ++--- src/bin/e_comp_wl_shell.c | 9 ++---- src/bin/e_eom.c | 3 +- src/bin/e_output.c | 8 ++--- src/bin/e_policy_wl.c | 26 +++++----------- 8 files changed, 100 insertions(+), 62 deletions(-) diff --git a/src/bin/e_client.c b/src/bin/e_client.c index 87a27473b1..17a21737a5 100644 --- a/src/bin/e_client.c +++ b/src/bin/e_client.c @@ -7090,3 +7090,68 @@ e_client_destroy_listener_get(E_Client *ec, wl_notify_func_t notify) API_ENTRY_VAL(NULL); return wl_signal_get(&priv->events.destroy, notify); } + +EINTERN void +e_client_shell_configure_send(E_Client *ec, uint32_t edges, int32_t width, int32_t height) +{ + EINA_SAFETY_ON_NULL_RETURN(ec); + EINA_SAFETY_ON_NULL_RETURN(ec->comp_data); + + if ((!ec->comp_data->shell.surface) || + (!ec->comp_data->shell.configure_send)) + return; + + ec->comp_data->shell.configure_send(ec->comp_data->shell.surface, edges, width, height); +} + +EINTERN void +e_client_shell_configure(E_Client *ec, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height) +{ + EINA_SAFETY_ON_NULL_RETURN(ec); + EINA_SAFETY_ON_NULL_RETURN(ec->comp_data); + + if ((!ec->comp_data->shell.surface) || + (!ec->comp_data->shell.configure)) + return; + + ec->comp_data->shell.configure(ec->comp_data->shell.surface, x, y, width, height); +} + +EINTERN void +e_client_shell_ping(E_Client *ec) +{ + EINA_SAFETY_ON_NULL_RETURN(ec); + EINA_SAFETY_ON_NULL_RETURN(ec->comp_data); + + if ((!ec->comp_data->shell.surface) || + (!ec->comp_data->shell.ping)) + return; + + ec->comp_data->shell.ping(ec->comp_data->shell.surface); +} + +EINTERN void +e_client_shell_map(E_Client *ec) +{ + EINA_SAFETY_ON_NULL_RETURN(ec); + EINA_SAFETY_ON_NULL_RETURN(ec->comp_data); + + if ((!ec->comp_data->shell.surface) || + (!ec->comp_data->shell.map)) + return; + + ec->comp_data->shell.map(ec->comp_data->shell.surface); +} + +EINTERN void +e_client_shell_unmap(E_Client *ec) +{ + EINA_SAFETY_ON_NULL_RETURN(ec); + EINA_SAFETY_ON_NULL_RETURN(ec->comp_data); + + if ((!ec->comp_data->shell.surface) || + (!ec->comp_data->shell.unmap)) + return; + + ec->comp_data->shell.unmap(ec->comp_data->shell.surface); +} diff --git a/src/bin/e_client_intern.h b/src/bin/e_client_intern.h index 36c717a7f8..c527552b25 100644 --- a/src/bin/e_client_intern.h +++ b/src/bin/e_client_intern.h @@ -57,4 +57,10 @@ EINTERN void e_client_unstick_listener_add(E_Client *ec, struct wl_listener *lis EINTERN struct wl_listener *e_client_destroy_listener_get(E_Client *ec, wl_notify_func_t notify); +void e_client_shell_configure_send(E_Client *ec, uint32_t edges, int32_t width, int32_t height); +void e_client_shell_configure(E_Client *ec, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height); +void e_client_shell_ping(E_Client *ec); +void e_client_shell_map(E_Client *ec); +void e_client_shell_unmap(E_Client *ec); + #endif diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index 7b2e575aaa..8144ac22b4 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -2,6 +2,7 @@ #include "e_foreign.h" #include "e_wtz_shell.h" #include "e_comp_wl_private.h" +#include "e_client_intern.h" #include #include @@ -220,9 +221,7 @@ _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size) w = h = -1; } - ec->comp_data->shell.configure_send(ec->comp_data->shell.surface, - edges * e_comp_wl->resize.edges, - w, h); + e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h); } static void @@ -2174,9 +2173,7 @@ _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event h = E_CLAMP(h, 1, h); e_client_resize_limit(ec, &w, &h); - ec->comp_data->shell.configure_send(ec->comp_data->shell.surface, - e_comp_wl->resize.edges, - w, h); + e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h); } else if ((!ec->fullscreen) && (!ec->maximized) && (!ec->comp_data->maximize_pre)) @@ -2210,11 +2207,9 @@ _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void if (e_object_is_del(E_OBJECT(ec))) return; - if (ec->comp_data->shell.configure_send) - { - e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h); - ec->comp_data->shell.configure_send(ec->comp_data->shell.surface, 0, w, h); - } + e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h); + e_client_shell_configure_send(ec, 0, w, h); + ec->comp_data->maximize_pre = 0; } @@ -2315,11 +2310,8 @@ _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EI E_Client *ec; if (!(ec = data)) return; - if (!(ec->comp_data)) return; - if (!(ec->comp_data->shell.ping)) return; - if (!(ec->comp_data->shell.surface)) return; - ec->comp_data->shell.ping(ec->comp_data->shell.surface); + e_client_shell_ping(ec); } static void @@ -2986,7 +2978,7 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state) } ec->show_pending.running = EINA_FALSE; } - cdata->shell.unmap(cdata->shell.surface); + e_client_shell_unmap(ec); } else if ((ec->internal) || (e_comp_wl_subsurface_check(ec)) || @@ -3016,7 +3008,7 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state) (!ec->ignored)) { ELOGF("COMP", "Try to map. Call shell.map.", ec); - cdata->shell.map(cdata->shell.surface); + e_client_shell_map(ec); } else if ((ec->internal) || (e_comp_wl_subsurface_can_show(ec)) || @@ -4090,7 +4082,7 @@ e_comp_wl_surface_commit(E_Client *ec) if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap)) { ELOGF("COMP", "Try to unmap2. Call shell.unmap.", ec); - ec->comp_data->shell.unmap(ec->comp_data->shell.surface); + e_client_shell_unmap(ec); } else if (ec->internal || e_comp_wl_subsurface_check(ec) || (ec == e_comp_wl->drag_client)) @@ -4114,7 +4106,7 @@ e_comp_wl_surface_commit(E_Client *ec) (!ec->ignored)) { ELOGF("COMP", "Try to map2. Call shell.map.", ec); - ec->comp_data->shell.map(ec->comp_data->shell.surface); + e_client_shell_map(ec); } else if (ec->internal || e_comp_wl_subsurface_can_show(ec) || (ec == e_comp_wl->drag_client)) @@ -5521,13 +5513,7 @@ e_comp_wl_commit_sync_configure(E_Client *ec) // cw interceptor(move,resize) won't work if wait_commit is TRUE ec->surface_sync.wait_commit = EINA_FALSE; - if ((ec->comp_data->shell.surface) && - (ec->comp_data->shell.configure)) - { - ec->comp_data->shell.configure(ec->comp_data->shell.surface, - ec->x, ec->y, - ec->w, ec->h); - } + e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h); // rollback wait_commit if there are pending requests remained if (eina_list_count(ec->surface_sync.pending_geometry)) diff --git a/src/bin/e_comp_wl_rsm.c b/src/bin/e_comp_wl_rsm.c index 1ae81b8d5d..da5d28d705 100644 --- a/src/bin/e_comp_wl_rsm.c +++ b/src/bin/e_comp_wl_rsm.c @@ -1,6 +1,7 @@ #include "e.h" #include "e_policy_wl.h" #include "e_device.h" +#include "e_client_intern.h" #include #include #include @@ -360,7 +361,7 @@ _remote_provider_offscreen_set(E_Comp_Wl_Remote_Provider* provider, Eina_Bool se if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap)) { ELOGF("COMP", "Call shell.unmap by rsm", ec); - ec->comp_data->shell.unmap(ec->comp_data->shell.surface); + e_client_shell_unmap(ec); } else { @@ -3015,9 +3016,7 @@ _e_comp_wl_remote_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *st ec->client.h = state->bh; e_client_size_set(ec, state->bw, state->bh); - if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.configure)) - ec->comp_data->shell.configure(ec->comp_data->shell.surface, - x, y, ec->w, ec->h); + e_client_shell_configure(ec, x, y, ec->w, ec->h); } sx = state->sx; diff --git a/src/bin/e_comp_wl_shell.c b/src/bin/e_comp_wl_shell.c index cc33d04169..4cccbc53e4 100644 --- a/src/bin/e_comp_wl_shell.c +++ b/src/bin/e_comp_wl_shell.c @@ -1,4 +1,5 @@ #include "e.h" +#include "e_client_intern.h" #include #include #include @@ -404,12 +405,8 @@ e_shell_e_client_destroy(E_Client *ec) { if (ec->comp_data->mapped) { - if ((ec->comp_data->shell.surface) && - (ec->comp_data->shell.unmap)) - { - ELOGF("SHELL", "Call shell.unmap by destroy surface", ec); - ec->comp_data->shell.unmap(ec->comp_data->shell.surface); - } + ELOGF("SHELL", "Call shell.unmap by destroy surface", ec); + e_client_shell_unmap(ec); } e_policy_client_unmap(ec); } diff --git a/src/bin/e_eom.c b/src/bin/e_eom.c index 5171cce8c9..aef9eca31e 100644 --- a/src/bin/e_eom.c +++ b/src/bin/e_eom.c @@ -3,6 +3,7 @@ #endif #include "e.h" +#include "e_client_intern.h" #include #include #include @@ -402,7 +403,7 @@ _e_eom_output_send_configure_event(E_EomOutput *eom_output, E_Client *ec) /* get the output size */ e_output_size_get(eom_output->output, &w, &h); - cdata->shell.configure_send(cdata->shell.surface, 0, w, h); + e_client_shell_configure_send(ec, 0, w, h); EOMINF("Send Configure Event for Presentation (%d X %d)", ec, eom_output->output, w, h); diff --git a/src/bin/e_output.c b/src/bin/e_output.c index 9c9644d310..82d0fb075f 100644 --- a/src/bin/e_output.c +++ b/src/bin/e_output.c @@ -1,4 +1,5 @@ #include "e.h" +#include "e_client_intern.h" #include #define EOERR(f, output, x...) \ @@ -714,18 +715,13 @@ static void _e_output_client_resize(int w, int h) { E_Client *ec = NULL; - E_Comp_Wl_Client_Data *cdata; E_CLIENT_FOREACH(ec) { if ((ec->visible && !ec->input_only) || (e_client_util_name_get(ec) != NULL && !ec->input_only)) { - cdata = e_client_cdata_get(ec); - if (cdata == NULL) continue; - if (cdata->shell.configure_send == NULL) continue; - - cdata->shell.configure_send(cdata->shell.surface, 0, w ,h); + e_client_shell_configure_send(ec, 0, w, h); } } } diff --git a/src/bin/e_policy_wl.c b/src/bin/e_policy_wl.c index f2025341f1..4ce7ba5d3c 100644 --- a/src/bin/e_policy_wl.c +++ b/src/bin/e_policy_wl.c @@ -15,6 +15,7 @@ #include "e_policy_visibility.h" #include "e_appinfo.h" #include "e_subsurface_watcher.h" +#include "e_client_intern.h" #include #include @@ -3686,14 +3687,7 @@ _tzpol_iface_cb_set_layout(struct wl_client *client EINA_UNUSED, struct wl_resou e_client_frame_geometry_set(ec, x, y, w, h); if (!ec->visible) - { - E_Comp_Wl_Client_Data *cdata; - cdata = e_client_cdata_get(ec); - if (cdata && cdata->shell.configure_send && cdata->shell.surface) - { - cdata->shell.configure_send(cdata->shell.surface, 0, w, h); - } - } + e_client_shell_configure_send(ec, 0, w, h); } // -------------------------------------------------------- @@ -8386,7 +8380,7 @@ e_policy_wl_clipboard_data_selected_send(E_Client *ec) static void _e_policy_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec) { - E_Comp_Wl_Client_Data *cdata; + int w = 0, h = 0; if (EINA_UNLIKELY(!ec)) return; @@ -8397,18 +8391,12 @@ _e_policy_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec) e_client_base_output_resolution_transform_adjust(ec); - cdata = e_client_cdata_get(ec); - if ((cdata->shell.configure_send) && - (cdata->shell.surface)) + if (ec->lock_client_size) { - int w = 0, h = 0; - if (ec->lock_client_size) - { - w = ec->w; - h = ec->h; - } - cdata->shell.configure_send(cdata->shell.surface, 0, w, h); + w = ec->w; + h = ec->h; } + e_client_shell_configure_send(ec, 0, w, h); } static void -- 2.34.1