From: Junseok, Kim Date: Wed, 24 Apr 2019 05:35:36 +0000 (+0900) Subject: working: add e_policy_wl_hook X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fbase_resolution;p=platform%2Fupstream%2Fenlightenment.git working: add e_policy_wl_hook Change-Id: I441cacd94010c1dcc6705617f2dda87aac4c1e44 --- diff --git a/configure.ac b/configure.ac index 6860c6b4fc..2e88f95d04 100755 --- a/configure.ac +++ b/configure.ac @@ -569,11 +569,6 @@ fi AM_CONDITIONAL([HAVE_WAYLAND_ONLY], [test "x${have_wayland_only}" = "xyes"]) -#aul -PKG_CHECK_MODULES([AUL], [aul]) -#pkgmgr-info -PKG_CHECK_MODULES([PKGMGR_INFO], [pkgmgr-info]) - PKG_CHECK_MODULES(E, [$e_requires]) requirements_e="\ evas >= ${efl_version} \ diff --git a/packaging/enlightenment.spec b/packaging/enlightenment.spec index 33dfce1f03..565ece77fa 100755 --- a/packaging/enlightenment.spec +++ b/packaging/enlightenment.spec @@ -50,8 +50,6 @@ BuildRequires: pkgconfig(cynara-client) BuildRequires: pkgconfig(cynara-creds-socket) BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(pixman-1) -BuildRequires: pkgconfig(aul) -BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: systemd-devel BuildRequires: pkgconfig(libinput) Requires: libwayland-extension-server diff --git a/src/bin/e_policy_appinfo.c b/src/bin/e_policy_appinfo.c index afdd09560a..f4793ce70a 100644 --- a/src/bin/e_policy_appinfo.c +++ b/src/bin/e_policy_appinfo.c @@ -91,7 +91,7 @@ e_policy_appinfo_base_output_resolution_get(E_Policy_Appinfo *epai, int *width, return EINA_TRUE; } -EINTERN E_Policy_Appinfo * +E_API E_Policy_Appinfo * e_policy_appinfo_find_with_pid(pid_t pid) { E_Policy_Appinfo *epai = NULL; @@ -108,7 +108,7 @@ e_policy_appinfo_find_with_pid(pid_t pid) return NULL; } -EINTERN Eina_Bool +E_API Eina_Bool e_policy_appinfo_base_output_resolution_set(E_Policy_Appinfo *epai, int width, int height) { EINA_SAFETY_ON_NULL_RETURN_VAL(epai, EINA_FALSE); diff --git a/src/bin/e_policy_appinfo.h b/src/bin/e_policy_appinfo.h index 0ffd8e845b..f2d31a62db 100644 --- a/src/bin/e_policy_appinfo.h +++ b/src/bin/e_policy_appinfo.h @@ -6,7 +6,7 @@ EINTERN Eina_Bool e_policy_appinfo_pid_set(E_Policy_Appinfo *epai, pid_t EINTERN Eina_Bool e_policy_appinfo_appid_set(E_Policy_Appinfo *epai, const char *appid); EINTERN Eina_Bool e_policy_appinfo_base_output_resolution_get(E_Policy_Appinfo *epai, int *width, int *height); -EINTERN E_Policy_Appinfo *e_policy_appinfo_find_with_pid(pid_t pid); -EINTERN Eina_Bool e_policy_appinfo_base_output_resolution_set(E_Policy_Appinfo *epai, int width, int height); +E_API E_Policy_Appinfo *e_policy_appinfo_find_with_pid(pid_t pid); +E_API Eina_Bool e_policy_appinfo_base_output_resolution_set(E_Policy_Appinfo *epai, int width, int height); diff --git a/src/bin/e_policy_wl.c b/src/bin/e_policy_wl.c index 1bea655e8f..abd0e2b2c8 100644 --- a/src/bin/e_policy_wl.c +++ b/src/bin/e_policy_wl.c @@ -17,11 +17,6 @@ #include #include -#if 1 // APPINFO launch_app_info -#include -#include -#endif - #define APP_DEFINE_GROUP_NAME "effect" typedef enum _Tzsh_Srv_Role @@ -227,6 +222,14 @@ static Eina_List *hooks_co = NULL; static struct wl_resource *_scrsaver_mng_res = NULL; // TODO static struct wl_resource *_indicator_srv_res = NULL; +static int _e_policy_wl_hooks_delete = 0; +static int _e_policy_wl_hooks_walking = 0; + +static Eina_Inlist *_e_policy_wl_hooks[] = +{ + [E_POLICY_WL_HOOK_BASE_SCREEN_RESOLUTION_GET] = NULL, +}; + E_API int E_EVENT_POLICY_INDICATOR_STATE_CHANGE = -1; E_API int E_EVENT_POLICY_INDICATOR_OPACITY_MODE_CHANGE = -1; E_API int E_EVENT_POLICY_INDICATOR_VISIBLE_STATE_CHANGE = -1; @@ -283,6 +286,77 @@ static void _launch_effect_hide(uint32_t pid); static void _launch_effect_client_del(E_Client *ec); static void _launch_splash_off(E_Policy_Wl_Tzlaunch_Splash *tzlaunch_splash); +// -------------------------------------------------------- +// E_Policy_Wl_Hook +// -------------------------------------------------------- + +static void +_e_policy_wl_hooks_clean() +{ + E_Policy_Wl_Hook *epwh = NULL; + Eina_Inlist *l = NULL; + unsigned int x; + + for (x = 0; x < E_POLICY_WL_HOOK_LAST; x++) + { + EINA_INLIST_FOREACH_SAFE(_e_policy_wl_hooks[x], l, epwh) + { + if (!epwh->delete_me) continue; + _e_policy_wl_hooks[x] = eina_inlist_remove(_e_policy_wl_hooks[x], EINA_INLIST_GET(epwh)); + free(epwh); + } + } +} + +static void +_e_policy_wl_hook_call(E_Policy_Wl_Hook_Point hookpoint, pid_t pid) +{ + E_Policy_Wl_Hook *epwh = NULL; + + _e_policy_wl_hooks_walking++; + EINA_INLIST_FOREACH(_e_policy_wl_hooks[hookpoint], epwh) + { + if (epwh->delete_me) continue; + epwh->func(epwh->data, pid); + } + _e_policy_wl_hooks_walking--; + + if ((_e_policy_wl_hooks_walking == 0) && (_e_policy_wl_hooks_delete > 0)) + _e_policy_wl_hooks_clean(); +} + +E_API E_Policy_Wl_Hook * +e_policy_wl_hook_add(E_Policy_Wl_Hook_Point hookpoint, E_Policy_Wl_Hook_Cb func, const void *data) +{ + E_Policy_Wl_Hook *epwh = NULL; + + EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint < 0, NULL); + EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_POLICY_WL_HOOK_LAST, NULL); + + epwh = E_NEW(E_Policy_Wl_Hook, 1); + EINA_SAFETY_ON_NULL_RETURN_VAL(epwh, NULL); + + epwh->hookpoint = hookpoint; + epwh->func = func; + epwh->data = (void *)data; + _e_policy_wl_hooks[hookpoint] = eina_inlist_append(_e_policy_wl_hooks[hookpoint], EINA_INLIST_GET(epwh)); + + return epwh; +} + +E_API void +e_policy_wl_hook_del(E_Policy_Wl_Hook *epwh) +{ + epwh->delete_me = 1; + if (_e_policy_wl_hooks_walking == 0) + { + _e_policy_wl_hooks[epwh->hookpoint] = eina_inlist_remove(_e_policy_wl_hooks[epwh->hookpoint], EINA_INLIST_GET(epwh)); + free(epwh); + } + else + _e_policy_wl_hooks_delete++; +} + // -------------------------------------------------------- // E_Policy_Wl_Tzpol // -------------------------------------------------------- @@ -5588,74 +5662,6 @@ _tzlaunch_appinfo_iface_cb_deregister_pid(struct wl_client *client, struct wl_re e_policy_appinfo_del(epai); } -static void -_e_module_base_resolution_get(const char *appid, int *width, int *height) -{ - int ret = 0; - char *resolution = NULL; - pkgmgrinfo_appinfo_h appinfo = NULL; - - *width = 0; - *height = 0; - - // 1. get appinfo - ret = pkgmgrinfo_appinfo_get_appinfo(appid, &appinfo); - if (ret != PMINFO_R_OK || appinfo == NULL) - { - ELOGF("APPINFO", "tzlaunch_appinfo:: failed to get appinfo.", NULL, NULL); - goto err; - } - - // 2. get metadata - ret = pkgmgrinfo_appinfo_get_metadata_value(appinfo, - "http://tizen.org/metadata/app_ui_type/base_screen_resolution", &resolution); - - if (ret != PMINFO_R_OK) - { - ELOGF("APPINFO", "tzlaunch_appinfo:: can't get base_screen_resolution from metadata.", NULL, NULL); - goto err; - // doing without metadata. using e_config preconfigued_resolution. - } - - if (!e_util_strcmp(resolution, "2k")) - { - *width = 1920; - *height = 1080; - } - else if (!e_util_strcmp(resolution, "4k")) - { - *width = 3840; - *height = 2160; - } - else if (!e_util_strcmp(resolution, "max")) - { - *width = 1920; - *height = 1080; - } - else - { -#if 1 // TODO: FIX ME - *width = 1920; - *height = 1080; -#else - *width = ec->desk->geom.w; - *height = ec->desk->geom.h; -#endif - } - - ELOGF("APPINFO", "tzlaunch_appinfo:: get base_screen_resolution from metadata: %s.", NULL, NULL, resolution); - - pkgmgrinfo_appinfo_destroy_appinfo(appinfo); - - return; -err: - *width = 1920; - *height = 1080; - - if (appinfo) - pkgmgrinfo_appinfo_destroy_appinfo(appinfo); -} - // launch doing! static void _tzlaunch_appinfo_iface_cb_set_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo, @@ -5696,11 +5702,11 @@ _tzlaunch_appinfo_iface_cb_set_appid(struct wl_client *client, struct wl_resourc // TODO: call the HOOK to get the base screen resolution from e20 module. // 1. send HOOK with pid + _e_policy_wl_hook_call(E_POLICY_WL_HOOK_BASE_SCREEN_RESOLUTION_GET, pid); // 2. module must set the base_output_resolution. - _e_module_base_resolution_get(appid, &width, &height); - if (!e_policy_appinfo_base_output_resolution_set(epai, width, height)) + if (!e_policy_appinfo_base_output_resolution_get(epai, &width, &height)) { - ELOGF("APPINFO", "tzlaunch_appinfo:: fail to set base_output_resolution.!!!! : |pid:%u|appid:%s|", NULL, NULL, pid, appid); + ELOGF("APPINFO", "tzlaunch_appinfo:: fail to set base_output_resolution in module!!!! : |pid:%u|appid:%s|", NULL, NULL, pid, appid); return; } // 3. server has to get the base_screern_resolution via e_policy_appinfo_base_output_resolution_get. diff --git a/src/bin/e_policy_wl.h b/src/bin/e_policy_wl.h index b38c586662..b0db8aa322 100644 --- a/src/bin/e_policy_wl.h +++ b/src/bin/e_policy_wl.h @@ -11,6 +11,28 @@ void e_policy_wl_client_add(E_Client *ec); void e_policy_wl_client_del(E_Client *ec); void e_policy_wl_pixmap_del(E_Pixmap *cp); +typedef struct _E_Policy_Wl_Hook E_Policy_Wl_Hook; +typedef void (*E_Policy_Wl_Hook_Cb)(void *data, pid_t pid); + +typedef enum _E_Policy_Wl_Hook_Point +{ + E_POLICY_WL_HOOK_BASE_SCREEN_RESOLUTION_GET, + E_POLICY_WL_HOOK_LAST, +} E_Policy_Wl_Hook_Point; + +struct _E_Policy_Wl_Hook +{ + EINA_INLIST; + E_Policy_Wl_Hook_Point hookpoint; + E_Policy_Wl_Hook_Cb func; + void *data; + unsigned char delete_me : 1; +}; + +/* hook */ +E_API E_Policy_Wl_Hook* e_policy_wl_hook_add(E_Policy_Wl_Hook_Point hookpoint, E_Policy_Wl_Hook_Cb func, const void *data); +E_API void e_policy_wl_hook_del(E_Policy_Wl_Hook *epwh); + /* visibility */ void e_policy_wl_visibility_send(E_Client *ec, int vis);