From 28e42a12c42fb6ee72ed3b27c62a2fea833f290f Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 24 Apr 2025 17:07:54 +0900 Subject: [PATCH] e_comp_wl_shell: Emit E_COMP_WL_HOOK_SHELL_SURFACE_READY hook This patch moves the implementation of emitting the E_COMP_WL_HOOK_SHELL_SURFACE_READY hook from e_comp_wl to e_comp_wl_shell. The hook is emitted when new_toplevel signal is emitted by E_Desktop_Shell. The hook cannot be removed at this time, as it is still used by the e modules. Change-Id: I189210e0902fa8d00d7e480e84567fa69a2f1b91 --- src/bin/server/e_comp_wl.c | 8 ----- src/bin/server/e_comp_wl_intern.h | 2 -- src/bin/server/e_comp_wl_shell.c | 42 ++++++++++++++++++++++++- src/bin/server/e_comp_wl_shell_intern.h | 6 ++++ src/bin/server/e_desktop_shell.c | 12 ++++--- 5 files changed, 55 insertions(+), 15 deletions(-) diff --git a/src/bin/server/e_comp_wl.c b/src/bin/server/e_comp_wl.c index e167355616..5eb963fd07 100644 --- a/src/bin/server/e_comp_wl.c +++ b/src/bin/server/e_comp_wl.c @@ -4788,14 +4788,6 @@ e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch) _e_comp_wl_intercept_hooks_delete++; } -EINTERN void -e_comp_wl_shell_surface_ready(E_Client *ec) -{ - if (!ec) return; - - _e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec); -} - E_API void e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled) { diff --git a/src/bin/server/e_comp_wl_intern.h b/src/bin/server/e_comp_wl_intern.h index d7d94b82ad..37740a9ad2 100644 --- a/src/bin/server/e_comp_wl_intern.h +++ b/src/bin/server/e_comp_wl_intern.h @@ -53,8 +53,6 @@ EINTERN void e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timest EINTERN Eina_Bool e_comp_wl_evas_handle_mouse_button(E_Comp_Wl_Data *comp_wl, E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state); -EINTERN void e_comp_wl_shell_surface_ready(E_Client *ec); - EINTERN void e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my); EINTERN Eina_Bool e_comp_wl_cursor_hide(E_Client *ec); diff --git a/src/bin/server/e_comp_wl_shell.c b/src/bin/server/e_comp_wl_shell.c index aced0cb2f9..27219a6e58 100644 --- a/src/bin/server/e_comp_wl_shell.c +++ b/src/bin/server/e_comp_wl_shell.c @@ -10,10 +10,14 @@ #include "e_config_intern.h" #include "e_view_intern.h" #include "e_view_client_intern.h" -#include "e_desktop_shell_intern.h" #include +struct _E_Comp_Wl_Shell +{ + struct wl_listener new_toplevel; +}; + EINTERN Eina_Bool e_shell_e_client_shell_assignable_check(E_Client *ec) { @@ -514,3 +518,39 @@ e_shell_e_client_unmap(E_Client *ec) } } +static void +_shell_cb_new_toplevel(struct wl_listener *listener, void *data) +{ + E_Desktop_Toplevel *toplevel = data; + + e_comp_wl_shell_surface_ready(e_desktop_toplevel_ec_get(toplevel)); +} + +EINTERN E_Comp_Wl_Shell * +e_comp_wl_shell_create(E_Desktop_Shell *desktop_shell) +{ + E_Comp_Wl_Shell *shell; + + shell = calloc(1, sizeof(*shell)); + if (!shell) + return NULL; + + shell->new_toplevel.notify = _shell_cb_new_toplevel; + e_desktop_shell_new_toplevel_listener_add(desktop_shell, &shell->new_toplevel); + + return shell; +} + +EINTERN void +e_comp_wl_shell_destroy(E_Comp_Wl_Shell *shell) +{ + wl_list_remove(&shell->new_toplevel.link); + free(shell); +} + +EINTERN void +e_comp_wl_shell_surface_ready(E_Client *ec) +{ + e_comp_wl_hook_call(E_COMP_WL_HOOK_SHELL_SURFACE_READY, ec); +} + diff --git a/src/bin/server/e_comp_wl_shell_intern.h b/src/bin/server/e_comp_wl_shell_intern.h index d9672a73c6..ef2b51e8d6 100644 --- a/src/bin/server/e_comp_wl_shell_intern.h +++ b/src/bin/server/e_comp_wl_shell_intern.h @@ -2,9 +2,15 @@ #define E_COMP_WL_SHELL_INTERN_H #include "e_comp_wl.h" +#include "e_desktop_shell_intern.h" +typedef struct _E_Comp_Wl_Shell E_Comp_Wl_Shell; typedef struct _E_Comp_Wl_Shell_Surface_Api E_Shell_Surface_Api; +E_Comp_Wl_Shell *e_comp_wl_shell_create(E_Desktop_Shell *desktop_shell); +void e_comp_wl_shell_destroy(E_Comp_Wl_Shell *shell); +void e_comp_wl_shell_surface_ready(E_Client *ec); + EINTERN Eina_Bool e_shell_e_client_shell_assignable_check(E_Client *ec); EINTERN void e_shell_e_client_shsurface_assign(E_Client *ec, struct wl_resource *shsurface, E_Shell_Surface_Api *api); EINTERN void e_shell_e_client_shsurface_api_set(E_Client *ec, E_Shell_Surface_Api *api); diff --git a/src/bin/server/e_desktop_shell.c b/src/bin/server/e_desktop_shell.c index b1dda86d39..35d58ad3eb 100644 --- a/src/bin/server/e_desktop_shell.c +++ b/src/bin/server/e_desktop_shell.c @@ -16,6 +16,7 @@ struct _E_Desktop_Shell { struct wl_global *wl_shell; struct wl_global *xdg_shell_v5; + E_Comp_Wl_Shell *e_comp_wl_shell; struct wl_listener display_destroy; @@ -33,6 +34,7 @@ _shell_cb_display_destroy(struct wl_listener *listener, void *data) wl_signal_emit(&shell->events.destroy, shell); + e_comp_wl_shell_destroy(shell->e_comp_wl_shell); wl_global_destroy(shell->wl_shell); wl_global_destroy(shell->xdg_shell_v5); wl_list_remove(&shell->display_destroy.link); @@ -48,6 +50,9 @@ e_desktop_shell_create(struct wl_display *display) if (!shell) return NULL; + wl_signal_init(&shell->events.destroy); + wl_signal_init(&shell->events.new_toplevel); + shell->wl_shell = e_desktop_wl_shell_create(display); if (!shell->wl_shell) goto err_wl_shell; @@ -59,8 +64,9 @@ e_desktop_shell_create(struct wl_display *display) if (!e_desktop_xdg_shell_v6_init(display, shell)) goto err_xdg_shell_v6; - wl_signal_init(&shell->events.destroy); - wl_signal_init(&shell->events.new_toplevel); + shell->e_comp_wl_shell = e_comp_wl_shell_create(shell); + if (!shell->e_comp_wl_shell) + goto err_xdg_shell_v6; shell->display_destroy.notify = _shell_cb_display_destroy; wl_display_add_destroy_listener(display, &shell->display_destroy); @@ -80,8 +86,6 @@ err_wl_shell: EINTERN void e_desktop_shell_toplevel_add(E_Desktop_Shell *shell, E_Desktop_Toplevel *toplevel) { - e_comp_wl_shell_surface_ready(e_surface_ec_get(toplevel->surface.surface)); - wl_signal_emit(&shell->events.new_toplevel, toplevel); } -- 2.34.1