From: EunMi Lee <eunmi15.lee@samsung.com>

Subject: [E-devel] [Patch] [Evas] Patch to provide information of
touched points

Hello,
I made a new patch to get information of current touched point instead
of Touch Event.

I added touch_points (Eina_List) to the Evas structure and it maintains touched points on the evas.
New touched point is added to the touch_points when we get Mouse_Down and Multi_Down,
touched point is updated when we get Mouse_Move and Mult_Move,
and touched point is removed when we get Mouse_Up and Multi_Up.

The each touch point has coordinate, id and state information as follows:
id - identifier. 0 for Mouse Event and device id for Multi Event. coordinate - (x, y) coordinate of point.
state - state of point. type is Evas_Touch_Point_State enum.
(EVAS_TOUCH_POINT_DOWN, EVAS_TOUCH_POINT_UP, EVAS_TOUCH_POINT_MOVE,
EVAS_TOUCH_POINT_STILL, EVAS_TOUCH_POINT_CANCEL)

There are 4 new APIs to get touch point's information as follows:
unsigned int evas_touch_point_list_count(Evas *e);
void evas_touch_point_list_nth_xy_get(Evas *e, unsigned int n, Evas_Coord *x, Evas_Coord *y);
int evas_touch_point_list_nth_id_get(Evas *e, unsigned int n);
Evas_Touch_Point_State evas_touch_point_list_nth_state_get(Evas *e, unsigned int n);

I added APIs to get each information instead of exposing whole
structure to make it easy to expand in the future as you mentioned in
the below e-mail :)



SVN revision: 64373
This commit is contained in:
EunMi Lee 2011-10-25 05:03:50 +00:00 committed by Carsten Haitzler
parent 8658d955ce
commit 8b5d185038
6 changed files with 298 additions and 0 deletions

View File

