Support of EFL event invocations on named widgets

A new action has been added, permitting the invocation of EFL events on
named widgets.
The name must be set via efl_name_set.
This commit is contained in:
Daniel Zaoui 2018-03-25 23:17:45 +03:00
parent cdb033bcbc
commit ca185b925a
5 changed files with 122 additions and 2 deletions

View File

@ -110,6 +110,7 @@ static int _multi_move_op = EINA_DEBUG_OPCODE_INVALID;
static int _key_down_op = EINA_DEBUG_OPCODE_INVALID;
static int _key_up_op = EINA_DEBUG_OPCODE_INVALID;
static int _take_shot_op = EINA_DEBUG_OPCODE_INVALID;
static int _efl_event_op = EINA_DEBUG_OPCODE_INVALID;
static int _finish_op = EINA_DEBUG_OPCODE_INVALID;
static Eina_Bool _all_apps_get_cb(Eina_Debug_Session *, int , void *, int);
@ -126,6 +127,7 @@ EINA_DEBUG_OPCODES_ARRAY_DEFINE(_debug_ops,
{"Exactness/Actions/Key Down", &_key_down_op, NULL},
{"Exactness/Actions/Key Up", &_key_up_op, NULL},
{"Exactness/Actions/Take Shot", &_take_shot_op, NULL},
{"Exactness/Actions/EFL Event", &_efl_event_op, NULL},
{"Exactness/Actions/Finish", &_finish_op, NULL},
{NULL, NULL, NULL}
);
@ -250,6 +252,19 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
eina_debug_session_send(_session, _cid, _take_shot_op, &n_evas, sizeof(int));
break;
}
case EXACTNESS_ACTION_EFL_EVENT:
{
Exactness_Action_Efl_Event *t = data;
int len = 0;
len += t->wdg_name ? strlen(t->wdg_name) : 0;
len += t->event_name ? strlen(t->event_name) : 0;
char *buf = malloc(len), *tmp = buf;
_printf(2, "%s %s\n", __func__, "EFL event");
STORE_STRING(tmp, t->wdg_name);
STORE_STRING(tmp, t->event_name);
eina_debug_session_send(_session, _cid, _efl_event_op, buf, len);
break;
}
default: /* All non-input events are not handeled */
break;
}

View File

@ -62,6 +62,7 @@ _action_name_get(Exactness_Action *act)
case EXACTNESS_ACTION_KEY_DOWN: return "Key Down";
case EXACTNESS_ACTION_KEY_UP: return "Key Up";
case EXACTNESS_ACTION_TAKE_SHOT: return "Take shot";
case EXACTNESS_ACTION_EFL_EVENT: return "EFL Event";
default: return NULL;
}
}
@ -81,6 +82,8 @@ _event_struct_len_get(Exactness_Action_Type type)
case EXACTNESS_ACTION_KEY_DOWN:
case EXACTNESS_ACTION_KEY_UP:
return sizeof(Exactness_Action_Key_Down_Up);
case EXACTNESS_ACTION_EFL_EVENT:
return sizeof(Exactness_Action_Efl_Event);
default: return 0;
}
}
@ -123,6 +126,12 @@ _action_specific_info_get(const Exactness_Action *act, char output[1024])
t->keyname, t->key, t->string, t->compose, t->keycode);
break;
}
case EXACTNESS_ACTION_EFL_EVENT:
{
Exactness_Action_Efl_Event *t = act->data;
sprintf(output, "Widget %s Event %s", t->wdg_name, t->event_name);
break;
}
default:
{
output[0] = '\0';
@ -158,6 +167,13 @@ _are_scenario_entries_different(Exactness_Action *act1, Exactness_Action *act2)
return !!memcmp(act1->data, act2->data, sizeof(Exactness_Action_Multi_Move));
case EXACTNESS_ACTION_KEY_UP: case EXACTNESS_ACTION_KEY_DOWN:
return !!memcmp(act1->data, act2->data, sizeof(Exactness_Action_Key_Down_Up));
case EXACTNESS_ACTION_EFL_EVENT:
{
Exactness_Action_Efl_Event *e1 = act1->data;
Exactness_Action_Efl_Event *e2 = act2->data;
return (!!strcmp(e1->wdg_name, e2->wdg_name) ||
!!strcmp(e1->event_name, e2->event_name));
}
default:
return EINA_FALSE;
}

View File

