Evas: Extend pointer events and add legacy conversion routines

To be honest, this commit is a bit of a mess since it's a
rebased version of some temporary work patches.
This commit is contained in:
Jean-Philippe Andre 2016-05-10 21:26:07 +09:00
parent c06cdadca2
commit ea8c6e5632
11 changed files with 592 additions and 53 deletions

View File

@ -152,6 +152,7 @@ lib/evas/canvas/evas_common_interface.c \
lib/evas/canvas/evas_data.c \ lib/evas/canvas/evas_data.c \
lib/evas/canvas/evas_device.c \ lib/evas/canvas/evas_device.c \
lib/evas/canvas/evas_events.c \ lib/evas/canvas/evas_events.c \
lib/evas/canvas/evas_events_legacy.c \
lib/evas/canvas/evas_focus.c \ lib/evas/canvas/evas_focus.c \
lib/evas/canvas/evas_key.c \ lib/evas/canvas/evas_key.c \
lib/evas/canvas/evas_key_grab.c \ lib/evas/canvas/evas_key_grab.c \

View File

@ -23,19 +23,27 @@ typedef struct _Efl_Input_State_Data Efl_Input_State_Data;
//typedef struct _Evas_Lock Evas_Lock; //typedef struct _Evas_Lock Evas_Lock;
#endif #endif
struct _Efl_Input_State_Data
{
Eo *eo;
/* FIXME / TODO */
// Evas_Modifier *modifiers;
// Evas_Lock *locks;
};
struct _Efl_Pointer_Event_Data struct _Efl_Pointer_Event_Data
{ {
Eo *eo; Eo *eo;
unsigned int timestamp; /* FIXME: store as double? */ unsigned int timestamp; /* FIXME: store as double? */
int button; int button;
unsigned int pressed_buttons; unsigned int pressed_buttons;
int finger;
double radius, radius_x, radius_y;
double pressure;
double angle;
struct { struct {
struct { int x, y;
int x, y; double xsub, ysub; // couldn't we just cast from double to int?
} output;
struct {
int x, y;
} canvas;
} cur, prev; } cur, prev;
struct { struct {
Efl_Orient dir; Efl_Orient dir;
@ -48,17 +56,11 @@ struct _Efl_Pointer_Event_Data
Efl_Pointer_Event_Flags event_flags; Efl_Pointer_Event_Flags event_flags;
void *data; /* evas data - whatever that is */ void *data; /* evas data - whatever that is */
const Eo_Event_Description *event_desc; const Eo_Event_Description *event_desc;
//Efl_Input_State state; Eina_Bool window_pos; /* true if positions are window-relative
}; (see input vs. feed: this is "input") */
//Efl_Input_State *state;
struct _Efl_Input_State_Data void *legacy; /* DO NOT TOUCH */
{ Eina_Bool evas_done; /* set by evas */
Eo *eo;
/* FIXME / TODO */
#if 0
Evas_Modifier *modifiers;
Evas_Lock *locks;
#endif
}; };
struct _Efl_Input_Device_Data struct _Efl_Input_Device_Data

View File

@ -34,5 +34,8 @@ interface Efl.Event
type: const(Eo_Event_Description)*; type: const(Eo_Event_Description)*;
} }
} }
reset {
[[Resets the internal data to 0 or default values.]]
}
} }
} }

View File

