bu5hm4n pushed a commit to branch master. http://git.enlightenment.org/enlightenment/modules/presentator.git/commit/?id=8ace8acd997ec608ea01e454ea722b4fe84fec71
commit 8ace8acd997ec608ea01e454ea722b4fe84fec71 Author: Marcel Hollerbach <[email protected]> Date: Sun Jul 30 19:12:29 2017 +0200 presentator: display on active zone --- src/e_mod_main.c | 87 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 33 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 3ad961e..3c58fa8 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -7,16 +7,14 @@ E_API E_Module_Api e_modapi = "Presentator helper tool" }; -static Evas_Object *notify, *bx; +static Evas_Object *notify, *lb; static Eina_Hash *string_hash; -static int entry_counter = 0; static Ecore_Event_Handler *event_data, *event_error; static Ecore_Exe *keylogger; typedef struct { unsigned int ref; char *name; - Evas_Object *vis; Ecore_Timer *timer; } Entry; @@ -32,6 +30,48 @@ _timed_del(void *data) } static void +_update_place(void) +{ + E_Zone *zone = e_zone_current_get(); + Eina_Rectangle geom, notify_geom; + Evas_Coord minw = -1, minh = -1; + Edje_Object *edje; + Eina_Strbuf *buf; + Entry *e; + + Eina_Iterator* iter = eina_hash_iterator_data_new(string_hash); + + buf = eina_strbuf_new(); + + EINA_ITERATOR_FOREACH(iter, e) + { + if (!!eina_strbuf_length_get(buf)) + eina_strbuf_append(buf, " + "); + eina_strbuf_append(buf, e->name); + } + + if (!eina_strbuf_length_get(buf)) + evas_object_hide(notify); + else + evas_object_show(notify); + + elm_object_text_set(lb, eina_strbuf_string_get(buf)); + + eina_strbuf_free(buf); + + edje = elm_layout_edje_get(notify); + edje_object_size_min_calc(edje, &minw, &minh); + + e_zone_useful_geometry_get(zone, &geom.x, &geom.y, &geom.w, &geom.h); + notify_geom.x = (geom.w - minw) /2; + notify_geom.y = geom.h - minh; + notify_geom.w = minw; + notify_geom.h = minh; + + evas_object_geometry_set(notify, EINA_RECTANGLE_ARGS(¬ify_geom)); +} + +static void _del_key(const char *name) { Entry *e = eina_hash_find(string_hash, name); @@ -58,19 +98,14 @@ _del_key(const char *name) //if ref is 0 nuke out that entry eina_hash_del_by_key(string_hash, name); - entry_counter --; //we need to update the notify visuals depending on the state of the box - if (entry_counter <= 0) - evas_object_hide(notify); + _update_place(); } } static void _add_key(const char *name) { - Eina_Strbuf *buf; - Evas_Object *o; - Entry *e = eina_hash_find(string_hash, name); //first if we have already displayed that string do not display it again @@ -81,33 +116,19 @@ _add_key(const char *name) return; } - //find a considerable text to display - buf = eina_strbuf_new(); - if (entry_counter == 0) - eina_strbuf_append_printf(buf, "%s", name); - else - eina_strbuf_append_printf(buf, " + %s", name); - - //create a label and attach to the box - o = elm_label_add(bx); - elm_object_text_set(o, eina_strbuf_string_get(buf)); - evas_object_show(o); - elm_box_pack_end(bx, o); - evas_object_show(notify); - //save as entry somewhere e = calloc(1, sizeof(Entry)); e->ref = 2; //one for beeing used and one for the minimum time - e->vis = o; e->name = strdup(name); - entry_counter ++; eina_hash_add(string_hash, name, e); + + //update the place here + _update_place(); } static void _entry_free(Entry *e) { - evas_object_del(e->vis); free(e->name); free(e); } @@ -146,20 +167,20 @@ _msg_from_child_handler_error(void *data EINA_UNUSED, int type EINA_UNUSED, void return ECORE_CALLBACK_PASS_ON; } + static void _start_logging(void) { string_hash = eina_hash_string_small_new((Eina_Free_Cb)_entry_free); - notify = elm_notify_add(e_comp->elm); - elm_notify_allow_events_set(notify, EINA_TRUE); + notify = elm_layout_add(e_comp->elm); + elm_layout_theme_set(notify, "notify", "bottom", "default"); evas_object_layer_set(notify, E_LAYER_POPUP); - elm_notify_align_set(notify, 0.5, 1.0); + evas_object_pass_events_set(notify, EINA_TRUE); - bx = elm_box_add(notify); - elm_box_horizontal_set(bx, EINA_TRUE); - elm_object_content_set(notify, bx); - evas_object_show(bx); + lb = elm_label_add(notify); + elm_object_content_set(notify, lb); + evas_object_show(lb); /* FIXME this is only on x11 need a different solution for wl */ { --
