Compare commits

...

10 Commits

Author SHA1 Message Date
Marcel Hollerbach 41da42207d mod: thats start stop not only start 2017-10-09 16:08:28 +02:00
Marcel Hollerbach d27ba73d78 ignore unresolved defines 2017-08-28 19:20:18 +02:00
Marcel Hollerbach f1ab2bee2f presentator: really decrease the font size 2017-08-03 13:57:41 +02:00
Marcel Hollerbach 1214dc9cbe presentator: enhance error messages 2017-07-31 07:58:39 +02:00
Marcel Hollerbach 6c9c9924ed Let there be a README 2017-07-30 20:29:32 +02:00
Marcel Hollerbach 9b853479c5 presentator: save the scale value 2017-07-30 19:34:28 +02:00
Marcel Hollerbach c30b7f16da presentator: place notify correctly 2017-07-30 19:20:39 +02:00
Marcel Hollerbach e3f95d45b1 presentator: free iterator 2017-07-30 19:20:06 +02:00
Marcel Hollerbach fc3fcc5431 presentator: set scale correctly 2017-07-30 19:19:52 +02:00
Marcel Hollerbach 8ace8acd99 presentator: display on active zone 2017-07-30 19:12:29 +02:00
3 changed files with 113 additions and 43 deletions

5
README
View File

@ -0,0 +1,5 @@
A Module to display your current keystrokes on the screen.
Helpfull for presentating a live demo infront of a audience
The visuals are displayed on the current active zone on your screen.

View File

@ -7,19 +7,24 @@ 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;
typedef struct {
float scale;
} Presentator_Config;
static E_Config_DD *dd_config;
static Presentator_Config *config;
static void _del_key(const char *name);
static Eina_Bool
@ -31,6 +36,59 @@ _timed_del(void *data)
return 0;
}
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);
}
eina_iterator_free(iter);
iter = NULL;
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.x + (geom.w - minw) /2;
notify_geom.y = geom.y + geom.h - minh;
notify_geom.w = minw;
notify_geom.h = minh;
evas_object_geometry_set(notify, EINA_RECTANGLE_ARGS(&notify_geom));
}
static void
_flush_config(void)
{
e_config_domain_save("presentator", dd_config, config);
elm_object_scale_set(lb, config->scale);
_update_place();
}
static void
_del_key(const char *name)
{
@ -39,7 +97,7 @@ _del_key(const char *name)
//something fishy is going on sometimes, then we dont even have a entry
if (!e)
{
ERR("What the fuck?!");
/* there was a release without a hit, usally happens when we are starting up */
return;
}
@ -58,19 +116,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 +134,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);
}
@ -131,7 +170,7 @@ _msg_from_child_handler(void *data EINA_UNUSED, int type EINA_UNUSED, void *even
}
else
{
printf("WHAT THE FUCK\n");
ERR("Unknown message from the keylogger");
}
}
return ECORE_CALLBACK_PASS_ON;
@ -140,27 +179,28 @@ _msg_from_child_handler(void *data EINA_UNUSED, int type EINA_UNUSED, void *even
static Eina_Bool
_msg_from_child_handler_error(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
printf("ERROR!!!!!!!\n");
ERR("The keylogger passed out");
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);
_flush_config();
/* FIXME this is only on x11 need a different solution for wl */
{
keylogger = ecore_exe_pipe_run(MODULE_DIR"/keylogger", ECORE_EXE_PIPE_WRITE |
@ -202,21 +242,42 @@ _toggle_run_mode(E_Object *e, const char *name)
static void
_decrease_fontsize(E_Object *e, const char *name)
{
float scale = elm_object_scale_get(notify);
elm_object_scale_set(notify, scale - 0.1);
float scale = elm_object_scale_get(lb);
config->scale = scale - 0.1;
_flush_config();
}
static void
_increase_fontsize(E_Object *e, const char *name)
{
float scale = elm_object_scale_get(notify);
elm_object_scale_set(notify, scale + 0.1);
float scale = elm_object_scale_get(lb);
config->scale = scale + 0.1;
_flush_config();
}
static void
_config_init(void)
{
E_Config_DD *result = E_CONFIG_DD_NEW("presentator", Presentator_Config);
E_CONFIG_VAL(result, Presentator_Config, scale, FLOAT);
dd_config = result;
}
E_API void *
e_modapi_init(E_Module *m)
{
ecore_init();
_config_init();
config = e_config_domain_load("presentator", dd_config);
if (!config)
config = calloc(1, sizeof(Presentator_Config));
#define ACTION_ADD(_action, _cb, _title, _value, _params, _example, _editable) \
{ \
@ -227,7 +288,7 @@ e_modapi_init(E_Module *m)
_params, _example, _editable); \
} \
}
ACTION_ADD(start_stop, _toggle_run_mode, "Start", "Toggle key highlight mode", NULL, NULL, EINA_FALSE);
ACTION_ADD(start_stop, _toggle_run_mode, "Start/Stop", "Toggle key highlight mode", NULL, NULL, EINA_FALSE);
ACTION_ADD(start_stop, _increase_fontsize, "Increase Fontsize", "Increase Fontsize", NULL, NULL, EINA_FALSE);
ACTION_ADD(start_stop, _decrease_fontsize, "Decrease Fontsize", "Decrease Fontsize", NULL, NULL, EINA_FALSE);
#undef ACTION_ADD
@ -238,6 +299,9 @@ e_modapi_init(E_Module *m)
E_API int
e_modapi_shutdown(E_Module *m EINA_UNUSED)
{
E_CONFIG_DD_FREE(dd_config);
free(config);
config = NULL;
ecore_shutdown();
return 1;

View File

@ -7,7 +7,8 @@ module = shared_module('module',
dependencies : e,
install_dir: install_dir,
install: true,
name_prefix: '')
name_prefix: '',
link_args: '-Wl,--unresolved-symbols=ignore-in-object-files')
keylogger = executable('keylogger', 'keylogger.c',
dependencies : [x11,xi],