@ -20,14 +20,77 @@
* Do not add any logic here. * Do not add any logic here.
*/ */
static Efl_Pointer_Event *s_cached_event = NULL;
static void
_del_hook(Eo *evt)
{
if (!s_cached_event)
{
if (eo_parent_get(evt))
{
eo_ref(evt);
eo_parent_set(evt, NULL);
}
s_cached_event = evt;
}
else
{
eo_del_intercept_set(evt, NULL);
eo_unref(evt);
}
}
EOLIAN static Efl_Pointer_Event *
_efl_pointer_event_instance_get(Eo_Class *klass EINA_UNUSED, void *pd EINA_UNUSED,
Eo *owner, void **priv)
{
Efl_Pointer_Event *evt;
if (s_cached_event)
{
evt = s_cached_event;
s_cached_event = NULL;
efl_event_reset(evt);
eo_parent_set(evt, owner);
}
else
{
evt = eo_add(EFL_POINTER_EVENT_CLASS, owner);
eo_del_intercept_set(evt, _del_hook);
}
if (priv)
*priv = eo_data_scope_get(evt, EFL_POINTER_EVENT_CLASS);
return evt;
}
EOLIAN static void
_efl_pointer_event_class_destructor(Eo_Class *klass EINA_UNUSED)
{
// this is a strange situation...
eo_unref(s_cached_event);
s_cached_event = NULL;
}
EOLIAN static Eo_Base * EOLIAN static Eo_Base *
_efl_pointer_event_eo_base_constructor(Eo *obj, Efl_Pointer_Event_Data *pd) _efl_pointer_event_eo_base_constructor(Eo *obj, Efl_Pointer_Event_Data *pd EINA_UNUSED)
{ {
eo_constructor(eo_super(obj, MY_CLASS)); eo_constructor(eo_super(obj, MY_CLASS));
pd->eo = obj; efl_event_reset(obj);
return obj; return obj;
} }
EOLIAN static void
_efl_pointer_event_efl_event_reset(Eo *obj, Efl_Pointer_Event_Data *pd)
{
free(pd->legacy);
memset(pd, 0, sizeof(*pd));
pd->eo = obj;
pd->wheel.dir = EFL_ORIENT_VERTICAL;
}
EOLIAN static void EOLIAN static void
_efl_pointer_event_action_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Efl_Pointer_Action act) _efl_pointer_event_action_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Efl_Pointer_Action act)
{ {
@ -72,37 +135,35 @@ _efl_pointer_event_button_pressed_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Dat
} }
EOLIAN static void EOLIAN static void
_efl_pointer_event_position_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int x, int y) _efl_pointer_event_position_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int x, int y, double xsub, double ysub)
{ {
pd->cur.canvas.x = x; pd->cur.x = x;
pd->cur.canvas.y = y; pd->cur.y = y;
/* FIXME: What is the difference??? */ pd->cur.xsub = xsub;
pd->cur.output.x = x; pd->cur.ysub = ysub;
pd->cur.output.y = y;
} }
EOLIAN static void EOLIAN static void
_efl_pointer_event_position_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int *x, int *y) _efl_pointer_event_position_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int *x, int *y, double *xsub, double *ysub)
{ {
if (x) *x = pd->cur.canvas.x; if (x) *x = pd->cur.x;
if (y) *y = pd->cur.canvas.y; if (y) *y = pd->cur.y;
if (xsub) *xsub = pd->cur.xsub;
if (ysub) *ysub = pd->cur.ysub;
} }
EOLIAN static void EOLIAN static void
_efl_pointer_event_previous_position_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int x, int y) _efl_pointer_event_previous_position_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int x, int y)
{ {
pd->prev.canvas.x = x; pd->prev.x = x;
pd->prev.canvas.y = y; pd->prev.y = y;
/* FIXME: What is the difference??? */
pd->prev.output.x = x;
pd->prev.output.y = y;
} }
EOLIAN static void EOLIAN static void
_efl_pointer_event_previous_position_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int *x, int *y) _efl_pointer_event_previous_position_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int *x, int *y)
{ {
if (x) *x = pd->prev.canvas.x; if (x) *x = pd->prev.x;
if (y) *y = pd->prev.canvas.y; if (y) *y = pd->prev.y;
} }
@ -219,4 +280,37 @@ _efl_pointer_event_wheel_distance_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Dat
return pd->wheel.z; return pd->wheel.z;
} }
EOLIAN static int
_efl_pointer_event_finger_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
{
return pd->finger;
}
EOLIAN static void
_efl_pointer_event_finger_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int id)
{
pd->finger = id;
}
EOLIAN static void
_efl_pointer_event_touch_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, double *r, double *rx, double *ry, double *press, double *angle)
{
if (r) *r = pd->radius;
if (rx) *rx = pd->radius_x;
if (ry) *ry = pd->radius_y;
if (press) *press = pd->pressure;
if (angle) *angle = pd->angle;
}
EOLIAN static void
_efl_pointer_event_touch_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, double r, double rx, double ry, double press, double angle)
{
pd->radius = r;
pd->radius_x = rx;
pd->radius_y = ry;
pd->pressure = press;
pd->angle = angle;
}
#include "interfaces/efl_pointer_event.eo.c" #include "interfaces/efl_pointer_event.eo.c"

