summaryrefslogtreecommitdiff
path: root/legacy/elementary/src/lib/elm_gesture_layer.c
diff options
context:
space:
mode:
Diffstat (limited to 'legacy/elementary/src/lib/elm_gesture_layer.c')
-rw-r--r--legacy/elementary/src/lib/elm_gesture_layer.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/legacy/elementary/src/lib/elm_gesture_layer.c b/legacy/elementary/src/lib/elm_gesture_layer.c
index 4b516f2e8b..bff601b320 100644
--- a/legacy/elementary/src/lib/elm_gesture_layer.c
+++ b/legacy/elementary/src/lib/elm_gesture_layer.c
@@ -157,9 +157,9 @@ typedef struct _Taps_Type Taps_Type;
157struct _Long_Tap_Type 157struct _Long_Tap_Type
158{ 158{
159 Elm_Gesture_Taps_Info info; 159 Elm_Gesture_Taps_Info info;
160 unsigned int center_x; 160 Evas_Coord center_x;
161 unsigned int center_y; 161 Evas_Coord center_y;
162 unsigned int n_taps; 162 unsigned int max_touched;
163 Ecore_Timer *timeout; /* When this expires, long tap STARTed */ 163 Ecore_Timer *timeout; /* When this expires, long tap STARTed */
164 Eina_List *touched; 164 Eina_List *touched;
165}; 165};
@@ -1430,7 +1430,8 @@ _tap_gestures_test(Evas_Object *obj, Pointer_Event *pe,
1430 * @ingroup Elm_Gesture_Layer 1430 * @ingroup Elm_Gesture_Layer
1431 */ 1431 */
1432static void 1432static void
1433_compute_taps_center(Long_Tap_Type *st, Pointer_Event *pe) 1433_compute_taps_center(Long_Tap_Type *st,
1434 Evas_Coord *x_out, Evas_Coord *y_out, Pointer_Event *pe)
1434{ 1435{
1435 if(!eina_list_count(st->touched)) 1436 if(!eina_list_count(st->touched))
1436 return; 1437 return;
@@ -1452,8 +1453,8 @@ _compute_taps_center(Long_Tap_Type *st, Pointer_Event *pe)
1452 } 1453 }
1453 } 1454 }
1454 1455
1455 st->info.x = x / eina_list_count(st->touched); 1456 *x_out = x / eina_list_count(st->touched);
1456 st->info.y = y / eina_list_count(st->touched); 1457 *y_out = y / eina_list_count(st->touched);
1457} 1458}
1458 1459
1459/** 1460/**
@@ -1479,10 +1480,9 @@ _n_long_tap_test(Evas_Object *obj, Pointer_Event *pe,
1479 if (!wd) return; 1480 if (!wd) return;
1480 1481
1481 if (!pe) /* this happens when unhandled event arrived */ 1482 if (!pe) /* this happens when unhandled event arrived */
1482 return; /* see _make_pointer_event function */ 1483 return; /* see _make_pointer_event function */
1483
1484 Gesture_Info *gesture = wd->gesture[g_type]; 1484 Gesture_Info *gesture = wd->gesture[g_type];
1485 if (!gesture ) return; 1485 if (!gesture) return;
1486 1486
1487 Long_Tap_Type *st = gesture->data; 1487 Long_Tap_Type *st = gesture->data;
1488 if (!st) 1488 if (!st)
@@ -1499,6 +1499,19 @@ _n_long_tap_test(Evas_Object *obj, Pointer_Event *pe,
1499 case EVAS_CALLBACK_MOUSE_DOWN: 1499 case EVAS_CALLBACK_MOUSE_DOWN:
1500 st->touched = _add_touched_device(st->touched, pe); 1500 st->touched = _add_touched_device(st->touched, pe);
1501 st->info.n = eina_list_count(st->touched); 1501 st->info.n = eina_list_count(st->touched);
1502 if (st->info.n > st->max_touched)
1503 st->max_touched = st->info.n;
1504 else
1505 { /* User removed finger from touch, then put back - ABORT */
1506 if ((gesture->state == ELM_GESTURE_STATE_START) ||
1507 (gesture->state == ELM_GESTURE_STATE_MOVE))
1508 {
1509 ev_flag =_set_state(gesture, ELM_GESTURE_STATE_ABORT,
1510 &st->info, EINA_FALSE);
1511 consume_event(wd, event_info, event_type, ev_flag);
1512 }
1513 }
1514
1502 if ((pe->device == 0) && (eina_list_count(st->touched) == 1)) 1515 if ((pe->device == 0) && (eina_list_count(st->touched) == 1))
1503 { /* This is the first mouse down we got */ 1516 { /* This is the first mouse down we got */
1504 st->info.timestamp = pe->timestamp; 1517 st->info.timestamp = pe->timestamp;
@@ -1511,12 +1524,15 @@ _n_long_tap_test(Evas_Object *obj, Pointer_Event *pe,
1511 } 1524 }
1512 1525
1513 consume_event(wd, event_info, event_type, ev_flag); 1526 consume_event(wd, event_info, event_type, ev_flag);
1514 _compute_taps_center(st, pe); 1527 _compute_taps_center(st, &st->info.x, &st->info.y, pe);
1528 st->center_x = st->info.x;
1529 st->center_y = st->info.y;
1515 break; 1530 break;
1516 1531
1517 case EVAS_CALLBACK_MULTI_UP: 1532 case EVAS_CALLBACK_MULTI_UP:
1518 case EVAS_CALLBACK_MOUSE_UP: 1533 case EVAS_CALLBACK_MOUSE_UP:
1519 st->touched = _remove_touched_device(st->touched, pe); 1534 st->touched = _remove_touched_device(st->touched, pe);
1535 _compute_taps_center(st, &st->center_x, &st->center_y, pe);
1520 if (st->info.n && 1536 if (st->info.n &&
1521 ((gesture->state == ELM_GESTURE_STATE_START) || 1537 ((gesture->state == ELM_GESTURE_STATE_START) ||
1522 (gesture->state == ELM_GESTURE_STATE_MOVE))) 1538 (gesture->state == ELM_GESTURE_STATE_MOVE)))
@@ -1545,9 +1561,20 @@ _n_long_tap_test(Evas_Object *obj, Pointer_Event *pe,
1545 ((gesture->state == ELM_GESTURE_STATE_START) || 1561 ((gesture->state == ELM_GESTURE_STATE_START) ||
1546 (gesture->state == ELM_GESTURE_STATE_MOVE))) 1562 (gesture->state == ELM_GESTURE_STATE_MOVE)))
1547 { /* Report MOVE only if STARTED */ 1563 { /* Report MOVE only if STARTED */
1548 _compute_taps_center(st, pe); 1564 Evas_Coord x;
1565 Evas_Coord y;
1566 Elm_Gesture_State state_to_report = ELM_GESTURE_STATE_MOVE;
1567
1568 _compute_taps_center(st, &x, &y, pe);
1569 /* ABORT if user moved fingers out of tap area */
1570#if defined(DEBUG_GESTURE_LAYER)
1571 printf("%s x,y=(%d,%d) st->info.x,st->info.y=(%d,%d)\n",__func__,x,y,st->info.x,st->info.y);
1572#endif
1573 if (!_inside(x, y, st->center_x, st->center_y))
1574 state_to_report = ELM_GESTURE_STATE_ABORT;
1575
1549 /* Report MOVE if gesture started */ 1576 /* Report MOVE if gesture started */
1550 ev_flag = _set_state(gesture, ELM_GESTURE_STATE_MOVE, 1577 ev_flag = _set_state(gesture, state_to_report,
1551 &st->info, EINA_TRUE); 1578 &st->info, EINA_TRUE);
1552 consume_event(wd, event_info, event_type, ev_flag); 1579 consume_event(wd, event_info, event_type, ev_flag);
1553 } 1580 }