Elm glayer: Set mimimun momentum for ABORT
[framework/uifw/elementary.git] / src / lib / elm_gesture_layer.c
index 55bd73d..1cfd219 100644 (file)
@@ -8,6 +8,7 @@
 #define ELM_GESTURE_NEGATIVE_ANGLE (-1.0) /* Magic number */
 #define ELM_GESTURE_MOMENTUM_TIMEOUT 50
 #define ELM_GESTURE_MULTI_TIMEOUT 50
+#define ELM_GESTURE_MINIMUM_MOMENTUM 0.001
 
 /* Some Trigo values */
 #define RAD_90DEG  M_PI_2
@@ -1716,6 +1717,12 @@ _momentum_test(Evas_Object *obj, Pointer_Event *pe,
    Gesture_Info *gesture = wd->gesture[g_type];
    if (!gesture ) return;
 
+   /* When continues enable = TRUE a gesture may START on MOVE event */
+   /* We don't allow this to happen with the if-statement below.     */
+   /* When continues enable = FALSE a gesture may START on DOWN only */
+   /* Therefor it would NOT start on MOVE event.                     */
+   /* NOTE that touched list is updated AFTER this function returns  */
+   /* so (count == 0) when we get here on first touch on surface.    */
    if ((wd->glayer_continues_enable) && (!eina_list_count(wd->touched)))
      return; /* Got move on mouse-over move */
 
@@ -1854,7 +1861,13 @@ _momentum_test(Evas_Object *obj, Pointer_Event *pe,
          _set_momentum(&st->info, st->line_st.x, st->line_st.y, pe_local.x, pe_local.y,
                st->t_st_x, st->t_st_y, pe_local.timestamp);
 
-         ev_flag = _set_state(gesture, ELM_GESTURE_STATE_END, &st->info,
+         if ((fabs(st->info.mx) > ELM_GESTURE_MINIMUM_MOMENTUM) ||
+               (fabs(st->info.my) > ELM_GESTURE_MINIMUM_MOMENTUM))
+           state_to_report = ELM_GESTURE_STATE_END;
+         else
+           state_to_report = ELM_GESTURE_STATE_ABORT;
+
+         ev_flag = _set_state(gesture, state_to_report, &st->info,
                EINA_FALSE);
          consume_event(wd, event_info, event_type, ev_flag);
          return;
@@ -1967,6 +1980,12 @@ _n_line_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
    Gesture_Info *gesture = wd->gesture[g_type];
    if (!gesture ) return;
 
+   /* When continues enable = TRUE a gesture may START on MOVE event */
+   /* We don't allow this to happen with the if-statement below.     */
+   /* When continues enable = FALSE a gesture may START on DOWN only */
+   /* Therefor it would NOT start on MOVE event.                     */
+   /* NOTE that touched list is updated AFTER this function returns  */
+   /* so (count == 0) when we get here on first touch on surface.    */
    if ((wd->glayer_continues_enable) && (!eina_list_count(wd->touched)))
      return; /* Got move on mouse-over move */