Gesture_Info *gesture[ELM_GESTURE_LAST];
Ecore_Timer *dbl_timeout; /* When this expires, dbl click/taps ABORTed */
Eina_List *pending; /* List of devices need to refeed *UP event */
- int touched; /* Int containing number of touched devices */
+ Eina_List *touched; /* Information of touched devices */
Eina_Bool repeat_events : 1;
};
memset(gesture->data, 0, sizeof(Taps_Type));
}
+/* START - Functions to manage touched-device list */
+/**
+ * @internal
+ * This function is used to find if device is touched
+ *
+ * @ingroup Elm_Gesture_Layer
+ */
+static int
+device_is_touched(const void *data1, const void *data2)
+{ /* Compare the two device numbers */
+ return (((Pointer_Event *) data1)->device -((Pointer_Event *) data2)->device);
+}
+
+/**
+ * @internal
+ *
+ * Recoed Pointer Event in touched device list
+ * Note: This fuction allocates memory for PE event
+ * This memory is released in _remove_touched_device()
+ * @param list Pointer to touched device list.
+ * @param Pointer_Event Pointer to PE.
+ *
+ * @ingroup Elm_Gesture_Layer
+ */
+static Eina_List *
+_add_touched_device(Eina_List *list, Pointer_Event *pe)
+{
+ if (eina_list_search_unsorted_list(list, device_is_touched, pe))
+ return list;
+
+ Pointer_Event *p = malloc(sizeof(Pointer_Event ));
+ memcpy(p, pe, sizeof(Pointer_Event)); /* Freed in _remove_touched_device() */
+ return eina_list_append(list, p);
+}
+
+/**
+ * @internal
+ *
+ * Remove Pointer Event from touched device list
+ * @param list Pointer to touched device list.
+ * @param Pointer_Event Pointer to PE.
+ *
+ * @ingroup Elm_Gesture_Layer
+ */
+static Eina_List *
+_remove_touched_device(Eina_List *list, Pointer_Event *pe)
+{
+ Pointer_Event *p = eina_list_search_unsorted(list, device_is_touched, pe);
+ if (p)
+ {
+ free(p);
+ return eina_list_remove(list, p);
+ }
+
+ return list;
+}
+/* END - Functions to manage touched-device list */
+
/**
* @internal
*
consume_event(Widget_Data *wd, void *event_info,
Evas_Callback_Type event_type, Evas_Event_Flags ev_flags)
{ /* Mark EVAS_EVENT_FLAG_ON_HOLD on events that are used by gesture layer */
- /* ev_flags != EVAS_EVENT_FLAG_NONE means target used the event and g-layer */
+ /* ev_flags != EVAS_EVENT_FLAG_NONE means target used event and g-layer */
/* should not refeed this event. */
if ((ev_flags) || (!wd->repeat_events))
{
// if ((!wd->touched) || (reset_s && !all_undefined))
/* (!wd->touched && reset_s) - don't stop zoom with mouse-wheel */
- if ((!wd->touched && reset_s) || (reset_s && !all_undefined))
+ if (reset_s && (!eina_list_count(wd->touched) || !all_undefined))
_event_history_clear(obj);
}
pe.timestamp = pe1.timestamp = 0;
- if(st->zoom_st.timestamp)
+ if (eina_list_search_unsorted_list(wd->touched, device_is_touched,
+ &st->zoom_st))
memcpy(&pe, &st->zoom_st, sizeof(Pointer_Event));
- if(st->zoom_st1.timestamp)
+ if (eina_list_search_unsorted_list(wd->touched, device_is_touched,
+ &st->zoom_st1))
memcpy(&pe1, &st->zoom_st1, sizeof(Pointer_Event));
memset(st, 0, sizeof(Zoom_Type));
/* If user released one finger only, restore down-info */
- if(pe.timestamp && (!pe1.timestamp))
+ if (pe.timestamp && (!pe1.timestamp))
memcpy(&st->zoom_st, &pe, sizeof(Pointer_Event));
- if(pe1.timestamp && (!pe.timestamp))
+ if (pe1.timestamp && (!pe.timestamp))
memcpy(&st->zoom_st1, &pe1, sizeof(Pointer_Event));
st->zoom_tolerance = wd->zoom_tolerance;
pe.timestamp = pe1.timestamp = 0;
- if(st->rotate_st.timestamp)
+ if (eina_list_search_unsorted_list(wd->touched, device_is_touched,
+ &st->rotate_st))
memcpy(&pe, &st->rotate_st, sizeof(Pointer_Event));
- if(st->rotate_st1.timestamp)
+ if (eina_list_search_unsorted_list(wd->touched, device_is_touched,
+ &st->rotate_st1))
memcpy(&pe1, &st->rotate_st1, sizeof(Pointer_Event));
memset(st, 0, sizeof(Rotate_Type));
/* If user released one finger only, restore down-info */
- if(pe.timestamp && (!pe1.timestamp))
+ if (pe.timestamp && (!pe1.timestamp))
memcpy(&st->rotate_st, &pe, sizeof(Pointer_Event));
- if(pe1.timestamp && (!pe.timestamp))
+ if (pe1.timestamp && (!pe.timestamp))
memcpy(&st->rotate_st1, &pe1, sizeof(Pointer_Event));
evas_object_event_callback_add(wd->target, EVAS_CALLBACK_MULTI_UP,
_multi_up, obj);
- evas_object_event_callback_add(wd->target, EVAS_CALLBACK_KEY_DOWN, _key_down_cb, obj);
- evas_object_event_callback_add(wd->target, EVAS_CALLBACK_KEY_UP, _key_up_cb, obj);
+ evas_object_event_callback_add(wd->target, EVAS_CALLBACK_KEY_DOWN,
+ _key_down_cb, obj);
+ evas_object_event_callback_add(wd->target, EVAS_CALLBACK_KEY_UP,
+ _key_up_cb, obj);
}
}
evas_object_event_callback_del(wd->target, EVAS_CALLBACK_MULTI_UP,
_multi_up);
- evas_object_event_callback_del(wd->target, EVAS_CALLBACK_KEY_DOWN, _key_down_cb);
- evas_object_event_callback_del(wd->target, EVAS_CALLBACK_KEY_UP, _key_up_cb);
+ evas_object_event_callback_del(wd->target, EVAS_CALLBACK_KEY_DOWN,
+ _key_down_cb);
+ evas_object_event_callback_del(wd->target, EVAS_CALLBACK_KEY_UP,
+ _key_up_cb);
}
}
* @ingroup Elm_Gesture_Layer
*/
static int
-device_in_list(const void *data1, const void *data2)
+device_in_pending_list(const void *data1, const void *data2)
{ /* Compare the two device numbers */
return (((int) data1) - ((int) data2));
}
return list;
}
- if (!eina_list_search_unsorted_list(list, device_in_list, (void *) device))
+ if (!eina_list_search_unsorted_list(list, device_in_pending_list,
+ (void *) device))
{
- printf("%s ======> Added <%d>\n", __func__, device);
return eina_list_append(list, (void *) device);
}
return NULL;
}
- return eina_list_search_unsorted_list(list, device_in_list, (void *) device);
+ return eina_list_search_unsorted_list(list, device_in_pending_list,
+ (void *) device);
}
/**
{
Event_History *t;
t = wd->event_history_list;
- Eina_List *pending = _device_is_pending(wd->pending, wd->event_history_list->event, wd->event_history_list->event_type);
+ Eina_List *pending = _device_is_pending(wd->pending,
+ wd->event_history_list->event,
+ wd->event_history_list->event_type);
/* Refeed events if no gesture matched input */
if (pending || ((!gesture_found) && (!wd->repeat_events)))
{
- evas_event_refeed_event(e, wd->event_history_list->event, wd->event_history_list->event_type);
+ evas_event_refeed_event(e, wd->event_history_list->event,
+ wd->event_history_list->event_type);
- if(pending)
+ if (pending)
{
wd->pending = eina_list_remove_list(wd->pending, pending);
int device = ELM_MOUSE_DEVICE;
- if(wd->event_history_list->event_type == EVAS_CALLBACK_MULTI_UP)
- device = ((Evas_Event_Multi_Up *) (wd->event_history_list->event))->device;
- printf("%s ======> Removed <%d>\n", __func__, device);
+ if (wd->event_history_list->event_type == EVAS_CALLBACK_MULTI_UP)
+ device = ((Evas_Event_Multi_Up *)
+ (wd->event_history_list->event))->device;
}
else
- wd->pending = _add_device_pending(wd->pending, wd->event_history_list->event, wd->event_history_list->event_type);
+ wd->pending = _add_device_pending(wd->pending,
+ wd->event_history_list->event,
+ wd->event_history_list->event_type);
}
free(wd->event_history_list->event);
_event_history_clear(obj);
eina_list_free(wd->pending);
+ Pointer_Event *data;
+ EINA_LIST_FREE(wd->touched, data)
+ free(data);
+
if (!elm_widget_disabled_get(obj))
_unregister_callbacks(obj);
}
static Eina_List*
-_record_pointer_event(Taps_Type *st, Eina_List *pe_list, Pointer_Event *pe, Widget_Data *wd, void *event_info,
- Evas_Callback_Type event_type)
+_record_pointer_event(Taps_Type *st, Eina_List *pe_list, Pointer_Event *pe,
+ Widget_Data *wd, void *event_info, Evas_Callback_Type event_type)
{ /* Keep copy of pe and record it in list */
Pointer_Event *p = malloc(sizeof(Pointer_Event));
memcpy(p, pe, sizeof(Pointer_Event));
Gesture_Info *gesture = wd->gesture[g_type];
if (!gesture ) return;
- if((gesture->state == ELM_GESTURE_STATE_UNDEFINED) &&
- wd->touched)
+ if ((gesture->state == ELM_GESTURE_STATE_UNDEFINED) &&
+ eina_list_count(wd->touched))
return; /* user left a finger on device, do NOT start */
Taps_Type *st = gesture->data;
Gesture_Info *gesture = wd->gesture[g_type];
if (!gesture ) return;
- if((gesture->state == ELM_GESTURE_STATE_UNDEFINED) &&
- wd->touched)
+ if ((gesture->state == ELM_GESTURE_STATE_UNDEFINED) &&
+ eina_list_count(wd->touched))
return; /* user left a finger on device, do NOT start */
Momentum_Type *st = gesture->data;
Gesture_Info *gesture = wd->gesture[g_type];
if (!gesture ) return;
- if((gesture->state == ELM_GESTURE_STATE_UNDEFINED) &&
- wd->touched)
+ if ((gesture->state == ELM_GESTURE_STATE_UNDEFINED) &&
+ eina_list_count(wd->touched))
return; /* user left a finger on device, do NOT start */
Line_Type *st = gesture->data;
#if defined(DEBUG_GESTURE_LAYER)
printf("%s a=<%f> d=<%f>\n", __func__, (a * 57.295779513), d);
#endif
- if((d > wd->line_tolerance) || (a > ELM_GESTURE_LINE_ANGLE_TOLERANCE))
+ if ((d > wd->line_tolerance) || (a > ELM_GESTURE_LINE_ANGLE_TOLERANCE))
// if (a > ELM_GESTURE_LINE_ANGLE_TOLERANCE)
{ /* Broke tolerance: abort line and start a new one */
ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
low += RAD_180DEG;
high += RAD_180DEG;
- if(t < RAD_180DEG)
+ if (t < RAD_180DEG)
t += RAD_180DEG;
else
t -= RAD_180DEG;
low -= RAD_180DEG;
high -= RAD_180DEG;
- if(t < RAD_180DEG)
+ if (t < RAD_180DEG)
t += RAD_180DEG;
else
t -= RAD_180DEG;
* @ingroup Elm_Gesture_Layer
*/
static void
-_zoom_test(Evas_Object *obj, Pointer_Event *pe, void *event_info, Evas_Callback_Type event_type,
- Elm_Gesture_Types g_type)
+_zoom_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
+ Evas_Callback_Type event_type, Elm_Gesture_Types g_type)
{
- if(!pe)
+ if (!pe)
return;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
/* Reset timestamp of finger-up.This is used later
by _zoom_test_reset() to retain finger-down data */
consume_event(wd, event_info, event_type, ev_flag);
- if(event_type == EVAS_CALLBACK_MOUSE_UP)
- st->zoom_st.timestamp = 0;
-
- if((event_type == EVAS_CALLBACK_MULTI_UP) &&
- (st->zoom_st1.device ==
- ((Evas_Event_Multi_Up *) event_info)->device))
- st->zoom_st1.timestamp = 0;
-
if (((st->zoom_wheel) || (st->zoom_base)) &&
(st->zoom_tolerance == 0))
{
{
{ /* Zoom broke tolerance, report move */
double d = st->info.zoom - st->next_step;
- if(d < 0.0)
+ if (d < 0.0)
d = (-d);
- if(d >= wd->zoom_step)
+ if (d >= wd->zoom_step)
{ /* Report move in steps */
st->next_step = st->info.zoom;
return;
}
- if((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
+ if ((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
(event_type == EVAS_CALLBACK_MULTI_DOWN))
{ /* report zoom start finger location is zoom-center temporarly */
/* Zoom may have started with mouse-wheel, don't report START */
- if((st->zoom_st.timestamp) && (st->zoom_st1.timestamp))
+ if ((st->zoom_st.timestamp) && (st->zoom_st1.timestamp))
{ /* Set zoom-base after BOTH down events were recorded */
/* Compute length of line between fingers on zoom start */
st->info.zoom = 1.0;
*angle = get_angle(x1, y1, x2, y2);
#if 0 /* (NOT YET SUPPORTED) */
- if(angle == &st->info.angle)
+ if (angle == &st->info.angle)
{ /* Compute momentum: TODO: bug when breaking 0, 360 values */
st->info.momentum = (((*angle) - st->info.base_angle) /
(fabs(tm2 - tm1))) * 1000;
_rotate_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
Evas_Callback_Type event_type, Elm_Gesture_Types g_type)
{
- if(!pe)
+ if (!pe)
return;
Widget_Data *wd = elm_widget_data_get(obj);
consume_event(wd, event_info, event_type, ev_flag);
/* Reset timestamp of finger-up.This is used later
by rotate_test_reset() to retain finger-down data */
- if(event_type == EVAS_CALLBACK_MOUSE_UP)
- st->rotate_st.timestamp = 0;
-
- if((event_type == EVAS_CALLBACK_MULTI_UP) &&
- (st->rotate_st1.device ==
- ((Evas_Event_Multi_Up *) event_info)->device))
- st->rotate_st1.timestamp = 0;
-
if (st->rotate_tolerance < 0)
{
ev_flag = _set_state(gesture, ELM_GESTURE_STATE_END,
if (rotation_broke_tolerance(st))
{ /* Rotation broke tolerance, report move */
double d = st->info.angle - st->next_step;
- if(d < 0.0)
+ if (d < 0.0)
d = (-d);
- if(d >= wd->rotate_step)
+ if (d >= wd->rotate_step)
{ /* Report move in steps */
st->next_step = st->info.angle;
return;
}
- if((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
+ if ((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
(event_type == EVAS_CALLBACK_MULTI_DOWN))
{
- if((st->rotate_st.timestamp) && (st->rotate_st1.timestamp))
+ if ((st->rotate_st.timestamp) && (st->rotate_st1.timestamp))
{ /* two-fingers on touch screen - report rotate start */
/* Set base angle, then report start. */
_get_rotate_properties(st,
if ((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
(event_type == EVAS_CALLBACK_MULTI_DOWN))
{
- wd->touched++;
- printf("%s touched=<%d>\n", __func__, wd->touched);
+ wd->touched = _add_touched_device(wd->touched, pe);
}
else if ((event_type == EVAS_CALLBACK_MOUSE_UP) ||
(event_type == EVAS_CALLBACK_MULTI_UP))
{
- wd->touched--;
- printf("%s touched=<%d>\n", __func__, wd->touched);
+ wd->touched = _remove_touched_device(wd->touched, pe);
}
/* Report current states and clear history if needed */
{
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
-printf("---- %s ----\n", __func__);
- if (((Evas_Event_Mouse_Down *) event_info)->button != 1) /* We only process left-click at the moment */
- return;
+ if (((Evas_Event_Mouse_Down *) event_info)->button != 1)
+ return; /* We only process left-click at the moment */
_event_process(data, obj, event_info, EVAS_CALLBACK_MOUSE_DOWN);
}
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
-printf("---- %s ----\n", __func__);
- if (((Evas_Event_Mouse_Up *) event_info)->button != 1) /* We only process left-click at the moment */
- return;
+ if (((Evas_Event_Mouse_Up *) event_info)->button != 1)
+ return; /* We only process left-click at the moment */
_event_process(data, obj, event_info, EVAS_CALLBACK_MOUSE_UP);
}
{
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
-printf("---- %s ----\n", __func__);
_event_process(data, obj, event_info, EVAS_CALLBACK_MULTI_DOWN);
}
{
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
-printf("---- %s ----\n", __func__);
_event_process(data, obj, event_info, EVAS_CALLBACK_MULTI_UP);
}
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- if(s < 0.0)
+ if (s < 0.0)
return;
wd->zoom_step = s;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- if(s < 0.0)
+ if (s < 0.0)
return;
wd->rotate_step = s;