Evas events: Split pointer events

This is going back to the same idea as legacy. We will have
events such as:
- move
- down
- up
- in
- out
- wheel
- cancel ("new" - very rare)

Now the question is whether/how we should divide "multi" events
which start from the 2nd finger from standard mouse events. The first
multitouch finger should by default look like a mouse event.
This commit is contained in:
Jean-Philippe Andre 2016-05-30 20:53:07 +09:00
parent 1950fb6fde
commit 0a27c78a33
13 changed files with 90 additions and 47 deletions

View File

@ -40,6 +40,7 @@ efl_eolian_files = \
lib/efl/interfaces/efl_ui_spin.eo \
lib/efl/interfaces/efl_ui_progress.eo \
lib/efl/interfaces/efl_event.eo \
lib/efl/interfaces/efl_input_interface.eo \
lib/efl/interfaces/efl_input_state.eo \
$(efl_eolian_legacy_files) \
$(NULL)

View File

@ -4314,6 +4314,29 @@ _pointer_position_set(Efl_Pointer_Event_Data *ev, Ecore_Evas *ee, int x, int y,
EVENT_XY_SET(ev, y, ee->w + fh - x - 1, y, ee->w + fh - mx - 1, fx, fy);
}
static const Eo_Event_Description *
_event_description_get(Efl_Pointer_Action action)
{
switch (action)
{
case EFL_POINTER_ACTION_MOVE:
return EFL_EVENT_POINTER_MOVE;
case EFL_POINTER_ACTION_DOWN:
return EFL_EVENT_POINTER_DOWN;
case EFL_POINTER_ACTION_UP:
return EFL_EVENT_POINTER_UP;
case EFL_POINTER_ACTION_CANCEL:
return EFL_EVENT_POINTER_CANCEL;
case EFL_POINTER_ACTION_IN:
return EFL_EVENT_POINTER_IN;
case EFL_POINTER_ACTION_OUT:
return EFL_EVENT_POINTER_OUT;
case EFL_POINTER_ACTION_WHEEL:
return EFL_EVENT_POINTER_WHEEL;
default: return NULL;
}
}
static Eina_Bool
_direct_mouse_updown(Ecore_Evas *ee, const Ecore_Event_Mouse_Button *info, Efl_Pointer_Action action)
{
@ -4347,7 +4370,7 @@ _direct_mouse_updown(Ecore_Evas *ee, const Ecore_Event_Mouse_Button *info, Efl_P
ev->pressure = info->multi.pressure;
ev->angle = info->multi.angle - ee->rotation;
eo_event_callback_call(e, EVAS_CANVAS_EVENT_POINTER, evt);
eo_event_callback_call(e, _event_description_get(ev->action), evt);
processed = ev->evas_done;
eo_unref(evt);
@ -4403,7 +4426,7 @@ _direct_mouse_move_cb(Ecore_Evas *ee, const Ecore_Event_Mouse_Move *info)
ev->pressure = info->multi.pressure;
ev->angle = info->multi.angle - ee->rotation;
eo_event_callback_call(e, EVAS_CANVAS_EVENT_POINTER, evt);
eo_event_callback_call(e, _event_description_get(ev->action), evt);
processed = ev->evas_done;
eo_unref(evt);
@ -4435,7 +4458,7 @@ _direct_mouse_wheel_cb(Ecore_Evas *ee, const Ecore_Event_Mouse_Wheel *info)
ev->wheel.z = info->z;
ev->wheel.dir = info->direction ? EFL_ORIENT_HORIZONTAL : EFL_ORIENT_VERTICAL;
eo_event_callback_call(e, EVAS_CANVAS_EVENT_POINTER, evt);
eo_event_callback_call(e, _event_description_get(ev->action), evt);
processed = ev->evas_done;
eo_unref(evt);
@ -4462,7 +4485,7 @@ _direct_mouse_inout(Ecore_Evas *ee, const Ecore_Event_Mouse_IO *info, Efl_Pointe
ev->timestamp = info->timestamp;
_pointer_position_set(ev, ee, info->x, info->y, info->x, info->y);
eo_event_callback_call(e, EVAS_CANVAS_EVENT_POINTER, evt);
eo_event_callback_call(e, _event_description_get(ev->action), evt);
processed = ev->evas_done;
eo_unref(evt);

View File

@ -129,6 +129,7 @@ static inline void efl_gfx_color16_type_set(Efl_Gfx_Color *color,
#include "interfaces/efl_event_types.eot.h"
#include "interfaces/efl_input_device.eo.h"
#include "interfaces/efl_input_state.eo.h"
#include "interfaces/efl_input_interface.eo.h"
#include "interfaces/efl_event.eo.h"
#else

View File

@ -123,8 +123,4 @@ interface Efl.Gfx {
}
}
}
events {
/* FIXME: eolian thinks there's a cyclic dependency here. wtf */
pointer /*: Efl.Pointer.Event*/; [[New generic pointer (mouse, finger, pen...) event.]]
}
}

View File

@ -0,0 +1,17 @@
interface Efl.Input.Interface ()
{
[[An object implementing this interface can send pointer events.
Windows and canvas objects may send input events.
]]
event_prefix: efl;
events {
pointer,move: Efl.Pointer.Event;
pointer,down: Efl.Pointer.Event;
pointer,up: Efl.Pointer.Event;
pointer,cancel: Efl.Pointer.Event;
pointer,in: Efl.Pointer.Event;
pointer,out: Efl.Pointer.Event;
pointer,wheel: Efl.Pointer.Event;
}
}

View File

@ -50,6 +50,7 @@ EAPI const Eo_Event_Description _EFL_GFX_PATH_CHANGED =
#include "interfaces/efl_event.eo.c"
#include "interfaces/efl_input_state.eo.c"
#include "interfaces/efl_input_interface.eo.c"
EAPI void
__efl_internal_init(void)

View File

@ -1631,12 +1631,18 @@ _evas_event_pointer_cb(void *data, const Eo_Event *ev)
Eo *win = data;
Eo *evt = ev->info;
eo_event_callback_call(win, EFL_GFX_EVENT_POINTER, evt);
eo_event_callback_call(win, ev->desc, evt);
return EO_CALLBACK_CONTINUE;
}
EO_CALLBACKS_ARRAY_DEFINE(_elm_win_evas_forward_callbacks,
{ EVAS_CANVAS_EVENT_POINTER, _evas_event_pointer_cb })
{ EFL_EVENT_POINTER_MOVE, _evas_event_pointer_cb },
{ EFL_EVENT_POINTER_DOWN, _evas_event_pointer_cb },
{ EFL_EVENT_POINTER_UP, _evas_event_pointer_cb },
{ EFL_EVENT_POINTER_IN, _evas_event_pointer_cb },
{ EFL_EVENT_POINTER_OUT, _evas_event_pointer_cb },
{ EFL_EVENT_POINTER_CANCEL, _evas_event_pointer_cb },
{ EFL_EVENT_POINTER_WHEEL, _evas_event_pointer_cb })
static void
_deferred_ecore_evas_free(void *data)

