From adedc7c0160f3a7d7fcc6ff7b62ae8a22e826973 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Wed, 28 Apr 2021 17:19:22 +0900 Subject: [PATCH] policy/shell: refactoring parent_set/transient_for code we changed code to use e_policy_stack_parent_set and e_policy_stack_transient_for_set while handling requests for parent_set and transient_for_set Change-Id: I7f010cf9e025f51e81b0e76b48199c876a2f2a0b --- src/bin/e_comp_wl_shell.c | 66 ++++------------------------------ src/bin/e_policy.h | 1 + src/bin/e_policy_stack.c | 10 ++++++ src/bin/e_policy_wl.c | 91 ++++++++--------------------------------------- 4 files changed, 31 insertions(+), 137 deletions(-) diff --git a/src/bin/e_comp_wl_shell.c b/src/bin/e_comp_wl_shell.c index b8f395f..18a98d1 100644 --- a/src/bin/e_comp_wl_shell.c +++ b/src/bin/e_comp_wl_shell.c @@ -158,71 +158,17 @@ e_shell_e_client_pong(E_Client *ec) EINTERN void e_shell_e_client_parent_set(E_Client *ec, struct wl_resource *parent_resource) { - E_Client *pc, *child; - Ecore_Window pwin = 0; - Eina_List *dup_transients = NULL; + E_Client *parent = NULL; EINA_SAFETY_ON_NULL_RETURN(ec); - ELOGF("SHELL", "Parent Set. parent_ec:%p, child_ec:%p, prev_parent_ec: %p", - ec, parent_resource? wl_resource_get_user_data(parent_resource) : NULL, ec, ec->parent); - - if (!parent_resource) - { - ec->icccm.fetch.transient_for = EINA_FALSE; - ec->icccm.transient_for = 0; - if (ec->parent) - { - ec->parent->transients = - eina_list_remove(ec->parent->transients, ec); - if (ec->parent->modal == ec) ec->parent->modal = NULL; - ec->parent = NULL; - } - return; - } - - pc = wl_resource_get_user_data(parent_resource); - if (!pc) - { - ERR("Could not get parent resource client"); - return; - } - - pwin = e_pixmap_window_get(pc->pixmap); - - e_pixmap_parent_window_set(ec->pixmap, pwin); - - /* If we already have a parent, remove it */ - if (ec->parent) - { - if (pc != ec->parent) - { - ec->parent->transients = - eina_list_remove(ec->parent->transients, ec); - if (ec->parent->modal == ec) ec->parent->modal = NULL; - ec->parent = NULL; - } - } - - if ((pc != ec) && - (eina_list_data_find(pc->transients, ec) != ec)) - { - pc->transients = eina_list_append(pc->transients, ec); - ec->parent = pc; - } + if (parent_resource) + parent = wl_resource_get_user_data(parent_resource); - dup_transients = eina_list_clone(pc->transients); - EINA_LIST_FREE(dup_transients, child) - { - if (child->transient_for_always_on_top) - { - pc->transients = eina_list_remove(pc->transients, child); - pc->transients = eina_list_append(pc->transients, child); - } - } + ELOGF("SHELL", "Parent Set. parent_resource:%p, parent_ec:%p, prev_parent_ec:%p", + ec, parent_resource, parent, ec->parent); - ec->icccm.fetch.transient_for = EINA_TRUE; - ec->icccm.transient_for = pwin; + e_policy_stack_parent_set(ec, parent); } EINTERN Eina_Bool diff --git a/src/bin/e_policy.h b/src/bin/e_policy.h index 08210fe..bbbffda 100644 --- a/src/bin/e_policy.h +++ b/src/bin/e_policy.h @@ -261,6 +261,7 @@ EINTERN void e_policy_client_window_opaque_set(E_Client *ec); EINTERN void e_policy_stack_init(void); EINTERN void e_policy_stack_shutdown(void); +E_API void e_policy_stack_parent_set(E_Client *child, E_Client *parent); E_API void e_policy_stack_transient_for_set(E_Client *child, E_Client *parent); EINTERN void e_policy_stack_transient_for_apply(E_Client *ec); EINTERN void e_policy_stack_transient_child_raise(E_Client *ec); diff --git a/src/bin/e_policy_stack.c b/src/bin/e_policy_stack.c index 5cf4ef9..17c8e7c 100644 --- a/src/bin/e_policy_stack.c +++ b/src/bin/e_policy_stack.c @@ -240,6 +240,10 @@ _e_policy_stack_transient_for_set(E_Client *ec, E_Client *parent, Eina_Bool tran Eina_Bool transient_each_other = EINA_FALSE; EINA_SAFETY_ON_NULL_RETURN(ec); + + ELOGF("POL", "Set Transient_stack. parent(win:%x, ec:%p), is_transient_for:%d", + ec, e_client_util_win_get(parent), parent, transient); + if (!parent) { ec->icccm.transient_for = 0; @@ -310,6 +314,12 @@ _e_policy_stack_transient_for_set(E_Client *ec, E_Client *parent, Eina_Bool tran } void +e_policy_stack_parent_set(E_Client *ec, E_Client *parent) +{ + _e_policy_stack_transient_for_set(ec, parent, EINA_FALSE); +} + +void e_policy_stack_transient_for_set(E_Client *ec, E_Client *parent) { _e_policy_stack_transient_for_set(ec, parent, EINA_TRUE); diff --git a/src/bin/e_policy_wl.c b/src/bin/e_policy_wl.c index 6ddcd66..08cadfe 100644 --- a/src/bin/e_policy_wl.c +++ b/src/bin/e_policy_wl.c @@ -1958,61 +1958,29 @@ e_policy_wl_notification_level_fetch(E_Client *ec) // transient for // -------------------------------------------------------- static void -_e_policy_wl_parent_surf_set(E_Client *ec, struct wl_resource *parent_surf) -{ - E_Client *pc = NULL; - - if (parent_surf) - { - if (!(pc = wl_resource_get_user_data(parent_surf))) - { - ERR("Could not get parent res e_client"); - return; - } - } - - e_policy_stack_transient_for_set(ec, pc); -} - -static void _tzpol_iface_cb_transient_for_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, uint32_t child_id, uint32_t parent_id) { - E_Client *ec, *pc; - E_Comp_Wl_Client_Data *cdata, *pc_cdata; - struct wl_resource *parent_surf; + E_Client *ec, *parent_ec; + E_Comp_Wl_Client_Data *cdata, *p_cdata; ELOGF("TZPOL", - "TF_SET |res_tzpol:%8p|parent:%d|child:%d", + "TF_SET |res_tzpol:%8p|parent_id:%8d |child_id:8%d", NULL, res_tzpol, parent_id, child_id); ec = e_pixmap_find_client_by_res_id(child_id); EINA_SAFETY_ON_NULL_RETURN(ec); cdata = e_client_cdata_get(ec); - pc = e_pixmap_find_client_by_res_id(parent_id); - EINA_SAFETY_ON_NULL_RETURN(pc); - pc_cdata = e_client_cdata_get(pc); - EINA_SAFETY_ON_NULL_RETURN(pc_cdata); - - parent_surf = pc_cdata->surface; - - _e_policy_wl_parent_surf_set(ec, parent_surf); + parent_ec = e_pixmap_find_client_by_res_id(parent_id); + EINA_SAFETY_ON_NULL_RETURN(parent_ec); + p_cdata = e_client_cdata_get(parent_ec); ELOGF("TZPOL", - " |win:0x%08zx|parent|s:%8p", - pc, - e_client_util_win_get(pc), - parent_surf); - - ELOGF("TZPOL", - " |win:0x%08zx|child |s:%8p", - ec, - e_client_util_win_get(ec), - (cdata ? cdata->surface : NULL)); + " |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p", + NULL, res_tzpol, (p_cdata ? p_cdata->surface : NULL), (cdata ? cdata->surface : NULL)); + e_policy_stack_transient_for_set(ec, parent_ec); tizen_policy_send_transient_for_done(res_tzpol, child_id); - - EC_CHANGED(ec); } static void @@ -2027,11 +1995,8 @@ _tzpol_iface_cb_transient_for_unset(struct wl_client *client EINA_UNUSED, struct ec = e_pixmap_find_client_by_res_id(child_id); EINA_SAFETY_ON_NULL_RETURN(ec); - _e_policy_wl_parent_surf_set(ec, NULL); - + e_policy_stack_transient_for_set(ec, NULL); tizen_policy_send_transient_for_done(res_tzpol, child_id); - - EC_CHANGED(ec); } // -------------------------------------------------------- @@ -3200,45 +3165,17 @@ _tzpol_iface_cb_subsurf_watcher_get(struct wl_client *client, struct wl_resource static void _tzpol_iface_cb_parent_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *child, struct wl_resource *parent) { - E_Client *ec, *pc; - E_Comp_Wl_Client_Data *cdata, *pc_cdata; - struct wl_resource *parent_surf; + E_Client *ec, *parent_ec; ELOGF("TZPOL", - "PARENT_SET |res_tzpol:%8p|parent:%8p|child:%8p", + "PARENT_SET |res_tzpol:%8p|parent_surf:%8p|child_surf:%8p", NULL, res_tzpol, parent, child); ec = wl_resource_get_user_data(child); EINA_SAFETY_ON_NULL_RETURN(ec); - pc = wl_resource_get_user_data(parent); - if (!pc) - { - _e_policy_wl_parent_surf_set(ec, NULL); - } - else - { - pc_cdata = e_client_cdata_get(pc); - EINA_SAFETY_ON_NULL_RETURN(pc_cdata); - - parent_surf = pc_cdata->surface; - _e_policy_wl_parent_surf_set(ec, parent_surf); - - ELOGF("TZPOL", - " |win:0x%08zx|parent|s:%8p", - pc, - e_client_util_win_get(pc), - parent_surf); - - cdata = e_client_cdata_get(ec); - ELOGF("TZPOL", - " |win:0x%08zx|child |s:%8p", - ec, - e_client_util_win_get(ec), - (cdata ? cdata->surface : NULL)); - } - - EC_CHANGED(ec); + parent_ec = wl_resource_get_user_data(parent); + e_policy_stack_parent_set(ec, parent_ec); } static void -- 2.7.4