efl/gesture: handle multi-touch press for tap gestures

any time multiple fingers are pressed down at the same time, we should
treat this as a single gesture like if only one finger was pressed

Reviewed-by: woochan lee <wc0917.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D11086
This commit is contained in:
Mike Blumenkrantz 2020-01-13 15:07:17 -05:00 committed by Marcel Hollerbach
parent 723382bf5c
commit 15527dbecb
4 changed files with 65 additions and 0 deletions

View File

@ -8,6 +8,9 @@
#include <Ecore.h>
/* milliseconds */
#define TAP_TOUCH_TIME_THRESHOLD (0.1 * 1000)
const Efl_Event_Description * _efl_gesture_type_get(const Eo *obj);
void efl_gesture_manager_gesture_clean_up(Eo *obj, Eo *target, const Efl_Event_Description *type);

View File

@ -89,6 +89,16 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
case EFL_GESTURE_TOUCH_STATE_UPDATE:
{
/* multi-touch */
if (efl_gesture_touch_cur_data_get(event)->action == EFL_POINTER_ACTION_DOWN)
{
/* a second finger was pressed at the same time-ish as the first: combine into same event */
if (efl_gesture_touch_cur_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
{
result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
break;
}
}
result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE &&
@ -119,6 +129,20 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE &&
!efl_gesture_touch_multi_touch_get(event))
{
if (efl_gesture_touch_prev_data_get(event))
{
Efl_Pointer_Action prev_act = efl_gesture_touch_prev_data_get(event)->action;
/* multi-touch */
if ((prev_act == EFL_POINTER_ACTION_UP) || (prev_act == EFL_POINTER_ACTION_CANCEL))
{
/* a second finger was pressed at the same time-ish as the first: combine into same event */
if (efl_gesture_touch_cur_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
{
result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
break;
}
}
}
dist = efl_gesture_touch_distance(event, 0);
length = fabs(dist.x) + fabs(dist.y);

View File

@ -46,6 +46,7 @@ _efl_canvas_gesture_recognizer_tap_efl_canvas_gesture_recognizer_recognize(Eo *o
{
case EFL_GESTURE_TOUCH_STATE_BEGIN:
{
new_tap:
pos = efl_gesture_touch_start_point_get(event);
efl_gesture_hotspot_set(gesture, pos);
@ -59,6 +60,19 @@ _efl_canvas_gesture_recognizer_tap_efl_canvas_gesture_recognizer_recognize(Eo *o
}
case EFL_GESTURE_TOUCH_STATE_UPDATE:
/* multi-touch */
if (efl_gesture_touch_cur_data_get(event)->action == EFL_POINTER_ACTION_DOWN)
{
/* a second finger was pressed at the same time-ish as the first: combine into same event */
if (efl_gesture_touch_cur_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
{
result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
break;
}
/* another distinct touch occurred, treat this as a new touch */
goto new_tap;
}
EINA_FALLTHROUGH;
case EFL_GESTURE_TOUCH_STATE_END:
{
if (pd->timeout)

View File

@ -89,6 +89,16 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
case EFL_GESTURE_TOUCH_STATE_UPDATE:
{
/* multi-touch */
if (efl_gesture_touch_cur_data_get(event)->action == EFL_POINTER_ACTION_DOWN)
{
/* a second finger was pressed at the same time-ish as the first: combine into same event */
if (efl_gesture_touch_cur_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
{
result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
break;
}
}
result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE &&
@ -119,6 +129,20 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE &&
!efl_gesture_touch_multi_touch_get(event))
{
if (efl_gesture_touch_prev_data_get(event))
{
Efl_Pointer_Action prev_act = efl_gesture_touch_prev_data_get(event)->action;
/* multi-touch */
if ((prev_act == EFL_POINTER_ACTION_UP) || (prev_act == EFL_POINTER_ACTION_CANCEL))
{
/* a second finger was pressed at the same time-ish as the first: combine into same event */
if (efl_gesture_touch_cur_timestamp_get(event) - efl_gesture_timestamp_get(gesture) < TAP_TOUCH_TIME_THRESHOLD)
{
result = EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
break;
}
}
}
dist = efl_gesture_touch_distance(event, 0);
length = fabs(dist.x) + fabs(dist.y);