View File

@ -7,7 +7,6 @@ class Efl.Pointer.Event (Eo.Base, Efl.Event)
@since 1.18 @since 1.18
]] ]]
legacy_prefix: null;
methods { methods {
@property action { @property action {
[[The action represented by this event.]] [[The action represented by this event.]]
@ -36,6 +35,8 @@ class Efl.Pointer.Event (Eo.Base, Efl.Event)
values { values {
x: int; x: int;
y: int; y: int;
xsub: double;
ysub: double;
} }
} }
@property previous_position { @property previous_position {
@ -63,6 +64,22 @@ class Efl.Pointer.Event (Eo.Base, Efl.Event)
dev: Efl.Input.Device; dev: Efl.Input.Device;
} }
} }
@property finger {
[[Finger ID in case of a multi touch event.]]
values {
id: int;
}
}
@property touch {
[[Touch information about a specific finger or pointer.]]
values {
radius: double;
rad_x: double;
rad_y: double;
pressure: double;
angle: double;
}
}
@property source { @property source {
[[The object where this event first originated, in case of [[The object where this event first originated, in case of
propagation or repetition of the event. propagation or repetition of the event.
@ -94,9 +111,21 @@ class Efl.Pointer.Event (Eo.Base, Efl.Event)
dist: int; dist: int;
} }
} }
instance_get @class {
[[Creates an instance of this events or returns a fresh one from
a memory pool.
]]
params {
@in owner: Eo.Base; [[The parent object.]]
@out priv: void*; [[Pointer to the internal data of the object.]]
}
return: own(Efl.Pointer.Event);
}
} }
implements { implements {
Eo.Base.constructor; Eo.Base.constructor;
class.destructor;
Efl.Event.reset;
Efl.Event.timestamp.set; Efl.Event.timestamp.set;
Efl.Event.timestamp.get; Efl.Event.timestamp.get;
Efl.Event.event_type.set; Efl.Event.event_type.set;

View File

@ -830,7 +830,7 @@ class Elm.Win (Elm.Widget, Elm.Interface.Atspi.Window,
name: const(char)* @nullable; name: const(char)* @nullable;
} }
} }
@property type { @property type { /* FIXME: before finalize */
[[The type of the window. [[The type of the window.
It is a hint of how the Window Manager should handle it. It is a hint of how the Window Manager should handle it.

View File

@ -410,8 +410,8 @@ class Evas.Canvas (Eo.Base, Evas.Common_Interface, Efl.Animator)
canvas. canvas.
When this function is called it will return a value of either When this function is called it will return a value of either
$false or $true, depending on if @.event_feed_mouse_in or $false or $true, depending on if $event_feed_mouse_in or
@.event_feed_mouse_out have been called to feed in a mouse $event_feed_mouse_out have been called to feed in a mouse
enter event into the canvas. enter event into the canvas.
A return value of $true indicates the mouse is logically A return value of $true indicates the mouse is logically
@ -504,7 +504,7 @@ class Evas.Canvas (Eo.Base, Evas.Common_Interface, Efl.Animator)
any host system's pointing device abilities. any host system's pointing device abilities.
A canvas by default begins with no mouse buttons being A canvas by default begins with no mouse buttons being
pressed and only calls to @.event_feed can alter that. pressed and only calls to $event_feed can alter that.
The least significant bit corresponds to the first mouse The least significant bit corresponds to the first mouse
button (button 1) and the most significant bit corresponds button (button 1) and the most significant bit corresponds
@ -1553,13 +1553,6 @@ class Evas.Canvas (Eo.Base, Evas.Common_Interface, Efl.Animator)
@in data: const(void)*; [[Data for canvas.]] @in data: const(void)*; [[Data for canvas.]]
} }
} }
event_feed {
[[Feed an input event.]]
legacy: null;
params {
event: const(Efl.Pointer.Event);
}
}
} }
implements { implements {
Eo.Base.constructor; Eo.Base.constructor;
@ -1580,5 +1573,6 @@ class Evas.Canvas (Eo.Base, Evas.Common_Interface, Efl.Animator)
device,changed; device,changed;
axis,update; axis,update;
viewport,resize; viewport,resize;
pointer;
} }
} }

View File

