1 #include "evas_common_private.h"
2 #include "evas_private.h"
3 
4 void
_evas_touch_point_append(Evas * eo_e,int id,Evas_Coord x,Evas_Coord y)5 _evas_touch_point_append(Evas *eo_e, int id, Evas_Coord x, Evas_Coord y)
6 {
7    Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
8    Evas_Coord_Touch_Point *point;
9 
10    /* create new Evas_Coord_Touch_Point */
11    point = (Evas_Coord_Touch_Point *)calloc(1, sizeof(Evas_Coord_Touch_Point));
12    point->x = x;
13    point->y = y;
14    point->id = id;
15    point->state = EVAS_TOUCH_POINT_DOWN;
16    e->touch_points = eina_list_append(e->touch_points, point);
17 }
18 
19 void
_evas_touch_point_update(Evas * eo_e,int id,Evas_Coord x,Evas_Coord y,Evas_Touch_Point_State state)20 _evas_touch_point_update(Evas *eo_e, int id, Evas_Coord x, Evas_Coord y, Evas_Touch_Point_State state)
21 {
22    Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
23    Eina_List *l;
24    Evas_Coord_Touch_Point *point = NULL;
25 
26    EINA_LIST_FOREACH(e->touch_points, l, point)
27      {
28         if (point->id == id)
29           {
30              point->x = x;
31              point->y = y;
32              point->state = state;
33              break;
34           }
35      }
36 }
37 
38 void
_evas_touch_point_remove(Evas * eo_e,int id)39 _evas_touch_point_remove(Evas *eo_e, int id)
40 {
41    Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
42    Eina_List *l;
43    Evas_Coord_Touch_Point *point = NULL;
44 
45    EINA_LIST_FOREACH(e->touch_points, l, point)
46      {
47         if (point->id == id)
48           {
49              e->touch_points = eina_list_remove(e->touch_points, point);
50              free(point);
51              break;
52           }
53      }
54 }
55 
56 EAPI unsigned int
evas_touch_point_list_count(Eo * eo_e)57 evas_touch_point_list_count(Eo *eo_e)
58 {
59    EVAS_LEGACY_API(eo_e, e, 0);
60    return eina_list_count(e->touch_points);
61 }
62 
63 /* For Efl.Ui.Win only */
64 EOLIAN void
_evas_canvas_touch_point_list_nth_xy_get(Evas_Canvas * eo_e EINA_UNUSED,Evas_Public_Data * e,unsigned int n,double * x,double * y)65 _evas_canvas_touch_point_list_nth_xy_get(Evas_Canvas *eo_e EINA_UNUSED,
66                                          Evas_Public_Data *e, unsigned int n,
67                                          double *x, double *y)
68 {
69    Evas_Coord_Touch_Point *point;
70 
71    point = eina_list_nth(e->touch_points, n);
72    if (!point)
73      {
74         if (x) *x = 0;
75         if (y) *y = 0;
76         return;
77      }
78    if (x) *x = point->x;
79    if (y) *y = point->y;
80 }
81 
82 EAPI void
evas_touch_point_list_nth_xy_get(Evas * eo_e,unsigned int n,Evas_Coord * x,Evas_Coord * y)83 evas_touch_point_list_nth_xy_get(Evas *eo_e, unsigned int n,
84                                  Evas_Coord *x, Evas_Coord *y)
85 {
86    double X, Y;
87 
88    EVAS_LEGACY_API(eo_e, e);
89    _evas_canvas_touch_point_list_nth_xy_get(eo_e, e, n, &X, &Y);
90    if (x) *x = X;
91    if (y) *y = Y;
92 }
93 
94 EAPI int
evas_touch_point_list_nth_id_get(Evas * eo_e,unsigned int n)95 evas_touch_point_list_nth_id_get(Evas *eo_e, unsigned int n)
96 {
97    Evas_Coord_Touch_Point *point;
98 
99    EVAS_LEGACY_API(eo_e, e, -1);
100    point = eina_list_nth(e->touch_points, n);
101    if (!point) return -1;
102    else return point->id;
103 }
104 
105 EAPI Evas_Touch_Point_State
evas_touch_point_list_nth_state_get(Evas * eo_e,unsigned int n)106 evas_touch_point_list_nth_state_get(Evas *eo_e, unsigned int n)
107 {
108    Evas_Coord_Touch_Point *point;
109 
110    EVAS_LEGACY_API(eo_e, e, EVAS_TOUCH_POINT_CANCEL);
111    point = eina_list_nth(e->touch_points, n);
112    if (!point) return EVAS_TOUCH_POINT_CANCEL;
113    else return point->state;
114 }
115 
116