evas events: Switch axis events to the new eo type

This converts Evas_Axis or Ecore_Axis info arrays into basic
pointer data. Also marks those fields as set. All events need
to properly implement the value_has property (mark all bits
whenever a value is known).
This commit is contained in:
Jean-Philippe Andre 2016-08-23 20:23:48 +09:00
parent 8938d8d557
commit 925878e931
7 changed files with 194 additions and 26 deletions

View File

@ -4347,6 +4347,8 @@ _event_description_get(Efl_Pointer_Action action)
return EFL_EVENT_POINTER_OUT;
case EFL_POINTER_ACTION_WHEEL:
return EFL_EVENT_POINTER_WHEEL;
case EFL_POINTER_ACTION_AXIS:
return EFL_EVENT_POINTER_AXIS;
default: return NULL;
}
}
@ -4520,6 +4522,74 @@ _direct_mouse_out_cb(Ecore_Evas *ee, const Ecore_Event_Mouse_IO *info)
return _direct_mouse_inout(ee, info, EFL_POINTER_ACTION_OUT);
}
static Eina_Bool
_direct_axis_update_cb(Ecore_Evas *ee, const Ecore_Event_Axis_Update *info)
{
Efl_Event_Pointer_Data *ev;
Efl_Event_Pointer *evt;
Evas *e = ee->evas;
Eina_Bool processed;
double x = 0, y = 0;
int n;
/* Unused information:
* window, root_window, event_window
*/
evt = efl_event_instance_get(EFL_EVENT_POINTER_CLASS, e, (void **) &ev);
if (!ev) return EINA_FALSE;
ev->action = EFL_POINTER_ACTION_AXIS;
ev->timestamp = info->timestamp;
ev->tool = info->toolid;
// see also evas_events.c
for (n = 0; n < info->naxis; n++)
{
const Ecore_Axis *axis = &(info->axis[n]);
switch (axis->label)
{
case EVAS_AXIS_LABEL_X:
_efl_input_value_mark(ev, EFL_INPUT_VALUE_X);
x = axis->value;
break;
case EVAS_AXIS_LABEL_Y:
_efl_input_value_mark(ev, EFL_INPUT_VALUE_Y);
y = axis->value;
break;
case EVAS_AXIS_LABEL_PRESSURE:
_efl_input_value_mark(ev, EFL_INPUT_VALUE_PRESSURE);
ev->pressure = axis->value;
break;
case EVAS_AXIS_LABEL_DISTANCE:
case EVAS_AXIS_LABEL_AZIMUTH:
case EVAS_AXIS_LABEL_TILT:
case EVAS_AXIS_LABEL_TWIST:
// TODO
case EVAS_AXIS_LABEL_UNKNOWN:
case EVAS_AXIS_LABEL_TOUCH_WIDTH_MAJOR:
case EVAS_AXIS_LABEL_TOUCH_WIDTH_MINOR:
case EVAS_AXIS_LABEL_TOOL_WIDTH_MAJOR:
case EVAS_AXIS_LABEL_TOOL_WIDTH_MINOR:
default:
DBG("Unsupported axis label %d, value %f (discarded)",
axis->label, axis->value);
break;
}
}
_pointer_position_set(ev, ee, x, y, x, y);
efl_event_callback_call(e, _event_description_get(ev->action), evt);
processed = ev->evas_done;
efl_del(evt);
return processed;
}
static Eina_Bool
_direct_key_updown_cb(Ecore_Evas *ee, const Ecore_Event_Key *info, Eina_Bool down)
{
@ -4561,13 +4631,6 @@ _direct_key_updown_cb(Ecore_Evas *ee, const Ecore_Event_Key *info, Eina_Bool dow
return processed;
}
static Eina_Bool
_direct_axis_update_cb(Ecore_Evas *ee EINA_UNUSED, const Ecore_Event_Axis_Update *info EINA_UNUSED)
{
/* TODO: Add joystick event type. */
return EINA_FALSE;
}
EAPI Eina_Bool
_ecore_evas_input_direct_cb(void *window, int type, const void *info)
{

View File

@ -104,4 +104,16 @@ struct _Efl_Event_Hold_Data
Eina_Bool evas_done : 1; /* set by evas */
};
static inline Eina_Bool
_efl_input_value_has(const Efl_Event_Pointer_Data *pd, Efl_Input_Value key)
{
return (pd->value_flags & (1 << (int) key)) != 0;
}
static inline void
_efl_input_value_mark(Efl_Event_Pointer_Data *pd, Efl_Input_Value key)
{
pd->value_flags |= (1 << (int) key);
}
#endif

View File

@ -34,6 +34,7 @@ interface Efl.Input.Interface ()
pointer,in: Efl.Event.Pointer; [[Pointer entered a window or a widget.]]
pointer,out: Efl.Event.Pointer; [[Pointer left a window or a widget.]]
pointer,wheel: Efl.Event.Pointer; [[Mouse wheel event.]]
pointer,axis: Efl.Event.Pointer; [[Pen or other axis event update.]]
finger,move: Efl.Event.Pointer; [[Finger moved (current and previous positions are known).]]
finger,down: Efl.Event.Pointer; [[Finger pressed (finger id is known).]]
finger,up: Efl.Event.Pointer; [[Finger released (finger id is known).]]

View File

@ -363,10 +363,9 @@ _efl_event_pointer_efl_event_input_fake_get(Eo *obj EINA_UNUSED, Efl_Event_Point
EOLIAN static Eina_Bool
_efl_event_pointer_value_has_get(Eo *obj EINA_UNUSED, Efl_Event_Pointer_Data *pd, Efl_Input_Value key)
{
// read-only
if ((key <= EFL_INPUT_VALUE_NONE) || (key > EFL_INPUT_VALUE_SLIDER))
if (!pd || (key <= EFL_INPUT_VALUE_NONE) || (key > EFL_INPUT_VALUE_SLIDER))
return EINA_FALSE;
return (pd->value_flags & (1 << (int) key)) != 0;
return _efl_input_value_has(pd, key);
}
EOLIAN static Eina_Bool

View File

@ -70,7 +70,7 @@ DEFINE_EVAS_CALLBACKS(_legacy_evas_callback_table, EVAS_CALLBACK_LAST,
EFL_CANVAS_EVENT_RENDER_POST,
EFL_IMAGE_EVENT_RESIZE,
EFL_CANVAS_EVENT_DEVICE_CHANGED,
EVAS_CANVAS_EVENT_AXIS_UPDATE,
EFL_EVENT_POINTER_AXIS,
EVAS_CANVAS_EVENT_VIEWPORT_RESIZE );
static inline Evas_Callback_Type
@ -123,6 +123,7 @@ _evas_event_efl_event_info_exists(Evas_Callback_Type type)
case EVAS_CALLBACK_MULTI_DOWN:
case EVAS_CALLBACK_MULTI_UP:
case EVAS_CALLBACK_MULTI_MOVE:
case EVAS_CALLBACK_AXIS_UPDATE:
return EFL_EVENT_TYPE_POINTER;
case EVAS_CALLBACK_KEY_DOWN:
case EVAS_CALLBACK_KEY_UP:

View File

@ -2864,26 +2864,23 @@ evas_event_feed_hold(Eo *eo_e, int hold, unsigned int timestamp, const void *dat
}
void
_canvas_event_feed_axis_update_internal(Evas *eo_e, Evas_Public_Data *e, unsigned int timestamp, int device, int toolid, int naxis, const Evas_Axis *axis, const void *data)
_canvas_event_feed_axis_update_internal(Evas_Public_Data *e, Efl_Event_Pointer_Data *ev)
{
Eina_List *l, *copy;
Evas_Event_Axis_Update ev;
Evas_Object *eo_obj;
int event_id = 0;
Evas *eo_e;
if (!e || !ev) return;
if (e->is_frozen) return;
e->last_timestamp = timestamp;
eo_e = e->evas;
e->last_timestamp = ev->timestamp;
ev->action = EFL_POINTER_ACTION_AXIS;
event_id = _evas_object_event_new();
ev.data = (void *)data;
ev.timestamp = timestamp;
ev.device = device;
ev.toolid = toolid;
ev.naxis = naxis;
ev.axis = (Evas_Axis *)axis;
ev.dev = _evas_device_top_get(eo_e);
if (ev.dev) efl_ref(ev.dev);
if (ev->device) efl_ref(ev->device);
_evas_walk(e);
copy = evas_event_list_copy(e->pointer.object.in);
@ -2894,8 +2891,8 @@ _canvas_event_feed_axis_update_internal(Evas *eo_e, Evas_Public_Data *e, unsigne
if (!evas_event_freezes_through(eo_obj, obj))
{
evas_object_event_callback_call(eo_obj, obj,
EVAS_CALLBACK_AXIS_UPDATE, &ev,
event_id, NULL, NULL);
EVAS_CALLBACK_AXIS_UPDATE, NULL,
event_id, EFL_EVENT_POINTER_AXIS, ev->eo);
if (e->delete_me || e->is_frozen) break;
}
}
@ -2903,13 +2900,69 @@ _canvas_event_feed_axis_update_internal(Evas *eo_e, Evas_Public_Data *e, unsigne
_evas_post_event_callback_call(eo_e, e);
_evas_unwalk(e);
if (ev->device) efl_unref(ev->device);
}
EAPI void
evas_event_feed_axis_update(Evas *eo_e, unsigned int timestamp, int device, int toolid, int naxis, const Evas_Axis *axis, const void *data)
evas_event_feed_axis_update(Evas *eo_e, unsigned int timestamp, int device, int toolid, int naxis, const Evas_Axis *axes, const void *data)
{
EINA_SAFETY_ON_FALSE_RETURN(efl_isa(eo_e, EVAS_CANVAS_CLASS));
Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
_canvas_event_feed_axis_update_internal(eo_e, e, timestamp, device, toolid, naxis, axis, data);
Efl_Event_Pointer_Data *ev = NULL;
Efl_Event_Pointer *evt;
int n;
evt = efl_event_instance_get(EFL_EVENT_POINTER_CLASS, eo_e, (void **) &ev);
if (!ev) return;
ev->data = (void *) data;
ev->timestamp = timestamp;
ev->action = EFL_POINTER_ACTION_AXIS;
ev->device = _evas_device_top_get(eo_e); // FIXME
ev->tool = toolid;
// see also ecore_evas.c
for (n = 0; n < naxis; n++)
{
const Evas_Axis *axis = &(axes[n]);
switch (axis->label)
{
case EVAS_AXIS_LABEL_X:
_efl_input_value_mark(ev, EFL_INPUT_VALUE_X);
ev->cur.x = axis->value;
break;
case EVAS_AXIS_LABEL_Y:
_efl_input_value_mark(ev, EFL_INPUT_VALUE_Y);
ev->cur.y = axis->value;
break;
case EVAS_AXIS_LABEL_PRESSURE:
_efl_input_value_mark(ev, EFL_INPUT_VALUE_PRESSURE);
ev->pressure = axis->value;
break;
case EVAS_AXIS_LABEL_DISTANCE:
case EVAS_AXIS_LABEL_AZIMUTH:
case EVAS_AXIS_LABEL_TILT:
case EVAS_AXIS_LABEL_TWIST:
// TODO
case EVAS_AXIS_LABEL_UNKNOWN:
case EVAS_AXIS_LABEL_TOUCH_WIDTH_MAJOR:
case EVAS_AXIS_LABEL_TOUCH_WIDTH_MINOR:
case EVAS_AXIS_LABEL_TOOL_WIDTH_MAJOR:
case EVAS_AXIS_LABEL_TOOL_WIDTH_MINOR:
default:
DBG("Unsupported axis label %d, value %f (discarded)",
axis->label, axis->value);
break;
}
}
_canvas_event_feed_axis_update_internal(e, ev);
efl_del(evt);
}
static void
@ -3215,6 +3268,10 @@ _evas_canvas_event_pointer_cb(void *data, const Eo_Event *event)
_canvas_event_feed_mouse_wheel_internal(eo_e, ev);
break;
case EFL_POINTER_ACTION_AXIS:
_canvas_event_feed_axis_update_internal(e, ev);
break;
default:
ERR("unsupported event type: %d", ev->action);
ev->evas_done = EINA_FALSE;
@ -3259,6 +3316,7 @@ EFL_CALLBACKS_ARRAY_DEFINE(_evas_canvas_event_pointer_callbacks,
{ EFL_EVENT_POINTER_OUT, _evas_canvas_event_pointer_cb },
{ EFL_EVENT_POINTER_CANCEL, _evas_canvas_event_pointer_cb },
{ EFL_EVENT_POINTER_WHEEL, _evas_canvas_event_pointer_cb },
{ EFL_EVENT_POINTER_AXIS, _evas_canvas_event_pointer_cb },
{ EFL_EVENT_KEY_DOWN, _evas_canvas_event_key_cb },
{ EFL_EVENT_KEY_UP, _evas_canvas_event_key_cb })

View File

@ -255,6 +255,40 @@ efl_event_pointer_legacy_info_fill(Efl_Event_Key *evt, Evas_Callback_Type type,
return e;
}
case EFL_POINTER_ACTION_AXIS:
{
TYPE_CHK(AXIS_UPDATE);
Evas_Event_Axis_Update *e = ev->legacy;
Evas_Axis *tmp_axis;
if (e && e->axis) free(e->axis);
e = _event_alloc(ev->legacy);
e->data = ev->data;
e->timestamp = ev->timestamp;
e->dev = ev->device;
/* FIXME: Get device id from above device object. 0 for now. */
e->device = 0;
e->toolid = ev->tool;
e->axis = malloc(sizeof(Evas_Axis) * 3);
e->axis[e->naxis].label = EVAS_AXIS_LABEL_X;
e->axis[e->naxis].value = ev->cur.x;
e->naxis++;
e->axis[e->naxis].label = EVAS_AXIS_LABEL_Y;
e->axis[e->naxis].value = ev->cur.y;
e->naxis++;
if (_efl_input_value_has(ev, EFL_INPUT_VALUE_PRESSURE))
{
e->axis[e->naxis].label = EVAS_AXIS_LABEL_PRESSURE;
e->axis[e->naxis].value = ev->pressure;
e->naxis++;
}
// TODO: distance, azimuth, tild, twist
tmp_axis = realloc(e->axis, e->naxis * sizeof(Evas_Axis));
if (tmp_axis) e->axis = tmp_axis;
if (pflags) *pflags = NULL;
ev->legacy = e;
return e;
}
default:
return NULL;
}