@ -487,6 +487,18 @@ typedef enum _Evas_Event_Flags
EVAS_EVENT_FLAG_ON_SCROLL = (1 << 1) /**< This event flag indicates the event occurs while scrolling; for exameple, DOWN event occurs during scrolling; the event should be used for informational purposes and maybe some indications visually, but not actually perform anything */
} Evas_Event_Flags; /**< Flags for Events */
/**
* State of Evas_Coord_Touch_Point
*/
typedef enum _Evas_Touch_Point_State
{
EVAS_TOUCH_POINT_DOWN, /**< Touch point is pressed down */
EVAS_TOUCH_POINT_UP, /**< Touch point is released */
EVAS_TOUCH_POINT_MOVE, /**< Touch point is moved */
EVAS_TOUCH_POINT_STILL, /**< Touch point is not moved after pressed */
EVAS_TOUCH_POINT_CANCEL /**< Touch point is calcelled */
} Evas_Touch_Point_State;
/**
* Flags for Font Hinting
* @ingroup Evas_Font_Group
@ -12035,6 +12047,141 @@ EAPI Eina_Bool evas_object_key_grab (Evas_Object *obj, cons
*/
EAPI void evas_object_key_ungrab (Evas_Object *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers) EINA_ARG_NONNULL(1, 2);
/**
* @}
*/
/**
* @defgroup Evas_Touch_Point_List Touch Point List Functions
*
* Functions to get information of touched points in the Evas.
*
* Evas maintains list of touched points on the canvas. Each point has
* its co-ordinates, id and state. You can get the number of touched
* points and information of each point using evas_touch_point_list
* functions.
*
* @ingroup Evas_Canvas
*/
/**
* @addtogroup Evas_Touch_Point_List
* @{
*/
/**
* Get the number of touched point in the evas.
*
* @param e The pointer to the Evas canvas.
* @return The number of touched point on the evas.
*
* New touched point is added to the list whenever touching the evas
* and point is removed whenever removing touched point from the evas.
*
* Example:
* @code
* extern Evas *evas;
* int count;
*
* count = evas_touch_point_list_count(evas);
* printf("The count of touch points: %i\n", count);
* @endcode
*
* @see evas_touch_point_list_nth_xy_get()
* @see evas_touch_point_list_nth_id_get()
* @see evas_touch_point_list_nth_state_get()
*/
EAPI unsigned int evas_touch_point_list_count(Evas *e) EINA_ARG_NONNULL(1);
/**
* This function returns the nth touch point's co-ordinates.
*
* @param e The pointer to the Evas canvas.
* @param n The number of the touched point (0 being the first).
* @param x The pointer to a Evas_Coord to be filled in.
* @param y The pointer to a Evas_Coord to be filled in.
*
* Touch point's co-ordinates is updated whenever moving that point
* on the canvas.
*
* Example:
* @code
* extern Evas *evas;
* Evas_Coord x, y;
*
* if (evas_touch_point_list_count(evas))
* {
* evas_touch_point_nth_xy_get(evas, 0, &x, &y);
* printf("The first touch point's co-ordinate: (%i, %i)\n", x, y);
* }
* @endcode
*
* @see evas_touch_point_list_count()
* @see evas_touch_point_list_nth_id_get()
* @see evas_touch_point_list_nth_state_get()
*/
EAPI void evas_touch_point_list_nth_xy_get(Evas *e, unsigned int n, Evas_Coord *x, Evas_Coord *y) EINA_ARG_NONNULL(1);
/**
* This function returns the @p id of nth touch point.
*
* @param e The pointer to the Evas canvas.
* @param n The number of the touched point (0 being the first).
* @return id of nth touch point, if the call succeeded, -1 otherwise.
*
* The point which comes from Mouse Event has @p id 0 and The point
* which comes from Multi Event has @p id that is same as Multi
* Event's device id.
*
* Example:
* @code
* extern Evas *evas;
* int id;
*
* if (evas_touch_point_list_count(evas))
* {
* id = evas_touch_point_nth_id_get(evas, 0);
* printf("The first touch point's id: %i\n", id);
* }
* @endcode
*
* @see evas_touch_point_list_count()
* @see evas_touch_point_list_nth_xy_get()
* @see evas_touch_point_list_nth_state_get()
*/
EAPI int evas_touch_point_list_nth_id_get(Evas *e, unsigned int n) EINA_ARG_NONNULL(1);
/**
* This function returns the @p state of nth touch point.
*
* @param e The pointer to the Evas canvas.
* @param n The number of the touched point (0 being the first).
* @return @p state of nth touch point, if the call succeeded,
* EVAS_TOUCH_POINT_CANCEL otherwise.
*
* The point's @p state is EVAS_TOUCH_POINT_DOWN when pressed,
* EVAS_TOUCH_POINT_STILL when the point is not moved after pressed,
* EVAS_TOUCH_POINT_MOVE when moved at least once after pressed and
* EVAS_TOUCH_POINT_UP when released.
*
* Example:
* @code
* extern Evas *evas;
* Evas_Touch_Point_State state;
*
* if (evas_touch_point_list_count(evas))
* {
* state = evas_touch_point_nth_state_get(evas, 0);
* printf("The first touch point's state: %i\n", state);
* }
* @endcode
*
* @see evas_touch_point_list_count()
* @see evas_touch_point_list_nth_xy_get()
* @see evas_touch_point_list_nth_id_get()
*/
EAPI Evas_Touch_Point_State evas_touch_point_list_nth_state_get(Evas *e, unsigned int n) EINA_ARG_NONNULL(1);
/**
* @}
*/

View File

@ -51,6 +51,7 @@ evas_smart.c \
evas_stack.c \
evas_async_events.c \
evas_stats.c \
evas_touch_point.c \
evas_map.c \
evas_gl.c

View File

