policy_wl: Use new_toplevel signal 62/323262/1
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 24 Apr 2025 05:31:21 +0000 (14:31 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Fri, 25 Apr 2025 01:07:09 +0000 (10:07 +0900)
Instead of using E_COMP_WL_HOOK_SHELL_SURFACE_READY hook, this patch
uses new_toplevel signal emitted from E_Desktop_Shell, which improves
readability.

Change-Id: I1bf58a36e27fe40df4b076da7037d377cfc098f7

src/bin/server/e_policy_wl.c

index ca4fbf1608b224aa879fc2aa90bcee757113e09c..19ca45076b91ad1463e6ec11921dc62cce2c090b 100644 (file)
@@ -28,6 +28,7 @@
 #include "e_tizen_display_policy_intern.h"
 #include "e_tizen_ws_shell_manager_intern.h"
 #include "e_policy_stack_intern.h"
+#include "e_desktop_shell_intern.h"
 
 #include <wayland-server.h>
 #include <tizen-extension-server-protocol.h>
@@ -70,6 +71,8 @@ struct _E_Policy_Wl
    Eina_Hash       *tzpols;                  /* list of E_Policy_Wl_Tzpol */
 
    Eina_List       *pending_vis;             /* list of clients that have pending visibility change*/
+
+   struct wl_listener new_toplevel;
 };
 
 static E_Policy_Wl *g_tizen_policy_wl = NULL;
@@ -2808,13 +2811,12 @@ _e_policy_wl_cb_hook_intercept_show_helper(void *data, E_Client *ec)
 }
 
 static void
-_e_policy_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec)
+_e_policy_wl_cb_new_toplevel(struct wl_listener *listener, void *data)
 {
+   E_Desktop_Toplevel *toplevel = data;
+   E_Client *ec = e_desktop_toplevel_ec_get(toplevel);
    int w = 0, h = 0;
 
-   if (EINA_UNLIKELY(!ec))
-     return;
-
    e_client_base_output_resolution_update(ec);
 
    e_policy_client_maximize(ec);
@@ -3006,6 +3008,8 @@ e_policy_wl_aux_hint_init(void)
 EINTERN E_Policy_Wl *
 e_policy_wl_init(struct wl_display *display)
 {
+   E_Desktop_Shell *desktop_shell;
+
    EINA_SAFETY_ON_NULL_RETURN_VAL(display, NULL);
 
    if (g_tizen_policy_wl) return g_tizen_policy_wl;
@@ -3032,9 +3036,12 @@ e_policy_wl_init(struct wl_display *display)
 
    E_COMP_OBJECT_INTERCEPT_HOOK_APPEND(hooks_co, E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER, _e_policy_wl_cb_hook_intercept_show_helper, NULL);
 
-   E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_SHELL_SURFACE_READY, _e_policy_wl_cb_hook_shell_surface_ready, NULL);
    E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE, _e_policy_wl_cb_hook_alpha_change, NULL);
 
+   desktop_shell = e_server_feature_handle_get(E_SERVER_FEATURE_DESKTOP_SHELL);
+   g_tizen_policy_wl->new_toplevel.notify = _e_policy_wl_cb_new_toplevel;
+   e_desktop_shell_new_toplevel_listener_add(desktop_shell, &g_tizen_policy_wl->new_toplevel);
+
    e_service_softkey_client_remove_handler_add();
 
    return g_tizen_policy_wl;
@@ -3057,6 +3064,7 @@ e_policy_wl_shutdown(void)
 
    E_FREE_FUNC(g_tizen_policy_wl->tzpols, eina_hash_free);
 
+   wl_list_remove(&g_tizen_policy_wl->new_toplevel.link);
    E_FREE(g_tizen_policy_wl);
 }