@ -1421,9 +1421,8 @@ evas_event_feed_mouse_wheel(Eo *eo_e, int direction, int z, unsigned int timesta
} }
static void static void
_canvas_event_feed_mouse_move_internal(Eo *eo_e, void *_pd, int x, int y, unsigned int timestamp, const void *data) _canvas_event_feed_mouse_move_internal(Eo *eo_e, Evas_Public_Data *e, int x, int y, unsigned int timestamp, const void *data)
{ {
Evas_Public_Data *e = _pd;
Evas_Object *nogrep_obj = NULL; Evas_Object *nogrep_obj = NULL;
int px, py; int px, py;
@ -3033,9 +3032,67 @@ _evas_canvas_event_down_count_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e)
return e->pointer.downs; return e->pointer.downs;
} }
EOLIAN void static Eina_Bool
_evas_canvas_event_feed(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const Efl_Pointer_Event *event) _evas_canvas_event_pointer_cb(void *data, const Eo_Event *event)
{ {
Efl_Pointer_Event_Data *ev = eo_data_scope_get(event, EFL_POINTER_EVENT_CLASS); Efl_Pointer_Event_Data *ev = eo_data_scope_get(event->info, EFL_POINTER_EVENT_CLASS);
/* TODO */ Evas_Public_Data *e = data;
Evas *eo_e = event->object;
if (!ev) return EO_CALLBACK_CONTINUE;
/* TODO:
* - pass event to the internal functions
* - implement legacy over oo instead of this
*/
switch (ev->action)
{
case EFL_POINTER_ACTION_MOUSE_MOVE:
if (ev->window_pos)
{
_canvas_event_feed_mouse_move_internal(eo_e, e,
ev->cur.x - e->framespace.x,
ev->cur.y - e->framespace.y,
ev->timestamp, ev->data);
}
else
{
_canvas_event_feed_mouse_move_internal(eo_e, e, ev->cur.x, ev->cur.y,
ev->timestamp, ev->data);
}
break;
case EFL_POINTER_ACTION_MOUSE_DOWN:
evas_event_feed_mouse_down(eo_e, ev->button, ev->button_flags, ev->timestamp, ev->data);
break;
case EFL_POINTER_ACTION_MOUSE_UP:
evas_event_feed_mouse_up(eo_e, ev->button, ev->button_flags, ev->timestamp, ev->data);
break;
case EFL_POINTER_ACTION_MOUSE_WHEEL:
evas_event_feed_mouse_wheel(eo_e,
(ev->wheel.dir == EFL_ORIENT_HORIZONTAL) ? 1 : 0,
ev->wheel.z, ev->timestamp, ev->data);
break;
default:
ERR("not implemented yet");
break;
}
return EO_CALLBACK_CONTINUE;
}
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);
}
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);
} }

View File

