From: Doyoun Kang Date: Wed, 18 Oct 2017 01:39:42 +0000 (+0900) Subject: softkey: modify softkey feature X-Git-Tag: submit/tizen/20171018.060412~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c8069f367ac034b0877a1afab9b425ada8df5c8;p=platform%2Fupstream%2Fenlightenment.git softkey: modify softkey feature We add code to control the softkey by module. Change-Id: Ice65d31fd1d71cd87daa81653d4e356ab070f988 --- diff --git a/src/bin/e_policy.c b/src/bin/e_policy.c index 8fc9017419..b837ede9ef 100644 --- a/src/bin/e_policy.c +++ b/src/bin/e_policy.c @@ -1006,6 +1006,7 @@ _e_policy_cb_zone_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) E_Event_Zone_Add *ev; E_Zone *zone; E_Config_Policy_Desk *d; + E_Policy_Softkey *softkey; int i, n; ev = event; @@ -1020,6 +1021,14 @@ _e_policy_cb_zone_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) e_policy_desk_add(zone->desks[i]); } + /* add and show softkey */ + if (e_config->use_softkey) + { + softkey = e_policy_softkey_get(zone); + if (!softkey) + softkey = e_policy_softkey_add(zone); + } + return ECORE_CALLBACK_PASS_ON; } @@ -1029,6 +1038,8 @@ _e_policy_cb_zone_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) E_Event_Zone_Del *ev; E_Zone *zone; E_Policy_Desk *pd; + E_Policy_Softkey *softkey; + int i, n; ev = event; @@ -1040,6 +1051,14 @@ _e_policy_cb_zone_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) if (pd) e_policy_desk_del(pd); } + /* add and show softkey */ + if (e_config->use_softkey) + { + softkey = e_policy_softkey_get(zone); + if (softkey) + e_policy_softkey_del(softkey); + } + return ECORE_CALLBACK_PASS_ON; } @@ -1140,6 +1159,9 @@ _e_policy_cb_desk_show(void *data EINA_UNUSED, int type EINA_UNUSED, void *event if (e_config->use_softkey) { softkey = e_policy_softkey_get(ev->desk->zone); + if (!softkey) + softkey = e_policy_softkey_add(ev->desk->zone); + if (eina_hash_find(hash_policy_desks, &ev->desk)) e_policy_softkey_show(softkey); else @@ -1422,7 +1444,6 @@ e_policy_desk_add(E_Desk *desk) { E_Policy_Desk *pd; E_Client *ec; - E_Policy_Softkey *softkey; E_Policy_Client *pc; pd = eina_hash_find(hash_policy_desks, &desk); @@ -1445,16 +1466,6 @@ e_policy_desk_add(E_Desk *desk) _e_policy_client_maximize_policy_apply(pc); } } - - /* add and show softkey */ - if (e_config->use_softkey) - { - softkey = e_policy_softkey_get(desk->zone); - if (!softkey) - softkey = e_policy_softkey_add(desk->zone); - if (e_desk_current_get(desk->zone) == desk) - e_policy_softkey_show(softkey); - } } void @@ -1465,8 +1476,6 @@ e_policy_desk_del(E_Policy_Desk *pd) E_Client *ec; Eina_List *clients_del = NULL; E_Policy_Softkey *softkey; - Eina_Bool keep = EINA_FALSE; - int i, n; /* hide and delete softkey */ if (e_config->use_softkey) @@ -1474,19 +1483,6 @@ e_policy_desk_del(E_Policy_Desk *pd) softkey = e_policy_softkey_get(pd->zone); if (e_desk_current_get(pd->zone) == pd->desk) e_policy_softkey_hide(softkey); - - n = pd->zone->desk_y_count * pd->zone->desk_x_count; - for (i = 0; i < n; i++) - { - if (eina_hash_find(hash_policy_desks, &pd->zone->desks[i])) - { - keep = EINA_TRUE; - break; - } - } - - if (!keep) - e_policy_softkey_del(softkey); } /* remove clients */ diff --git a/src/bin/e_policy.h b/src/bin/e_policy.h index 110c6d3e73..5d772a75e6 100644 --- a/src/bin/e_policy.h +++ b/src/bin/e_policy.h @@ -9,6 +9,7 @@ typedef struct _E_Policy E_Policy; typedef struct _E_Policy_System_Info E_Policy_System_Info; typedef struct _E_Policy_Interceptor E_Policy_Interceptor; typedef struct _E_Policy_Hook E_Policy_Hook; +typedef struct _E_Policy_Softkey_Funcs E_Policy_Softkey_Funcs; typedef enum _E_Policy_Intercept_Point { @@ -91,6 +92,16 @@ struct _E_Policy_Softkey E_Zone *zone; Evas_Object *home; Evas_Object *back; + Evas_Object *other; +}; + +struct _E_Policy_Softkey_Funcs +{ + E_Policy_Softkey* (*softkey_create)(E_Zone *zone); + void (*softkey_destroy)(E_Policy_Softkey *softkey); + void (*softkey_show)(E_Policy_Softkey *softkey); + void (*softkey_hide)(E_Policy_Softkey *softkey); + void (*softkey_update)(E_Policy_Softkey *softkey); }; struct _E_Policy @@ -135,7 +146,7 @@ EINTERN E_Policy_Config_Desk *e_policy_conf_desk_get_by_nums(E_Policy_Config *co EINTERN E_Policy_Client *e_policy_client_get(E_Client *ec); EINTERN void e_policy_desk_add(E_Desk *desk); EINTERN void e_policy_desk_del(E_Policy_Desk *pd); -EINTERN E_Policy_Client *e_policy_client_launcher_get(E_Zone *zone); +E_API E_Policy_Client *e_policy_client_launcher_get(E_Zone *zone); E_API Eina_Bool e_policy_client_is_lockscreen(E_Client *ec); E_API Eina_Bool e_policy_client_is_home_screen(E_Client *ec); @@ -155,12 +166,14 @@ E_API Eina_Bool e_policy_client_is_keyboard(E_Client *ec); E_API Eina_Bool e_policy_client_is_keyboard_sub(E_Client *ec); E_API Eina_Bool e_policy_client_is_keyboard_magnifier(E_Client *ec); -EINTERN E_Policy_Softkey *e_policy_softkey_add(E_Zone *zone); -EINTERN void e_policy_softkey_del(E_Policy_Softkey *softkey); -EINTERN void e_policy_softkey_show(E_Policy_Softkey *softkey); -EINTERN void e_policy_softkey_hide(E_Policy_Softkey *softkey); -EINTERN void e_policy_softkey_update(E_Policy_Softkey *softkey); -EINTERN E_Policy_Softkey *e_policy_softkey_get(E_Zone *zone); +E_API E_Policy_Softkey *e_policy_softkey_add(E_Zone *zone); +E_API void e_policy_softkey_del(E_Policy_Softkey *softkey); +E_API void e_policy_softkey_show(E_Policy_Softkey *softkey); +E_API void e_policy_softkey_hide(E_Policy_Softkey *softkey); +E_API void e_policy_softkey_update(E_Policy_Softkey *softkey); +E_API E_Policy_Softkey *e_policy_softkey_get(E_Zone *zone); +E_API Eina_Bool e_policy_softkey_module_func_set(E_Policy_Softkey_Funcs *fn); +E_API void e_policy_softkey_module_func_unset(void); EINTERN void e_policy_client_visibility_send(E_Client *ec); EINTERN void e_policy_client_iconify_by_visibility(E_Client *ec); diff --git a/src/bin/e_policy_softkey.c b/src/bin/e_policy_softkey.c index dab04a4b32..988f0cc649 100644 --- a/src/bin/e_policy_softkey.c +++ b/src/bin/e_policy_softkey.c @@ -5,6 +5,8 @@ static void _e_policy_softkey_iconify(E_Zone *zone, Eina_Bool all); static Evas_Object *_e_policy_softkey_icon_add(E_Zone *zone, const char *name); static void _e_policy_softkey_icon_del(Evas_Object *comp_obj); +static E_Policy_Softkey_Funcs *_e_softkey_funcs = NULL; + static void _e_policy_cb_softkey(void *data, Evas_Object *obj EINA_UNUSED, const char *emission, const char *source EINA_UNUSED) { @@ -99,12 +101,20 @@ e_policy_softkey_add(E_Zone *zone) { E_Policy_Softkey *softkey; - softkey = E_NEW(E_Policy_Softkey, 1); - EINA_SAFETY_ON_NULL_RETURN_VAL(softkey, NULL); + if (_e_softkey_funcs && _e_softkey_funcs->softkey_create) + { + softkey = _e_softkey_funcs->softkey_create(zone); + EINA_SAFETY_ON_NULL_RETURN_VAL(softkey, NULL); + } + else + { + softkey = E_NEW(E_Policy_Softkey, 1); + EINA_SAFETY_ON_NULL_RETURN_VAL(softkey, NULL); - softkey->zone = zone; - softkey->home = _e_policy_softkey_icon_add(zone, "home"); - softkey->back = _e_policy_softkey_icon_add(zone, "back"); + softkey->zone = zone; + softkey->home = _e_policy_softkey_icon_add(zone, "home"); + softkey->back = _e_policy_softkey_icon_add(zone, "back"); + } e_policy->softkeys = eina_inlist_append(e_policy->softkeys, EINA_INLIST_GET(softkey)); @@ -116,17 +126,25 @@ e_policy_softkey_del(E_Policy_Softkey *softkey) { if (!softkey) return; - _e_policy_softkey_icon_del(softkey->home); - _e_policy_softkey_icon_del(softkey->back); - e_policy->softkeys = eina_inlist_remove(e_policy->softkeys, EINA_INLIST_GET(softkey)); - free(softkey); + if (_e_softkey_funcs && _e_softkey_funcs->softkey_destroy) + return _e_softkey_funcs->softkey_destroy(softkey); + else + { + _e_policy_softkey_icon_del(softkey->home); + _e_policy_softkey_icon_del(softkey->back); + + E_FREE(softkey); + } } void e_policy_softkey_show(E_Policy_Softkey *softkey) { + if (_e_softkey_funcs && _e_softkey_funcs->softkey_show) + return _e_softkey_funcs->softkey_show(softkey); + if (!softkey) return; e_policy_softkey_update(softkey); @@ -138,6 +156,9 @@ e_policy_softkey_show(E_Policy_Softkey *softkey) void e_policy_softkey_hide(E_Policy_Softkey *softkey) { + if (_e_softkey_funcs && _e_softkey_funcs->softkey_hide) + return _e_softkey_funcs->softkey_hide(softkey); + if (!softkey) return; evas_object_hide(softkey->home); @@ -149,6 +170,9 @@ e_policy_softkey_update(E_Policy_Softkey *softkey) { int x, y, w, h, ow, oh, space; + if (_e_softkey_funcs && _e_softkey_funcs->softkey_update) + return _e_softkey_funcs->softkey_update(softkey); + if (!softkey) return; e_zone_useful_geometry_get(softkey->zone, &x, &y, &w, &h); @@ -176,3 +200,31 @@ e_policy_softkey_get(E_Zone *zone) return NULL; } + +E_API Eina_Bool +e_policy_softkey_module_func_set(E_Policy_Softkey_Funcs *fp) +{ + EINA_SAFETY_ON_FALSE_RETURN_VAL((_e_softkey_funcs == NULL), EINA_FALSE); + + if (!fp) return EINA_FALSE; + + _e_softkey_funcs = E_NEW(E_Policy_Softkey_Funcs, 1); + EINA_SAFETY_ON_NULL_RETURN_VAL(_e_softkey_funcs, EINA_FALSE); + + _e_softkey_funcs->softkey_create = fp->softkey_create; + _e_softkey_funcs->softkey_destroy = fp->softkey_destroy; + _e_softkey_funcs->softkey_show = fp->softkey_show; + _e_softkey_funcs->softkey_hide = fp->softkey_hide; + _e_softkey_funcs->softkey_update = fp->softkey_update; + + return EINA_TRUE; +} + +E_API void +e_policy_softkey_module_func_unset(void) +{ + if (!_e_softkey_funcs) + return; + + E_FREE(_e_softkey_funcs); +}