View File

@ -150,7 +150,7 @@ enum Elm.Illume_Command
class Elm.Win (Elm.Widget, Elm.Interface.Atspi.Window,
Elm.Interface.Atspi_Widget_Action, Efl.Pack,
Efl.Input.State)
Efl.Input.State, Efl.Input.Interface)
{
legacy_prefix: elm_win;
eo_prefix: elm_obj_win;

View File

@ -59,25 +59,28 @@ typedef struct
} _eo_evas_object_cb_info;
static inline void *
_pointer_event_get(const _eo_evas_object_cb_info *info, const Eo_Event *event)
_pointer_event_get(const _eo_evas_object_cb_info *info, const Eo_Event *event,
const Eo_Event_Description **pdesc)
{
if (!info->data) return NULL;
/* See also evas_events.c: _pointer_event_create() */
#define EV_CASE(TYPE, Type) \
case EVAS_CALLBACK_ ## TYPE: return ((Evas_Event_ ## Type *) event->info)->reserved
#define EV_CASE(TYPE, NEWTYPE, Type) \
case EVAS_CALLBACK_ ## TYPE: \
*pdesc = EFL_EVENT_POINTER_ ## NEWTYPE; \
return ((Evas_Event_ ## Type *) event->info)->reserved
switch (info->type)
{
EV_CASE(MOUSE_MOVE, Mouse_Move);
EV_CASE(MOUSE_OUT, Mouse_Out);
EV_CASE(MOUSE_IN, Mouse_In);
EV_CASE(MOUSE_DOWN, Mouse_Down);
EV_CASE(MOUSE_UP, Mouse_Up);
EV_CASE(MULTI_MOVE, Multi_Move);
EV_CASE(MULTI_DOWN, Multi_Down);
EV_CASE(MULTI_UP, Multi_Up);
EV_CASE(MOUSE_WHEEL, Mouse_Wheel);
EV_CASE(MOUSE_MOVE, MOVE, Mouse_Move);
EV_CASE(MOUSE_OUT, OUT, Mouse_Out);
EV_CASE(MOUSE_IN, IN, Mouse_In);
EV_CASE(MOUSE_DOWN, DOWN, Mouse_Down);
EV_CASE(MOUSE_UP, UP, Mouse_Up);
EV_CASE(MULTI_MOVE, MOVE, Multi_Move);
EV_CASE(MULTI_DOWN, DOWN, Multi_Down);
EV_CASE(MULTI_UP, UP, Multi_Up);
EV_CASE(MOUSE_WHEEL, WHEEL, Mouse_Wheel);
default: return NULL;
}
#undef EV_CASE
@ -88,12 +91,9 @@ static Eina_Bool
_eo_evas_object_cb(void *data, const Eo_Event *event)
{
_eo_evas_object_cb_info *info = data;
void *pe = _pointer_event_get(info, event);
if (pe)
{
DBG("triggering eo pointer event!");
eo_event_callback_call(event->object, EFL_GFX_EVENT_POINTER, pe);
}
const Eo_Event_Description *desc;
void *pe = _pointer_event_get(info, event, &desc);
if (pe) eo_event_callback_call(event->object, desc, pe);
if (info->func) info->func(info->data, evas_object_evas_get(event->object), event->object, event->info);
return EINA_TRUE;
}

View File

@ -1,7 +1,8 @@
import evas_types;
import efl_event_types;
class Evas.Canvas (Eo.Base, Evas.Common_Interface, Efl.Animator)
class Evas.Canvas (Eo.Base, Evas.Common_Interface, Efl.Animator,
Efl.Input.Interface)
{
legacy_prefix: evas;
data: Evas_Public_Data;
@ -1327,6 +1328,5 @@ class Evas.Canvas (Eo.Base, Evas.Common_Interface, Efl.Animator)
device,changed;
axis,update;
viewport,resize;
pointer: Efl.Pointer.Event; [[Generic pointer event (mouse, finger...)]]
}
}

View File

@ -3190,10 +3190,6 @@ _evas_canvas_event_pointer_cb(void *data, const Eo_Event *event)
if (!ev) return EO_CALLBACK_CONTINUE;
/* TODO:
* - implement legacy over eo instead of this (hardcore)
*/
ev->evas_done = EINA_TRUE;
ev->modifiers = &e->modifiers;
ev->locks = &e->locks;
@ -3272,14 +3268,23 @@ _evas_canvas_event_pointer_cb(void *data, const Eo_Event *event)
return EO_CALLBACK_CONTINUE;
}
EO_CALLBACKS_ARRAY_DEFINE(_evas_canvas_event_pointer_callbacks,
{ EFL_EVENT_POINTER_MOVE, _evas_canvas_event_pointer_cb },
{ EFL_EVENT_POINTER_DOWN, _evas_canvas_event_pointer_cb },
{ EFL_EVENT_POINTER_UP, _evas_canvas_event_pointer_cb },
{ EFL_EVENT_POINTER_IN, _evas_canvas_event_pointer_cb },
{ 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 })
void
_evas_canvas_event_init(Evas *eo_e, Evas_Public_Data *e)
{
eo_event_callback_add(eo_e, EVAS_CANVAS_EVENT_POINTER, _evas_canvas_event_pointer_cb, e);
eo_event_callback_array_add(eo_e, _evas_canvas_event_pointer_callbacks(), e);
}
void
_evas_canvas_event_shutdown(Evas *eo_e, Evas_Public_Data *e)
{
eo_event_callback_del(eo_e, EVAS_CANVAS_EVENT_POINTER, _evas_canvas_event_pointer_cb, e);
eo_event_callback_array_del(eo_e, _evas_canvas_event_pointer_callbacks(), e);
}

View File

@ -11,19 +11,10 @@ efl_pointer_event_legacy_info_set(Efl_Pointer_Event *evt, const void *event_info
if (!ev || !event_info) return EINA_FALSE;
/* FIXME/TODO:
*
* Some things that are not supported or should be eo-ified somehow
*
* 1. Lock
* 2. Modifiers
* 3. data
*
* Some events definitely don't have all the info they could have. Need
* to get it from ecore!
*/
#warning Modifiers and locks not supported yet - very bad!
#if defined(DEBUG)
# define CHKACT(a) do { if (evdata->action != EFL_POINTER_ACTION_ ## a) abort(); } while (0)
#else

View File

@ -1,6 +1,7 @@
import evas_types;
abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx, Efl.Gfx.Stack, Efl.Animator)
abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx, Efl.Gfx.Stack,
Efl.Animator, Efl.Input.Interface)
{
legacy_prefix: evas_object;
eo_prefix: evas_obj;
@ -1247,6 +1248,7 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx, Efl.Gfx.Stack, Ef
Efl.Gfx.Stack.lower;
}
events {
/* FIXME: remove events from Efl.Input.Interface */
mouse,in; [[Mouse In Event ]]
mouse,out; [[Mouse Out Event ]]
mouse,down; [[Mouse Button Down Event ]]