@ -0,0 +1,349 @@
#include "evas_common_private.h"
#include "evas_private.h"
#define EFL_INTERNAL_UNSTABLE
#include "interfaces/efl_common_internal.h"
Eina_Bool
efl_pointer_event_legacy_info_set(Efl_Pointer_Event *evt, const void *event_info, Evas_Callback_Type type)
{
Efl_Pointer_Event_Data *ev = eo_data_scope_get(evt, EFL_POINTER_EVENT_CLASS);
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!
switch (type)
{
//cse EVAS_CALLBACK_MOUSE_IN:
//case EVAS_CALLBACK_MOUSE_OUT:
case EVAS_CALLBACK_MOUSE_DOWN:
{
const Evas_Event_Mouse_Down *e = event_info;
ev->action = EFL_POINTER_ACTION_MOUSE_DOWN;
ev->button = e->button;
ev->cur.x = e->canvas.x;
ev->cur.y = e->canvas.y;
ev->cur.xsub = e->canvas.x;
ev->cur.ysub = e->canvas.y;
ev->data = e->data;
ev->button_flags = e->flags;
ev->timestamp = e->timestamp;
ev->event_flags = e->event_flags;
ev->device = e->dev;
ev->source = e->event_src;
break;
}
case EVAS_CALLBACK_MOUSE_UP:
{
const Evas_Event_Mouse_Up *e = event_info;
ev->action = EFL_POINTER_ACTION_MOUSE_UP;
ev->button = e->button;
ev->cur.x = e->canvas.x;
ev->cur.y = e->canvas.y;
ev->cur.xsub = e->canvas.x;
ev->cur.ysub = e->canvas.y;
ev->data = e->data;
ev->button_flags = e->flags;
ev->timestamp = e->timestamp;
ev->event_flags = e->event_flags;
ev->device = e->dev;
ev->source = e->event_src;
break;
}
case EVAS_CALLBACK_MOUSE_MOVE:
{
const Evas_Event_Mouse_Move *e = event_info;
ev->action = EFL_POINTER_ACTION_MOUSE_MOVE;
ev->pressed_buttons = e->buttons;
ev->cur.x = e->cur.canvas.x;
ev->cur.y = e->cur.canvas.y;
ev->cur.xsub = e->cur.canvas.x;
ev->cur.ysub = e->cur.canvas.y;
ev->prev.x = e->prev.canvas.x;
ev->prev.y = e->prev.canvas.y;
ev->prev.xsub = e->prev.canvas.x;
ev->prev.ysub = e->prev.canvas.y;
ev->data = e->data;
ev->timestamp = e->timestamp;
ev->event_flags = e->event_flags;
ev->device = e->dev;
ev->source = e->event_src;
break;
}
case EVAS_CALLBACK_MOUSE_WHEEL:
{
const Evas_Event_Mouse_Wheel *e = event_info;
ev->action = EFL_POINTER_ACTION_MOUSE_WHEEL;
ev->wheel.dir = (e->direction ? EFL_ORIENT_HORIZONTAL : EFL_ORIENT_VERTICAL);
ev->wheel.z = e->z;
ev->cur.x = e->canvas.x;
ev->cur.y = e->canvas.y;
ev->cur.xsub = e->canvas.x;
ev->cur.ysub = e->canvas.y;
ev->data = e->data;
ev->timestamp = e->timestamp;
ev->event_flags = e->event_flags;
ev->device = e->dev;
break;
}
case EVAS_CALLBACK_MULTI_DOWN:
{
const Evas_Event_Multi_Down *e = event_info;
ev->action = EFL_POINTER_ACTION_MOUSE_DOWN; // TOUCH DOWN???
ev->finger = e->device;
ev->radius = e->radius;
ev->radius_x = e->radius_x;
ev->radius_y = e->radius_y;
ev->pressure = e->pressure;
ev->angle = e->angle;
ev->cur.x = e->canvas.x;
ev->cur.y = e->canvas.y;
ev->cur.xsub = e->canvas.xsub;
ev->cur.ysub = e->canvas.ysub;
ev->data = e->data;
ev->button_flags = e->flags;
ev->timestamp = e->timestamp;
ev->event_flags = e->event_flags;
ev->device = e->dev;
break;
}
case EVAS_CALLBACK_MULTI_UP:
{
const Evas_Event_Multi_Up *e = event_info;
ev->action = EFL_POINTER_ACTION_MOUSE_UP;
ev->finger = e->device;
ev->radius = e->radius;
ev->radius_x = e->radius_x;
ev->radius_y = e->radius_y;
ev->pressure = e->pressure;
ev->angle = e->angle;
ev->cur.x = e->canvas.x;
ev->cur.y = e->canvas.y;
ev->cur.xsub = e->canvas.xsub;
ev->cur.ysub = e->canvas.ysub;
ev->data = e->data;
ev->button_flags = e->flags;
ev->timestamp = e->timestamp;
ev->event_flags = e->event_flags;
ev->device = e->dev;
break;
}
case EVAS_CALLBACK_MULTI_MOVE:
{
const Evas_Event_Multi_Move *e = event_info;
ev->action = EFL_POINTER_ACTION_MOUSE_MOVE;
ev->finger = e->device;
ev->radius = e->radius;
ev->radius_x = e->radius_x;
ev->radius_y = e->radius_y;
ev->pressure = e->pressure;
ev->angle = e->angle;
ev->cur.x = e->cur.canvas.x;
ev->cur.y = e->cur.canvas.y;
ev->cur.xsub = e->cur.canvas.xsub;
ev->cur.ysub = e->cur.canvas.ysub;
ev->data = e->data;
ev->timestamp = e->timestamp;
ev->event_flags = e->event_flags;
ev->device = e->dev;
break;
}
default:
ERR("invalid event type %d", type);
return EINA_FALSE;
}
return EINA_TRUE;
}
const void *
efl_pointer_event_legacy_info_get(const Efl_Pointer_Event *evt, Evas_Callback_Type *ptype, Eina_Bool multi)
{
Efl_Pointer_Event_Data *ev = eo_data_scope_get(evt, EFL_POINTER_EVENT_CLASS);
if (!ev) return NULL;
switch (ev->action)
{
case EFL_POINTER_ACTION_MOUSE_DOWN:
if (!ev->finger || !multi)
{
Evas_Event_Mouse_Down *e = calloc(1, sizeof(*e));
if (ptype) *ptype = EVAS_CALLBACK_MOUSE_DOWN;
ev->legacy = e;
e->button = ev->button;
e->canvas.x = ev->cur.x;
e->canvas.y = ev->cur.y;
e->output.x = ev->cur.x;
e->output.y = ev->cur.y;
e->data = ev->data;
e->flags = ev->button_flags;
e->timestamp = ev->timestamp;
e->event_flags = ev->event_flags;
e->dev = ev->device;
e->event_src = ev->source;
}
else
{
Evas_Event_Multi_Down *e = calloc(1, sizeof(*e));
if (ptype) *ptype = EVAS_CALLBACK_MULTI_DOWN;
ev->legacy = e;
e->device = ev->finger;
e->radius = ev->radius;
e->radius_x = ev->radius_x;
e->radius_y = ev->radius_y;
e->pressure = ev->pressure;
e->angle = ev->angle;
e->canvas.x = ev->cur.x;
e->canvas.y = ev->cur.y;
e->canvas.xsub = ev->cur.xsub;
e->canvas.ysub = ev->cur.ysub;
e->output.x = ev->cur.x;
e->output.y = ev->cur.y;
e->data = ev->data;
e->flags = ev->button_flags;
e->timestamp = ev->timestamp;
e->event_flags = ev->event_flags;
e->dev = ev->device;
}
break;
case EFL_POINTER_ACTION_MOUSE_UP:
if (!ev->finger || !multi)
{
Evas_Event_Mouse_Up *e = calloc(1, sizeof(*e));
if (ptype) *ptype = EVAS_CALLBACK_MOUSE_UP;
ev->legacy = e;
e->button = ev->button;
e->canvas.x = ev->cur.x;
e->canvas.y = ev->cur.y;
e->output.x = ev->cur.x;
e->output.y = ev->cur.y;
e->data = ev->data;
e->flags = ev->button_flags;
e->timestamp = ev->timestamp;
e->event_flags = ev->event_flags;
e->dev = ev->device;
e->event_src = ev->source;
}
else
{
Evas_Event_Multi_Down *e = calloc(1, sizeof(*e));
if (ptype) *ptype = EVAS_CALLBACK_MULTI_UP;
ev->legacy = e;
e->device = ev->finger;
e->radius = ev->radius;
e->radius_x = ev->radius_x;
e->radius_y = ev->radius_y;
e->pressure = ev->pressure;
e->angle = ev->angle;
e->canvas.x = ev->cur.x;
e->canvas.y = ev->cur.y;
e->canvas.xsub = ev->cur.xsub;
e->canvas.ysub = ev->cur.ysub;
e->output.x = ev->cur.x;
e->output.y = ev->cur.y;
e->data = ev->data;
e->flags = ev->button_flags;
e->timestamp = ev->timestamp;
e->event_flags = ev->event_flags;
e->dev = ev->device;
break;
}
break;
case EFL_POINTER_ACTION_MOUSE_MOVE:
if (!ev->finger || !multi)
{
Evas_Event_Mouse_Move *e = calloc(1, sizeof(*e));
if (ptype) *ptype = EVAS_CALLBACK_MOUSE_MOVE;
ev->legacy = e;
e->buttons = ev->pressed_buttons;
e->cur.canvas.x = ev->cur.x;
e->cur.canvas.y = ev->cur.y;
e->cur.output.x = ev->cur.x;
e->cur.output.y = ev->cur.y;
e->prev.canvas.x = ev->prev.x;
e->prev.canvas.y = ev->prev.y;
e->prev.output.x = ev->prev.x;
e->prev.output.y = ev->prev.y;
e->data = ev->data;
e->timestamp = ev->timestamp;
e->event_flags = ev->event_flags;
e->dev = ev->device;
e->event_src = ev->source;
}
else
{
Evas_Event_Multi_Move *e = calloc(1, sizeof(*e));
if (ptype) *ptype = EVAS_CALLBACK_MULTI_MOVE;
ev->legacy = e;
e->device = ev->finger;
e->radius = ev->radius;
e->radius_x = ev->radius_x;
e->radius_y = ev->radius_y;
e->pressure = ev->pressure;
e->angle = ev->angle;
e->cur.canvas.x = ev->cur.x;
e->cur.canvas.y = ev->cur.y;
e->cur.canvas.xsub = ev->cur.xsub;
e->cur.canvas.ysub = ev->cur.ysub;
e->cur.output.x = ev->cur.x;
e->cur.output.y = ev->cur.y;
e->data = ev->data;
e->timestamp = ev->timestamp;
e->event_flags = ev->event_flags;
e->dev = ev->device;
}
break;
case EFL_POINTER_ACTION_MOUSE_WHEEL:
{
Evas_Event_Mouse_Wheel *e = calloc(1, sizeof(*e));
if (ptype) *ptype = EVAS_CALLBACK_MOUSE_WHEEL;
ev->legacy = e;
e->direction = (ev->wheel.dir == EFL_ORIENT_VERTICAL);
e->z = ev->wheel.z;
e->canvas.x = ev->cur.x;
e->canvas.y = ev->cur.y;
e->output.x = ev->cur.x;
e->output.y = ev->cur.y;
e->data = ev->data;
e->timestamp = ev->timestamp;
e->event_flags = ev->event_flags;
e->dev = ev->device;
break;
}
default:
ERR("invalid event type %d", ev->action);
return NULL;
}
return ev->legacy;
}