@ -377,6 +377,55 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
if (_dest_type != FTYPE_UNKNOWN && e) _shot_do(e);
break;
}
case EXACTNESS_ACTION_EFL_EVENT:
{
Exactness_Action_Efl_Event *t = data;
Eina_Bool found = EINA_FALSE;
Eina_List *itr;
EINA_LIST_FOREACH(_evas_list, itr, e)
{
Eo *o = efl_name_find(e, t->wdg_name);
if (o)
{
_printf(2, "%s EFL event invoke %s on %s\n",
__func__, t->event_name, t->wdg_name);
Efl_Event_Description d;
found = EINA_TRUE;
memset(&d, 0, sizeof(d));
d.name = t->event_name;
d.legacy_is = EINA_TRUE;
efl_event_callback_legacy_call(o, &d, NULL);
#if 0
/* Remove when events stuff work well */
Eina_Size2D sz = efl_gfx_size_get(o);
Eina_Position2D pos = efl_gfx_position_get(o);
if (!strcmp(t->event_name, "clicked") ||
!strcmp(t->event_name, "clicked,double"))
{
int x = pos.x + (sz.w / 2);
int y = pos.y + (sz.h / 2);
evas_event_feed_mouse_move(e, x, y, time(NULL), NULL);
evas_event_feed_mouse_down(e, 0, EVAS_BUTTON_NONE, time(NULL), NULL);
evas_event_feed_mouse_up(e, 0, EVAS_BUTTON_NONE, time(NULL), NULL);
if (rect)
{
evas_object_move(rect, x, y);
evas_object_color_set(rect, 255, 0, 0, 255);
}
if (!strcmp(t->event_name, "clicked,double"))
{
evas_event_feed_mouse_down(e, 0, EVAS_BUTTON_DOUBLE_CLICK,
time(NULL), NULL);
evas_event_feed_mouse_up(e, 0, EVAS_BUTTON_DOUBLE_CLICK,
time(NULL), NULL);
}
}
#endif
}
}
if (!found) fprintf(stderr, "Failed finding %s.\n", t->wdg_name);
break;
}
default: /* All non-input events are not handeled */
break;
}
@ -526,6 +575,16 @@ _main_loop_take_shot_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_
_feed_event(EXACTNESS_ACTION_TAKE_SHOT, n_evas, NULL);
}
static void
_main_loop_efl_event_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
Exactness_Action_Efl_Event t;
t.wdg_name = EXTRACT_STRING(buf);
t.event_name = EXTRACT_STRING(buf);
_feed_event(EXACTNESS_ACTION_EFL_EVENT, 0, &t);
}
static void
_main_loop_finish_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer EINA_UNUSED, int size EINA_UNUSED)
{
@ -541,6 +600,7 @@ WRAPPER_TO_XFER_MAIN_LOOP(_multi_move_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_key_down_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_key_up_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_take_shot_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_efl_event_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_finish_cb)
EINA_DEBUG_OPCODES_ARRAY_DEFINE(_debug_ops,
@ -553,6 +613,7 @@ EINA_DEBUG_OPCODES_ARRAY_DEFINE(_debug_ops,
{"Exactness/Actions/Key Down", NULL, &_key_down_cb},
{"Exactness/Actions/Key Up", NULL, &_key_up_cb},
{"Exactness/Actions/Take Shot", NULL, &_take_shot_cb},
{"Exactness/Actions/EFL Event", NULL, &_efl_event_cb},
{"Exactness/Actions/Finish", NULL, &_finish_cb},
{NULL, NULL, NULL}
);

View File

@ -56,7 +56,8 @@ typedef enum
EXACTNESS_ACTION_KEY_DOWN,
EXACTNESS_ACTION_KEY_UP,
EXACTNESS_ACTION_TAKE_SHOT,
EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_TAKE_SHOT
EXACTNESS_ACTION_EFL_EVENT,
EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_EFL_EVENT
/* Add any supported actions here and update _LAST */
} Exactness_Action_Type;
@ -121,6 +122,16 @@ typedef struct
double fy;
} Exactness_Action_Multi_Move;
/**
* @typedef Exactness_Action_Efl_Event
* The type for the Exactness EFL Event action.
*/
typedef struct
{
char *wdg_name;
char *event_name;
} Exactness_Action_Efl_Event;
/**
* @typedef Exactness_Action
* The type for the Exactness action.

View File

@ -96,6 +96,20 @@ _multi_move_desc_make(void)
return _d;
}
static Eet_Data_Descriptor *
_efl_event_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *_d;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Efl_Event);
_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "wdg_name", wdg_name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "event_name", event_name, EET_T_STRING);
return _d;
}
static Eet_Data_Descriptor *
_dummy_desc_make(void)
{
@ -119,7 +133,8 @@ static const char *_mapping[] =
"exactness_action_multi_move",
"exactness_action_key_down",
"exactness_action_key_up",
"exactness_action_take_shot"
"exactness_action_take_shot",
"exactness_action_efl_event"
};
const char *
@ -207,6 +222,8 @@ _unit_desc_make(void)
_mapping[EXACTNESS_ACTION_KEY_UP], _key_down_up_desc_make());
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
_mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make());
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
_mapping[EXACTNESS_ACTION_EFL_EVENT], _efl_event_desc_make());
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "n_evas", n_evas, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "delay_ms", delay_ms, EET_T_UINT);