@ -223,6 +223,8 @@ evas_event_feed_mouse_down(Evas *e, int b, Evas_Button_Flags flags, unsigned int
ev.event_flags = EVAS_EVENT_FLAG_NONE;
_evas_walk(e);
/* append new touch point to the touch point list */
_evas_touch_point_append(e, 0, e->pointer.x, e->pointer.y);
/* If this is the first finger down, i.e no other fingers pressed,
* get a new event list, otherwise, keep the current grabbed list. */
if (e->pointer.mouse_grabbed == 0)
@ -258,6 +260,8 @@ evas_event_feed_mouse_down(Evas *e, int b, Evas_Button_Flags flags, unsigned int
if (copy) eina_list_free(copy);
e->last_mouse_down_counter++;
_evas_post_event_callback_call(e);
/* update touch point's state to EVAS_TOUCH_POINT_STILL */
_evas_touch_point_update(e, 0, e->pointer.x, e->pointer.y, EVAS_TOUCH_POINT_STILL);
_evas_unwalk(e);
}
@ -400,6 +404,8 @@ evas_event_feed_mouse_up(Evas *e, int b, Evas_Button_Flags flags, unsigned int t
ev.event_flags = EVAS_EVENT_FLAG_NONE;
_evas_walk(e);
/* update released touch point */
_evas_touch_point_update(e, 0, e->pointer.x, e->pointer.y, EVAS_TOUCH_POINT_UP);
copy = evas_event_list_copy(e->pointer.object.in);
EINA_LIST_FOREACH(copy, l, obj)
{
@ -455,6 +461,8 @@ evas_event_feed_mouse_cancel(Evas *e, unsigned int timestamp, const void *data)
if ((e->pointer.button & (1 << i)))
evas_event_feed_mouse_up(e, i + 1, 0, timestamp, data);
}
/* remove released touch point from the touch point list */
_evas_touch_point_remove(e, 0);
_evas_unwalk(e);
}
@ -530,6 +538,9 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const
//// e->pointer.canvas_y = evas_coord_screen_y_to_world(e, y);
if ((!e->pointer.inside) && (e->pointer.mouse_grabbed == 0)) return;
_evas_walk(e);
/* update moved touch point */
if ((px != x) || (py != y))
_evas_touch_point_update(e, 0, e->pointer.x, e->pointer.y, EVAS_TOUCH_POINT_MOVE);
/* if our mouse button is grabbed to any objects */
if (e->pointer.mouse_grabbed > 0)
{
@ -914,6 +925,8 @@ evas_event_feed_multi_down(Evas *e,
ev.event_flags = EVAS_EVENT_FLAG_NONE;
_evas_walk(e);
/* append new touch point to the touch point list */
_evas_touch_point_append(e, d, x, y);
copy = evas_event_list_copy(e->pointer.object.in);
EINA_LIST_FOREACH(copy, l, obj)
{
@ -940,6 +953,8 @@ evas_event_feed_multi_down(Evas *e,
}
if (copy) eina_list_free(copy);
_evas_post_event_callback_call(e);
/* update touch point's state to EVAS_TOUCH_POINT_STILL */
_evas_touch_point_update(e, d, x, y, EVAS_TOUCH_POINT_STILL);
_evas_unwalk(e);
}
@ -985,6 +1000,8 @@ evas_event_feed_multi_up(Evas *e,
ev.event_flags = EVAS_EVENT_FLAG_NONE;
_evas_walk(e);
/* update released touch point */
_evas_touch_point_update(e, d, x, y, EVAS_TOUCH_POINT_UP);
copy = evas_event_list_copy(e->pointer.object.in);
EINA_LIST_FOREACH(copy, l, obj)
{
@ -1010,6 +1027,8 @@ evas_event_feed_multi_up(Evas *e,
if (copy) copy = eina_list_free(copy);
if ((e->pointer.mouse_grabbed == 0) && !_post_up_handle(e, timestamp, data))
_evas_post_event_callback_call(e);
/* remove released touch point from the touch point list */
_evas_touch_point_remove(e, d);
_evas_unwalk(e);
}
@ -1031,6 +1050,8 @@ evas_event_feed_multi_move(Evas *e,
if (!e->pointer.inside) return;
_evas_walk(e);
/* update moved touch point */
_evas_touch_point_update(e, d, x, y, EVAS_TOUCH_POINT_MOVE);
/* if our mouse button is grabbed to any objects */
if (e->pointer.mouse_grabbed > 0)
{

View File

@ -144,6 +144,7 @@ EAPI void
evas_free(Evas *e)
{
Eina_Rectangle *r;
Evas_Coord_Touch_Point *touch_point;
Evas_Layer *lay;
int i;
int del;
@ -250,6 +251,9 @@ evas_free(Evas *e)
eina_array_flush(&e->calculate_objects);
eina_array_flush(&e->clip_changes);
EINA_LIST_FREE(e->touch_points, touch_point)
free(touch_point);
e->magic = 0;
free(e);
}

View File

@ -0,0 +1,110 @@
#include "evas_common.h"
#include "evas_private.h"
void
_evas_touch_point_append(Evas *e, int id, Evas_Coord x, Evas_Coord y)
{
Evas_Coord_Touch_Point *point;
/* create new Evas_Coord_Touch_Point */
point = (Evas_Coord_Touch_Point *)calloc(1, sizeof(Evas_Coord_Touch_Point));
point->x = x;
point->y = y;
point->id = id;
point->state = EVAS_TOUCH_POINT_DOWN;
e->touch_points = eina_list_append(e->touch_points, point);
}
void
_evas_touch_point_update(Evas *e, int id, Evas_Coord x, Evas_Coord y, Evas_Touch_Point_State state)
{
Eina_List *l;
Evas_Coord_Touch_Point *point = NULL;
EINA_LIST_FOREACH(e->touch_points, l, point)
{
if (point->id == id)
{
point->x = x;
point->y = y;
point->state = state;
break;
}
}
}
void
_evas_touch_point_remove(Evas *e, int id)
{
Eina_List *l;
Evas_Coord_Touch_Point *point = NULL;
EINA_LIST_FOREACH(e->touch_points, l, point)
{
if (point->id == id)
{
e->touch_points = eina_list_remove(e->touch_points, point);
free(point);
break;
}
}
}
EAPI unsigned int
evas_touch_point_list_count(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return 0;
MAGIC_CHECK_END();
return eina_list_count(e->touch_points);
}
EAPI void
evas_touch_point_list_nth_xy_get(Evas *e, unsigned int n, Evas_Coord *x, Evas_Coord *y)
{
Evas_Coord_Touch_Point *point = NULL;
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
if (x) *x = 0;
if (y) *y = 0;
return;
MAGIC_CHECK_END();
point = (Evas_Coord_Touch_Point *)eina_list_nth(e->touch_points, n);
if (!point)
{
if (x) *x = 0;
if (y) *y = 0;
return;
}
if (x) *x = point->x;
if (y) *y = point->y;
}
EAPI int
evas_touch_point_list_nth_id_get(Evas *e, unsigned int n)
{
Evas_Coord_Touch_Point *point = NULL;
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return -1;
MAGIC_CHECK_END();
point = (Evas_Coord_Touch_Point *)eina_list_nth(e->touch_points, n);
if (!point) return -1;
return point->id;
}
EAPI Evas_Touch_Point_State
evas_touch_point_list_nth_state_get(Evas *e, unsigned int n)
{
Evas_Coord_Touch_Point *point = NULL;
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return EVAS_TOUCH_POINT_CANCEL;
MAGIC_CHECK_END();
point = (Evas_Coord_Touch_Point *)eina_list_nth(e->touch_points, n);
if (!point) return EVAS_TOUCH_POINT_CANCEL;
return point->state;
}

View File

@ -46,6 +46,7 @@ typedef struct _Evas_Format Evas_Format;
typedef struct _Evas_Map_Point Evas_Map_Point;
typedef struct _Evas_Smart_Cb_Description_Array Evas_Smart_Cb_Description_Array;
typedef struct _Evas_Post_Callback Evas_Post_Callback;
typedef struct _Evas_Coord_Touch_Point Evas_Coord_Touch_Point;
enum _Evas_Font_Style
{
@ -167,6 +168,13 @@ MAGIC_CHECK_FAILED(o, t, m)
(o)->prev.key = NULL; \
}
struct _Evas_Coord_Touch_Point
{
Evas_Coord x, y; // point's x, y position
int id; // id in order to distinguish each point
Evas_Touch_Point_State state;
};
struct _Evas_Key_Grab
{
char *keyname;
@ -377,6 +385,8 @@ struct _Evas
unsigned char invalidate : 1;
unsigned char cleanup : 1;
unsigned char focus : 1;
Eina_List *touch_points;
};
struct _Evas_Layer
@ -1017,6 +1027,11 @@ Eina_Bool evas_map_coords_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y, Eva
Eina_List *evas_module_engine_list(void);
/* for updating touch point list */
void _evas_touch_point_append(Evas *e, int id, Evas_Coord x, Evas_Coord y);
void _evas_touch_point_update(Evas *e, int id, Evas_Coord x, Evas_Coord y, Evas_Touch_Point_State state);
void _evas_touch_point_remove(Evas *e, int id);
/****************************************************************************/
/*****************************************/
/********************/