View File

@ -199,6 +199,8 @@ _evas_canvas_eo_base_constructor(Eo *eo_obj, Evas_Public_Data *e)
eina_lock_new(&(e->lock_objects)); eina_lock_new(&(e->lock_objects));
eina_spinlock_new(&(e->render.lock)); eina_spinlock_new(&(e->render.lock));
_evas_canvas_event_init(eo_obj, e);
return eo_obj; return eo_obj;
} }
@ -230,6 +232,7 @@ _evas_canvas_eo_base_destructor(Eo *eo_e, Evas_Public_Data *e)
evas_render_idle_flush(eo_e); evas_render_idle_flush(eo_e);
_evas_post_event_callback_free(eo_e); _evas_post_event_callback_free(eo_e);
_evas_canvas_event_shutdown(eo_e, e);
del = EINA_TRUE; del = EINA_TRUE;
e->walking_list++; e->walking_list++;

View File

@ -1881,6 +1881,9 @@ struct _Evas_Proxy_Render_Data
Eina_Bool source_clip : 1; Eina_Bool source_clip : 1;
}; };
void _evas_canvas_event_init(Evas *eo_e, Evas_Public_Data *e);
void _evas_canvas_event_shutdown(Evas *eo_e, Evas_Public_Data *e);
int evas_async_events_init(void); int evas_async_events_init(void);
int evas_async_events_shutdown(void); int evas_async_events_shutdown(void);
int evas_async_target_del(const void *target); int evas_async_target_del(const void *target);
@ -1933,6 +1936,10 @@ void _evas_touch_point_remove(Evas *e, int id);
void _evas_device_cleanup(Evas *e); void _evas_device_cleanup(Evas *e);
Evas_Device *_evas_device_top_get(const Evas *e); Evas_Device *_evas_device_top_get(const Evas *e);
/* legacy/eo events */
Eina_Bool efl_pointer_event_legacy_info_set(Efl_Pointer_Event *evt, const void *event_info, Evas_Callback_Type type);
const void *efl_pointer_event_legacy_info_get(const Efl_Pointer_Event *evt, Evas_Callback_Type *ptype, Eina_Bool multi);
Eina_Bool evas_vg_loader_svg(Evas_Object *vg, const Eina_File *f, const char *key EINA_UNUSED); Eina_Bool evas_vg_loader_svg(Evas_Object *vg, const Eina_File *f, const char *key EINA_UNUSED);
void *_evas_object_image_surface_get(Evas_Object *eo, Evas_Object_Protected_Data *obj); void *_evas_object_image_surface_get(Evas_Object *eo, Evas_Object_Protected_Data *obj);