[gesture_layer] opensource merge (r71200)
[framework/uifw/elementary.git] / src / lib / elm_gesture_layer.c
index 2843fa3..68b7758 100644 (file)
@@ -6,7 +6,12 @@
 #define ELM_MOUSE_DEVICE 0
 /* ELM_GESTURE_NEGATIVE_ANGLE - magic number says we didn't compute this yet */
 #define ELM_GESTURE_NEGATIVE_ANGLE (-1.0) /* Magic number */
+#define ELM_GESTURE_MOMENTUM_DELAY 25
 #define ELM_GESTURE_MOMENTUM_TIMEOUT 50
+#define ELM_GESTURE_MULTI_TIMEOUT 50
+#define ELM_GESTURE_MINIMUM_MOMENTUM 0.001
+
+#define ELM_GESTURE_TAP_TIMEOUT 0.2
 
 /* Some Trigo values */
 #define RAD_90DEG  M_PI_2
@@ -15,6 +20,9 @@
 #define RAD_360DEG (M_PI * 2)
 /* #define DEBUG_GESTURE_LAYER 1 */
 
+#define RAD2DEG(x) ((x) * 57.295779513)
+#define DEG2RAD(x) ((x) / 57.295779513)
+
 static void *
 _glayer_bufdup(void *buf, size_t size)
 {
@@ -69,7 +77,7 @@ struct _Gesture_Info
   Evas_Object *obj;
   void *data; /**< Holds gesture intemidiate processing data */
   Func_Data fn[ELM_GESTURE_STATE_ABORT + 1]; /**< Callback info for states */
-  Elm_Gesture_Types g_type;  /**< gesture type */
+  Elm_Gesture_Type g_type;  /**< gesture type */
   Elm_Gesture_State state;  /**< gesture state */
   void *info;                        /**< Data for the state callback */
   Eina_Bool test; /**< if true this gesture should be tested on input */
@@ -156,9 +164,9 @@ typedef struct _Taps_Type Taps_Type;
 struct _Long_Tap_Type
 {
    Elm_Gesture_Taps_Info info;
-   unsigned int center_x;
-   unsigned int center_y;
-   unsigned int n_taps;
+   Evas_Coord center_x;
+   Evas_Coord center_y;
+   unsigned int max_touched;
    Ecore_Timer *timeout; /* When this expires, long tap STARTed */
    Eina_List *touched;
 };
@@ -172,6 +180,7 @@ struct _Momentum_Type
    unsigned int t_st_x;  /* Time start on X */
    unsigned int t_st_y;  /* Time start on Y */
    unsigned int t_end;   /* Time end        */
+   unsigned int t_up; /* Recent up event time */
    int xdir, ydir;
 };
 typedef struct _Momentum_Type Momentum_Type;
@@ -205,8 +214,10 @@ struct _Zoom_Type
    Evas_Event_Mouse_Wheel *zoom_wheel;
    Evas_Coord zoom_base;  /* Holds gap between fingers on zoom-start  */
    Evas_Coord zoom_distance_tolerance;
-   Elm_Gesture_Momentum_Info momentum1;      /* For continues gesture */
-   Elm_Gesture_Momentum_Info momentum2;      /* For continues gesture */
+   unsigned int m_st_tm;      /* momentum start time */
+   unsigned int m_prev_tm;    /* momentum prev time  */
+   int dir;   /* Direction: 1=zoom-in, (-1)=zoom-out */
+   double m_base; /* zoom value when momentum starts */
    double next_step;
 };
 typedef struct _Zoom_Type Zoom_Type;
@@ -218,10 +229,11 @@ struct _Rotate_Type
    Pointer_Event rotate_mv;
    Pointer_Event rotate_st1;
    Pointer_Event rotate_mv1;
+   unsigned int prev_momentum_tm; /* timestamp of prev_momentum */
+   double prev_momentum;   /* Snapshot of momentum 0.01 sec ago */
+   double accum_momentum;
    double rotate_angular_tolerance;
    double next_step;
-   Elm_Gesture_Momentum_Info momentum1;      /* For continues gesture */
-   Elm_Gesture_Momentum_Info momentum2;      /* For continues gesture */
 };
 typedef struct _Rotate_Type Rotate_Type;
 
@@ -248,7 +260,6 @@ struct _Widget_Data
    Ecore_Timer *dbl_timeout; /* When this expires, dbl click/taps ABORTed  */
    Eina_List *pending; /* List of devices need to refeed *UP event */
    Eina_List *touched;  /* Information  of touched devices   */
-   Eina_List *recent_device_event;  /* Information  of recent pe event of each device */
 
    Eina_Bool repeat_events : 1;
 };
@@ -261,7 +272,7 @@ static Eina_Bool _event_history_clear(Evas_Object *obj);
 static void _reset_states(Widget_Data *wd);
 static void _key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
 static void _key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
-static void _zoom_with_wheel_test(Evas_Object *obj, void *event_info, Evas_Callback_Type event_type, Elm_Gesture_Types g_type);
+static void _zoom_with_wheel_test(Evas_Object *obj, void *event_info, Evas_Callback_Type event_type, Elm_Gesture_Type g_type);
 static void _mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
 static void _mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static void _mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
@@ -296,11 +307,13 @@ compare_device(const void *data1, const void *data2)
 static Eina_List *
 _remove_touched_device(Eina_List *list, Pointer_Event *pe)
 {
+   Eina_List *lst = NULL;
    Pointer_Event *p = eina_list_search_unsorted(list, compare_device, pe);
    if (p)
      {
+        lst = eina_list_remove(list, p);
         free(p);
-        return eina_list_remove(list, p);
+        return lst;
      }
 
    return list;
@@ -327,69 +340,18 @@ _add_touched_device(Eina_List *list, Pointer_Event *pe)
         return list;
      }
 
-   p = malloc(sizeof(Pointer_Event));
-   memcpy(p, pe, sizeof(Pointer_Event)); /* Freed in _remove_touched_device() */
-   return eina_list_append(list, p);
-}
-/* END   - Functions to manage touched-device list */
-
-/* START - Functions to manage recent device event list */
-/* This list holds the recent-event for each device     */
-/* it will hold a single recent-event for each device   */
-/* We are using those PE events of this list to         */
-/* send them later to test funcs to restart gestures    */
-/* We only keep DOWN, MOVE events in this list.         */
-/* So when no touch this list is empty.                 */
-/**
- * @internal
- *
- * Recoed Pointer Event in touched device list
- * Note: This fuction allocates memory for PE event
- * This memory is released here when device untouched
- * or in cleanup.
- * @param list Pointer to touched device list.
- * @param Pointer_Event Pointer to PE.
- *
- * @ingroup Elm_Gesture_Layer
- */
-static Eina_List *
-_add_recent_device_event(Eina_List *list, Pointer_Event *pe)
-{
-   void *data = eina_list_search_sorted(list, compare_device, pe);
-   Eina_List *l = list;
-   Pointer_Event *p = NULL;
-   if(data)   /* First remove recent event for this device */
-     l = eina_list_remove(list, data);
-
-
-   switch(pe->event_type)
-     {
-      case EVAS_CALLBACK_MOUSE_DOWN:
-      case EVAS_CALLBACK_MOUSE_MOVE:
-      case EVAS_CALLBACK_MULTI_DOWN:
-      case EVAS_CALLBACK_MULTI_MOVE:
-         p = malloc(sizeof(Pointer_Event));
-         memcpy(p, pe, sizeof(Pointer_Event)); /* Freed in here or on cleanup */
-         l =  eina_list_sorted_insert(l, compare_device, p);
-         break;
-
-      /* Kept those cases for referance */
-      case EVAS_CALLBACK_MOUSE_IN:
-      case EVAS_CALLBACK_MOUSE_OUT:
-      case EVAS_CALLBACK_MOUSE_WHEEL:
-      case EVAS_CALLBACK_MOUSE_UP:
-      case EVAS_CALLBACK_MULTI_UP:
-      case EVAS_CALLBACK_KEY_DOWN:
-      case EVAS_CALLBACK_KEY_UP:
-         break;
-
-      default:
-         return l;
+   if ((pe->event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
+         (pe->event_type == EVAS_CALLBACK_MULTI_DOWN))
+     {  /* Add touched device on DOWN event only */
+        p = malloc(sizeof(Pointer_Event));
+        /* Freed in _remove_touched_device()    */
+        memcpy(p, pe, sizeof(Pointer_Event));
+        return eina_list_append(list, p);
      }
 
-   return l;
+   return list;
 }
-/* END   - Functions to manage recent device event list */
+/* END   - Functions to manage touched-device list */
 
 /**
  * @internal
@@ -448,10 +410,12 @@ consume_event(Widget_Data *wd, void *event_info,
 {  /* Mark EVAS_EVENT_FLAG_ON_HOLD on events that are used by gesture layer */
    /* ev_flags != EVAS_EVENT_FLAG_NONE means target used event and g-layer  */
    /* should not refeed this event.                                         */
-   if(!event_info)
+   if (!event_info)
      return;  /* This happens when restarting gestures  */
 
-   if ((ev_flags) || (!wd->repeat_events))
+   if (!wd->repeat_events) ev_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+
+   if (ev_flags)
      {
         switch(event_type)
           {
@@ -626,19 +590,19 @@ _clear_if_finished(Evas_Object *obj)
 }
 
 static Eina_Bool
-_inside(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
+_inside(Evas_Coord xx1, Evas_Coord yy1, Evas_Coord xx2, Evas_Coord yy2)
 {
-   int w = elm_finger_size_get() >> 1; /* Finger size devided by 2 */
-   if (x1 < (x2 - w))
+   int w = _elm_config->finger_size >> 1; /* Finger size devided by 2 */
+   if (xx1 < (xx2 - w))
      return EINA_FALSE;
 
-   if (x1 > (x2 + w))
+   if (xx1 > (xx2 + w))
      return EINA_FALSE;
 
-   if (y1 < (y2 - w))
+   if (yy1 < (yy2 - w))
      return EINA_FALSE;
 
-   if (y1 > (y2 + w))
+   if (yy1 > (yy2 + w))
      return EINA_FALSE;
 
    return EINA_TRUE;
@@ -655,10 +619,15 @@ _tap_gestures_test_reset(Gesture_Info *gesture)
      return;
 
    Widget_Data *wd = elm_widget_data_get(gesture->obj);
-   wd->dbl_timeout = NULL;
    Eina_List *data;
    Pointer_Event *pe;
 
+   if (wd->dbl_timeout)
+     {
+        ecore_timer_del(wd->dbl_timeout);
+        wd->dbl_timeout = NULL;
+     }
+
    if (!gesture->data)
      return;
 
@@ -686,10 +655,14 @@ _n_long_tap_test_reset(Gesture_Info *gesture)
    Eina_List *l;
    Pointer_Event *p;
    EINA_LIST_FOREACH(st->touched, l, p)
-      free(p);
+     free(p);
 
    eina_list_free(st->touched);
-   if (st->timeout) ecore_timer_del(st->timeout);
+   if (st->timeout)
+     {
+        ecore_timer_del(st->timeout);
+        st->timeout = NULL;
+     }
    memset(gesture->data, 0, sizeof(Long_Tap_Type));
 }
 
@@ -896,9 +869,9 @@ _add_device_pending(Eina_List *list, void *event, Evas_Callback_Type event_type)
      }
 
    if (!eina_list_search_unsorted_list(list, device_in_pending_list,
-            (intptr_t*) device))
+                                       (void *)(intptr_t)device))
      {
-        return eina_list_append(list, (intptr_t*) device);
+        return eina_list_append(list, (void *)(intptr_t)device);
      }
 
    return list;
@@ -926,7 +899,7 @@ _device_is_pending(Eina_List *list, void *event, Evas_Callback_Type event_type)
      }
 
    return eina_list_search_unsorted_list(list, device_in_pending_list,
-         (intptr_t *) device);
+                                         (void *)(intptr_t)device);
 }
 
 /**
@@ -953,7 +926,7 @@ _event_history_clear(Evas_Object *obj)
    Gesture_Info *p;
    Evas *e = evas_object_evas_get(obj);
    Eina_Bool gesture_found = EINA_FALSE;
-   for (i = ELM_GESTURE_FIRST ; i < ELM_GESTURE_LAST; i++)
+   for (i = ELM_GESTURE_FIRST; i < ELM_GESTURE_LAST; i++)
      {
         p = wd->gesture[i];
         if (p)
@@ -975,7 +948,8 @@ _event_history_clear(Evas_Object *obj)
      {  /* We do not clear a long-tap gesture if fingers still on surface */
         /* and gesture timer still pending to test gesture state          */
         Long_Tap_Type *st = wd->gesture[ELM_GESTURE_N_LONG_TAPS]->data;
-        if((!eina_list_count(st->touched)) || (!st->timeout))
+        if ((st) &&  /* st not allocated if clear occurs before 1st input */
+              ((!eina_list_count(st->touched)) || (!st->timeout)))
           _n_long_tap_test_reset(wd->gesture[ELM_GESTURE_N_LONG_TAPS]);
      }
 
@@ -1012,16 +986,14 @@ _event_history_clear(Evas_Object *obj)
 
              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;
+                  wd->pending = eina_list_remove_list(wd->pending, pending);
                }
              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);
@@ -1111,10 +1083,7 @@ _del_hook(Evas_Object *obj)
 
    Pointer_Event *data;
    EINA_LIST_FREE(wd->touched, data)
-      free(data);
-
-   EINA_LIST_FREE(wd->recent_device_event, data)
-      free(data);
+     free(data);
 
    if (!elm_widget_disabled_get(obj))
      _unregister_callbacks(obj);
@@ -1154,8 +1123,8 @@ compare_match_fingers(const void *data1, const void *data2)
 
 static int
 compare_pe_device(const void *data1, const void *data2)
-{  /* Compare coords of first item in list to cur coords */
-   const Pointer_Event *pe1 = eina_list_data_get(eina_list_last(data1));
+{  /* Compare device of first item in list to our pe device */
+   const Pointer_Event *pe1 = eina_list_data_get(data1);
    const Pointer_Event *pe2 = data2;
 
    /* Only match if last was a down event */
@@ -1163,7 +1132,6 @@ compare_pe_device(const void *data1, const void *data2)
          (pe1->event_type != EVAS_CALLBACK_MOUSE_DOWN))
      return 1;
 
-
    if (pe1->device == pe2->device)
      return 0;
    else if (pe1->device < pe2->device)
@@ -1203,32 +1171,55 @@ _record_pointer_event(Taps_Type *st, Eina_List *pe_list, Pointer_Event *pe,
 /**
  * @internal
  *
- * This function sets state a tap-gesture to END or ABORT
+ * This function checks if the tap gesture is done.
  *
  * @param data gesture info pointer
+ * @return EINA_TRUE if it is done.
  *
  * @ingroup Elm_Gesture_Layer
  */
-static void
-_tap_gesture_finish(void *data)
-{  /* This function will test each tap gesture when timer expires */
-   Gesture_Info *gesture = data;
-   Elm_Gesture_State s = ELM_GESTURE_STATE_END;
+static Eina_Bool
+_tap_gesture_check_finish(Gesture_Info *gesture)
+{
    /* Here we check if taps-gesture was completed successfuly */
    /* Count how many taps were recieved on each device then   */
    /* determine if it matches n_taps_needed defined on START  */
    Taps_Type *st = gesture->data;
    Eina_List *l;
    Eina_List *pe_list;
+   if (!st || !st->l) return EINA_FALSE;
    EINA_LIST_FOREACH(st->l, l, pe_list)
      {
         if (eina_list_count(pe_list) != st->n_taps_needed)
           {  /* No match taps number on device, ABORT */
-             s = ELM_GESTURE_STATE_ABORT;
-             break;
+             return EINA_FALSE;
           }
      }
 
+   return EINA_TRUE;
+}
+
+/**
+ * @internal
+ *
+ * This function sets state a tap-gesture to END or ABORT
+ *
+ * @param data gesture info pointer
+ *
+ * @ingroup Elm_Gesture_Layer
+ */
+static void
+_tap_gesture_finish(void *data)
+{  /* This function will test each tap gesture when timer expires */
+   Elm_Gesture_State s = ELM_GESTURE_STATE_ABORT;
+   Gesture_Info *gesture = data;
+   Taps_Type *st = gesture->data;
+
+   if (_tap_gesture_check_finish(gesture))
+     {
+        s = ELM_GESTURE_STATE_END;
+     }
+
    st->info.n = eina_list_count(st->l);
    _set_state(gesture, s, gesture->info, EINA_FALSE);
    _tap_gestures_test_reset(gesture);
@@ -1251,13 +1242,13 @@ _multi_tap_timeout(void *data)
    if (!wd) return EINA_FALSE;
 
    if (IS_TESTED(ELM_GESTURE_N_TAPS))
-     _tap_gesture_finish(wd->gesture[ELM_GESTURE_N_TAPS]);
+      _tap_gesture_finish(wd->gesture[ELM_GESTURE_N_TAPS]);
 
    if (IS_TESTED(ELM_GESTURE_N_DOUBLE_TAPS))
-   _tap_gesture_finish(wd->gesture[ELM_GESTURE_N_DOUBLE_TAPS]);
+      _tap_gesture_finish(wd->gesture[ELM_GESTURE_N_DOUBLE_TAPS]);
 
    if (IS_TESTED(ELM_GESTURE_N_TRIPLE_TAPS))
-   _tap_gesture_finish(wd->gesture[ELM_GESTURE_N_TRIPLE_TAPS]);
+      _tap_gesture_finish(wd->gesture[ELM_GESTURE_N_TRIPLE_TAPS]);
 
    _clear_if_finished(data);
    wd->dbl_timeout = NULL;
@@ -1291,7 +1282,7 @@ _long_tap_timeout(void *data)
 /**
  * @internal
  *
- * This function checks if a tap gesture should start
+ * This function checks the state of a tap gesture.
  *
  * @param wd Gesture Layer Widget Data.
  * @param pe The recent input event as stored in pe struct.
@@ -1300,15 +1291,16 @@ _long_tap_timeout(void *data)
  * @param gesture what gesture is tested
  * @param how many taps for this gesture (1, 2 or 3)
  *
- * @return Flag to determine if we need to set a timer for finish
- *
  * @ingroup Elm_Gesture_Layer
  */
-static Eina_Bool
-_tap_gesture_start(Widget_Data *wd, Pointer_Event *pe,
+static void
+_tap_gesture_test(Widget_Data *wd, Pointer_Event *pe,
       void *event_info, Evas_Callback_Type event_type,
       Gesture_Info *gesture, int taps)
 {  /* Here we fill Tap struct */
+   if (!pe)
+      return;
+
    Taps_Type *st = gesture->data;
    if (!st)
      {  /* Allocated once on first time */
@@ -1324,8 +1316,30 @@ _tap_gesture_start(Widget_Data *wd, Pointer_Event *pe,
      {
       case EVAS_CALLBACK_MULTI_DOWN:
       case EVAS_CALLBACK_MOUSE_DOWN:
+         /* Check if got tap on same cord was tapped before */
          pe_list = eina_list_search_unsorted(st->l, compare_match_fingers, pe);
+
+         if ((!pe_list) &&
+               eina_list_search_unsorted(st->l, compare_pe_device, pe))
+           {  /* This device was touched in other cord before completion */
+              ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
+                    &st->info, EINA_FALSE);
+              consume_event(wd, event_info, event_type, ev_flag);
+
+              return;
+           }
+
          pe_list = _record_pointer_event(st, pe_list, pe, wd, event_info, event_type);
+         if (!wd->dbl_timeout)
+           {
+              wd->dbl_timeout = ecore_timer_add(ELM_GESTURE_TAP_TIMEOUT,
+                    _multi_tap_timeout, gesture->obj);
+           }
+         else
+           {
+              ecore_timer_reset(wd->dbl_timeout);
+           }
+
          if ((pe->device == 0) && (eina_list_count(pe_list) == 1))
            {  /* This is the first mouse down we got */
               ev_flag = _set_state(gesture, ELM_GESTURE_STATE_START,
@@ -1334,7 +1348,13 @@ _tap_gesture_start(Widget_Data *wd, Pointer_Event *pe,
 
               st->n_taps_needed = taps * 2; /* count DOWN and UP */
 
-              return EINA_TRUE;
+              return;
+           }
+         else if (eina_list_count(pe_list) > st->n_taps_needed)
+           {
+              /* If we arleady got too many touches for this gesture. */
+              ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
+                    &st->info, EINA_FALSE);
            }
 
          break;
@@ -1343,9 +1363,23 @@ _tap_gesture_start(Widget_Data *wd, Pointer_Event *pe,
       case EVAS_CALLBACK_MOUSE_UP:
          pe_list = eina_list_search_unsorted(st->l, compare_pe_device, pe);
          if (!pe_list)
-           return EINA_FALSE;
+           return;
 
          pe_list = _record_pointer_event(st, pe_list, pe, wd, event_info, event_type);
+
+         if (((gesture->g_type == ELM_GESTURE_N_TAPS) &&
+                  !IS_TESTED(ELM_GESTURE_N_DOUBLE_TAPS) &&
+                  !IS_TESTED(ELM_GESTURE_N_TRIPLE_TAPS)) ||
+               ((gesture->g_type == ELM_GESTURE_N_DOUBLE_TAPS) &&
+                !IS_TESTED(ELM_GESTURE_N_TRIPLE_TAPS)))
+           {
+              if (_tap_gesture_check_finish(gesture))
+                {
+                   _tap_gesture_finish(gesture);
+                   return;
+                }
+           }
+
          break;
 
       case EVAS_CALLBACK_MULTI_MOVE:
@@ -1366,52 +1400,7 @@ _tap_gesture_start(Widget_Data *wd, Pointer_Event *pe,
          break;
 
       default:
-         return EINA_FALSE;
-     }
-
-   return EINA_FALSE;
-}
-
-
-/**
- * @internal
- *
- * This function checks all click/tap and double/triple taps
- *
- * @param obj The gesture-layer object.
- * @param pe The recent input event as stored in pe struct.
- * @param event_info Original input event pointer.
- * @param event_type Type of original input event.
- *
- * @ingroup Elm_Gesture_Layer
- */
-static void
-_tap_gestures_test(Evas_Object *obj, Pointer_Event *pe,
-      void *event_info, Evas_Callback_Type event_type)
-{  /* Here we fill Recent_Taps struct and fire-up click/tap timers */
-   Eina_Bool need_timer = EINA_FALSE;
-   Widget_Data *wd = elm_widget_data_get(obj);
-   if (!wd) return;
-
-   if (!pe)   /* this happens when unhandled event arrived */
-     return;  /* see _make_pointer_event function */
-
-   if (IS_TESTED(ELM_GESTURE_N_TAPS))
-     need_timer |= _tap_gesture_start(wd, pe, event_info, event_type,
-           wd->gesture[ELM_GESTURE_N_TAPS], 1);
-
-   if (IS_TESTED(ELM_GESTURE_N_DOUBLE_TAPS))
-     need_timer |= _tap_gesture_start(wd, pe, event_info, event_type,
-           wd->gesture[ELM_GESTURE_N_DOUBLE_TAPS], 2);
-
-   if (IS_TESTED(ELM_GESTURE_N_TRIPLE_TAPS))
-     need_timer |= _tap_gesture_start(wd, pe, event_info, event_type,
-           wd->gesture[ELM_GESTURE_N_TRIPLE_TAPS], 3);
-
-   if ((need_timer) && (!wd->dbl_timeout))
-     {  /* Set a timer to finish these gestures */
-        wd->dbl_timeout = ecore_timer_add(0.4, _multi_tap_timeout,
-              obj);
+         return ;
      }
 }
 
@@ -1426,9 +1415,10 @@ _tap_gestures_test(Evas_Object *obj, Pointer_Event *pe,
  * @ingroup Elm_Gesture_Layer
  */
 static void
-_compute_taps_center(Long_Tap_Type *st, Pointer_Event *pe)
+_compute_taps_center(Long_Tap_Type *st,
+      Evas_Coord *x_out, Evas_Coord *y_out, Pointer_Event *pe)
 {
-   if(!eina_list_count(st->touched))
+   if (!eina_list_count(st->touched))
      return;
 
    Eina_List *l;
@@ -1448,8 +1438,8 @@ _compute_taps_center(Long_Tap_Type *st, Pointer_Event *pe)
           }
      }
 
-   st->info.x = x / eina_list_count(st->touched);
-   st->info.y = y / eina_list_count(st->touched);
+   *x_out = x / eina_list_count(st->touched);
+   *y_out = y / eina_list_count(st->touched);
 }
 
 /**
@@ -1468,17 +1458,16 @@ _compute_taps_center(Long_Tap_Type *st, Pointer_Event *pe)
  */
 static void
 _n_long_tap_test(Evas_Object *obj, Pointer_Event *pe,
-      void *event_info, Evas_Callback_Type event_type,
-      Elm_Gesture_Types g_type)
+                 void *event_info, Evas_Callback_Type event_type,
+                 Elm_Gesture_Type g_type)
 {  /* Here we fill Recent_Taps struct and fire-up click/tap timers */
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
 
    if (!pe)   /* this happens when unhandled event arrived */
-     return; /* see _make_pointer_event function */
-
+     return;  /* see _make_pointer_event function */
    Gesture_Info *gesture = wd->gesture[g_type];
-   if (!gesture ) return;
+   if (!gesture) return;
 
    Long_Tap_Type *st = gesture->data;
    if (!st)
@@ -1493,64 +1482,91 @@ _n_long_tap_test(Evas_Object *obj, Pointer_Event *pe,
      {
       case EVAS_CALLBACK_MULTI_DOWN:
       case EVAS_CALLBACK_MOUSE_DOWN:
-         st->touched = _add_touched_device(st->touched, pe);
-         st->info.n = eina_list_count(st->touched);
-         if ((pe->device == 0) && (eina_list_count(st->touched) == 1))
-           {  /* This is the first mouse down we got */
-              st->info.timestamp = pe->timestamp;
+        st->touched = _add_touched_device(st->touched, pe);
+        st->info.n = eina_list_count(st->touched);
+        if (st->info.n > st->max_touched)
+          st->max_touched = st->info.n;
+        else
+          {  /* User removed finger from touch, then put back - ABORT */
+             if ((gesture->state == ELM_GESTURE_STATE_START) ||
+                 (gesture->state == ELM_GESTURE_STATE_MOVE))
+               {
+                  ev_flag =_set_state(gesture, ELM_GESTURE_STATE_ABORT,
+                                      &st->info, EINA_FALSE);
+                  consume_event(wd, event_info, event_type, ev_flag);
+               }
+          }
 
-              /* To test long tap */
-              /* When this timer expires, gesture STARTED */
-              if (!st->timeout)
-                st->timeout = ecore_timer_add(wd->long_tap_start_timeout,
-                      _long_tap_timeout, gesture);
-           }
+        if ((pe->device == 0) && (eina_list_count(st->touched) == 1))
+          {  /* This is the first mouse down we got */
+             st->info.timestamp = pe->timestamp;
 
-         consume_event(wd, event_info, event_type, ev_flag);
-         _compute_taps_center(st, pe);
-         break;
+             /* To test long tap */
+             /* When this timer expires, gesture STARTED */
+             if (!st->timeout)
+               st->timeout = ecore_timer_add(wd->long_tap_start_timeout,
+                                             _long_tap_timeout, gesture);
+          }
+
+        consume_event(wd, event_info, event_type, ev_flag);
+        _compute_taps_center(st, &st->info.x, &st->info.y, pe);
+        st->center_x = st->info.x;
+        st->center_y = st->info.y;
+        break;
 
       case EVAS_CALLBACK_MULTI_UP:
       case EVAS_CALLBACK_MOUSE_UP:
-         st->touched = _remove_touched_device(st->touched, pe);
-         if (st->info.n &&
-               ((gesture->state == ELM_GESTURE_STATE_START) ||
+        st->touched = _remove_touched_device(st->touched, pe);
+        _compute_taps_center(st, &st->center_x, &st->center_y, pe);
+        if (st->info.n &&
+            ((gesture->state == ELM_GESTURE_STATE_START) ||
                 (gesture->state == ELM_GESTURE_STATE_MOVE)))
-           {  /* Report END only for gesture that STARTed */
-              if (eina_list_count(st->touched) == 0)
-                {  /* Report END only at last release event */
-                   ev_flag =_set_state(gesture, ELM_GESTURE_STATE_END,
-                         &st->info, EINA_FALSE);
-                   consume_event(wd, event_info, event_type, ev_flag);
-                }
-           }
-         else
-           {  /* Stop test, user lifts finger before long-start */
-              if (st->timeout) ecore_timer_del(st->timeout);
-              st->timeout = NULL;
-              ev_flag =_set_state(gesture, ELM_GESTURE_STATE_ABORT,
-                    &st->info, EINA_FALSE);
-              consume_event(wd, event_info, event_type, ev_flag);
-           }
+          {  /* Report END only for gesture that STARTed */
+             if (eina_list_count(st->touched) == 0)
+               {  /* Report END only at last release event */
+                  ev_flag =_set_state(gesture, ELM_GESTURE_STATE_END,
+                                      &st->info, EINA_FALSE);
+                  consume_event(wd, event_info, event_type, ev_flag);
+               }
+          }
+        else
+          {  /* Stop test, user lifts finger before long-start */
+             if (st->timeout) ecore_timer_del(st->timeout);
+             st->timeout = NULL;
+             ev_flag =_set_state(gesture, ELM_GESTURE_STATE_ABORT,
+                                 &st->info, EINA_FALSE);
+             consume_event(wd, event_info, event_type, ev_flag);
+          }
 
-         break;
+        break;
 
       case EVAS_CALLBACK_MULTI_MOVE:
       case EVAS_CALLBACK_MOUSE_MOVE:
-         if(st->info.n &&
-               ((gesture->state == ELM_GESTURE_STATE_START) ||
-                (gesture->state == ELM_GESTURE_STATE_MOVE)))
-           {  /* Report MOVE only if STARTED */
-              _compute_taps_center(st, pe);
-              /* Report MOVE if gesture started */
-              ev_flag = _set_state(gesture, ELM_GESTURE_STATE_MOVE,
-                    &st->info, EINA_TRUE);
-              consume_event(wd, event_info, event_type, ev_flag);
-           }
-         break;
+        if (st->info.n &&
+           ((gesture->state == ELM_GESTURE_STATE_START) ||
+               (gesture->state == ELM_GESTURE_STATE_MOVE)))
+          {  /* Report MOVE only if STARTED */
+             Evas_Coord x = 0;
+             Evas_Coord y = 0;
+             Elm_Gesture_State state_to_report = ELM_GESTURE_STATE_MOVE;
+
+             _compute_taps_center(st, &x, &y, pe);
+             /* ABORT if user moved fingers out of tap area */
+#if defined(DEBUG_GESTURE_LAYER)
+             printf("%s x,y=(%d,%d) st->info.x,st->info.y=(%d,%d)\n",__func__,x,y,st->info.x,st->info.y);
+#endif
+             if (!_inside(x, y, st->center_x, st->center_y))
+               state_to_report = ELM_GESTURE_STATE_ABORT;
+
+             /* Report MOVE if gesture started */
+             ev_flag = _set_state(gesture, state_to_report,
+                                  &st->info, EINA_TRUE);
+             consume_event(wd, event_info, event_type, ev_flag);
+          }
+        break;
 
       default:
-         return;
+        return;
      }
 }
 
@@ -1572,13 +1588,14 @@ _n_long_tap_test(Evas_Object *obj, Pointer_Event *pe,
  * @ingroup Elm_Gesture_Layer
  */
 static void
-_set_momentum(Elm_Gesture_Momentum_Info *momentum, Evas_Coord x1, Evas_Coord y1,
-      Evas_Coord x2, Evas_Coord y2, unsigned int t1x, unsigned int t1y,
-      unsigned int t2)
+_set_momentum(Elm_Gesture_Momentum_Info *momentum,
+              Evas_Coord xx1, Evas_Coord yy1,
+              Evas_Coord xx2, Evas_Coord yy2,
+              unsigned int t1x, unsigned int t1y, unsigned int t2)
 {
    Evas_Coord velx = 0, vely = 0, vel;
-   Evas_Coord dx = x2 - x1;
-   Evas_Coord dy = y2 - y1;
+   Evas_Coord dx = xx2 - xx1;
+   Evas_Coord dy = yy2 - yy1;
    int dtx = t2 - t1x;
    int dty = t2 - t1y;
    if (dtx > 0)
@@ -1612,65 +1629,57 @@ _set_momentum(Elm_Gesture_Momentum_Info *momentum, Evas_Coord x1, Evas_Coord y1,
  * @param x2 second finger x location.
  * @param y2 second finger y location.
  *
- * @return angle of the line between (x1,y1), (x2,y2) in Radians.
+ * @return angle of the line between (x1,y1), (x2,y2) in Deg.
+ * Angles now are given in DEG, not RAD.
+ * ZERO angle at 12-oclock, growing clockwise.
  *
  * @ingroup Elm_Gesture_Layer
  */
 static double
-get_angle(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
+get_angle(Evas_Coord xx1, Evas_Coord yy1, Evas_Coord xx2, Evas_Coord yy2)
 {
-   double a, xx, yy;
-   xx = fabs(x2 - x1);
-   yy = fabs(y2 - y1);
+   double a, xx, yy, rt = (-1);
+   xx = fabs(xx2 - xx1);
+   yy = fabs(yy2 - yy1);
 
-   if (((int) xx) && ((int) yy))
+   if (((int)xx) && ((int)yy))
      {
-        a = atan(yy / xx);
-        if (x1 < x2)
+        rt = a = RAD2DEG(atan(yy / xx));
+        if (xx1 < xx2)
           {
-             if (y1 < y2)
-               {
-                  return RAD_360DEG - a;
-               }
-             else
-               {
-                  return (a);
-               }
+             if (yy1 < yy2) rt = 360 - a;
+             else rt = a;
           }
         else
           {
-             if (y1 < y2)
-               {
-                  return RAD_180DEG + a;
-               }
-             else
-               {
-                  return RAD_180DEG - a;
-               }
+             if (yy1 < yy2) rt = 180 + a;
+             else rt = 180 - a;
           }
      }
 
-   if (((int) xx))
-     {  /* Horizontal line */
-        if (x2 < x1)
-          {
-             return RAD_180DEG;
+   if (rt < 0)
+     {  /* Do this only if rt is not set */
+        if (((int)xx))
+          {  /* Horizontal line */
+             if (xx2 < xx1) rt = 180;
+             else rt = 0.0;
           }
         else
-          {
-             return 0.0;
+          {  /* Vertical line */
+             if (yy2 < yy1) rt = 90;
+             else rt = 270;
           }
      }
 
-   /* Vertical line */
-   if (y2 < y1)
-     {
-        return RAD_90DEG;
-     }
-   else
-     {
-        return RAD_270DEG;
-     }
+   /* Now we want to change from:
+    *                      90                   0
+    * original circle   180   0   We want:  270   90
+    *                     270                 180
+    */
+   rt = 450 - rt;
+   if (rt >= 360) rt -= 360;
+
+   return rt;
 }
 
 /**
@@ -1689,25 +1698,22 @@ get_angle(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
  * @ingroup Elm_Gesture_Layer
  */
 static void
-get_vector(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2,
-      Evas_Coord *l, double *a)
+get_vector(Evas_Coord xx1, Evas_Coord yy1, Evas_Coord xx2, Evas_Coord yy2,
+           Evas_Coord *l, double *a)
 {
    Evas_Coord xx, yy;
-   xx = x2 - x1;
-   yy = y2 - y1;
-   *l = (Evas_Coord) sqrt(xx*xx + yy*yy);
-   *a = get_angle(x1, y1, x2, y2);
+   xx = xx2 - xx1;
+   yy = yy2 - yy1;
+   *l = (Evas_Coord) sqrt((xx * xx) + (yy * yy));
+   *a = get_angle(xx1, yy1, xx2, yy2);
 }
 
 static int
-_get_direction(Evas_Coord x1, Evas_Coord x2)
+_get_direction(Evas_Coord xx1, Evas_Coord xx2)
 {
-   if (x1 == x2)
-     return 0;
-   else if (x2 < x1)
-     return -1;
-   else
-     return 1;
+   if (xx2 < xx1) return -1;
+   if (xx2 > xx1) return 1;
+   return 0;
 }
 /**
  * @internal
@@ -1723,16 +1729,25 @@ _get_direction(Evas_Coord x1, Evas_Coord x2)
  */
 static void
 _momentum_test(Evas_Object *obj, Pointer_Event *pe,
-      void *event_info, Evas_Callback_Type event_type,
-      Elm_Gesture_Types g_type)
+               void *event_info, Evas_Callback_Type event_type,
+               Elm_Gesture_Type g_type)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    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 */
+
    Momentum_Type *st = gesture->data;
-   Elm_Gesture_State state_to_report;
+   Elm_Gesture_State state_to_report = ELM_GESTURE_STATE_MOVE;
    if (!st)
      {  /* Allocated once on first time */
         st = calloc(1, sizeof(Momentum_Type));
@@ -1743,38 +1758,82 @@ _momentum_test(Evas_Object *obj, Pointer_Event *pe,
    if (!pe)
      return;
 
+   /* First make avarage of all touched devices to determine center point */
+   Eina_List *l;
+   Pointer_Event *p;
+   Pointer_Event pe_local = *pe;           /* Copy pe event info to local */
+   unsigned int cnt = 1;    /* We start counter counting current pe event */
+   EINA_LIST_FOREACH(wd->touched, l, p)
+      if (p->device != pe_local.device)
+        {
+           pe_local.x += p->x;
+           pe_local.y += p->y;
+           cnt++;
+        }
+
+
+   /* Compute avarage to get center point */
+   pe_local.x /= cnt;
+   pe_local.y /= cnt;
+
+   /* If user added finger - reset gesture */
+   if ((st->info.n) && (st->info.n < cnt))
+     state_to_report = ELM_GESTURE_STATE_ABORT;
+
+
+   if (st->info.n < cnt)
+     st->info.n = cnt;
+
    Evas_Event_Flags ev_flag = EVAS_EVENT_FLAG_NONE;
    switch (event_type)
      {
       case EVAS_CALLBACK_MOUSE_DOWN:
+      case EVAS_CALLBACK_MULTI_DOWN:
       case EVAS_CALLBACK_MOUSE_MOVE:
+      case EVAS_CALLBACK_MULTI_MOVE:
          if (!st->t_st_x)
            {
               if ((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
+                    (event_type == EVAS_CALLBACK_MULTI_DOWN) ||
                     (wd->glayer_continues_enable)) /* start also on MOVE */
                 {  /* We start on MOVE when cont-enabled only */
-                   st->line_st.x = st->line_end.x = pe->x;
-                   st->line_st.y = st->line_end.y = pe->y;
-                   st->t_st_x = st->t_st_y = st->t_end = pe->timestamp;
+                   st->line_st.x = st->line_end.x = pe_local.x;
+                   st->line_st.y = st->line_end.y = pe_local.y;
+                   st->t_st_x = st->t_st_y = st->t_end = pe_local.timestamp;
                    st->xdir = st->ydir = 0;
-                   st->info.x2 = st->info.x1 = pe->x;
-                   st->info.y2 = st->info.y1 = pe->y;
-                   st->info.tx = st->info.ty = pe->timestamp;
+                   st->info.x2 = st->info.x1 = pe_local.x;
+                   st->info.y2 = st->info.y1 = pe_local.y;
+                   st->info.tx = st->info.ty = pe_local.timestamp;
                    ev_flag = _set_state(gesture, ELM_GESTURE_STATE_START,
                          &st->info, EINA_FALSE);
                    consume_event(wd, event_info, event_type, ev_flag);
-
                 }
 
               return;
            }
 
-         state_to_report = ELM_GESTURE_STATE_MOVE;
-         if ((pe->timestamp - ELM_GESTURE_MOMENTUM_TIMEOUT) > st->t_end)
+
+         if (st->t_up)
+           {
+              Eina_Bool force = EINA_TRUE;  /* for move state */
+              if ((st->t_up + ELM_GESTURE_MULTI_TIMEOUT) < pe_local.timestamp)
+                {  /* ABORT if got DOWN or MOVE event after UP+timeout */
+                   state_to_report = ELM_GESTURE_STATE_ABORT;
+                   force = EINA_FALSE;
+                }
+
+              /* We report state but don't compute momentum now */
+              ev_flag = _set_state(gesture, state_to_report, &st->info,
+                    force);
+              consume_event(wd, event_info, event_type, ev_flag);
+              return; /* Stop computing when user remove finger */
+           }
+
+         if ((pe_local.timestamp - ELM_GESTURE_MOMENTUM_TIMEOUT) > st->t_end)
            {  /*  Too long of a wait, reset all values */
-              st->line_st.x = pe->x;
-              st->line_st.y = pe->y;
-              st->t_st_y = st->t_st_x = pe->timestamp;
+              st->line_st.x = pe_local.x;
+              st->line_st.y = pe_local.y;
+              st->t_st_y = st->t_st_x = pe_local.timestamp;
               st->info.tx = st->t_st_x;
               st->info.ty = st->t_st_y;
               st->xdir = st->ydir = 0;
@@ -1782,16 +1841,16 @@ _momentum_test(Evas_Object *obj, Pointer_Event *pe,
          else
            {
               int xdir, ydir;
-              xdir = _get_direction(st->line_st.x, pe->x);
-              ydir = _get_direction(st->line_st.y, pe->y);
-              if (!xdir || (xdir == (-st->xdir)))
+              xdir = _get_direction(st->line_end.x, pe_local.x);
+              ydir = _get_direction(st->line_end.y, pe_local.y);
+              if (xdir && (xdir != st->xdir))
                 {
                    st->line_st.x = st->line_end.x;
                    st->info.tx = st->t_st_x = st->t_end;
                    st->xdir = xdir;
                 }
 
-              if (!ydir || (ydir == (-st->ydir)))
+              if (ydir && (ydir != st->ydir))
                 {
                    st->line_st.y = st->line_end.y;
                    st->info.ty = st->t_st_y = st->t_end;
@@ -1799,11 +1858,13 @@ _momentum_test(Evas_Object *obj, Pointer_Event *pe,
                 }
            }
 
-         st->info.x2 = st->line_end.x = pe->x;
-         st->info.y2 = st->line_end.y = pe->y;
-         st->t_end = pe->timestamp;
-         _set_momentum(&st->info, st->line_st.x, st->line_st.y, pe->x, pe->y,
-               st->t_st_x, st->t_st_y, pe->timestamp);
+         st->info.x2 = st->line_end.x = pe_local.x;
+         st->info.y2 = st->line_end.y = pe_local.y;
+         st->t_end = pe_local.timestamp;
+         _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, state_to_report, &st->info,
                EINA_TRUE);
          consume_event(wd, event_info, event_type, ev_flag);
@@ -1811,38 +1872,35 @@ _momentum_test(Evas_Object *obj, Pointer_Event *pe,
 
 
       case EVAS_CALLBACK_MOUSE_UP:
-         /* IGNORE if line info was cleared, like long press, move */
-         if (!st->t_st_x)
+      case EVAS_CALLBACK_MULTI_UP:
+         st->t_up = pe_local.timestamp;       /* Record recent up event time */
+         if ((cnt > 1) ||     /* Ignore if more fingers touch surface        */
+               (!st->t_st_x)) /* IGNORE if info was cleared, long press,move */
            return;
-         state_to_report = ELM_GESTURE_STATE_END;
 
-         if ((pe->timestamp - ELM_GESTURE_MOMENTUM_TIMEOUT) > st->t_end)
+         if ((pe_local.timestamp - ELM_GESTURE_MOMENTUM_TIMEOUT) > st->t_end)
            {  /* Too long of a wait, reset all values */
-              st->line_st.x = pe->x;
-              st->line_st.y = pe->y;
-              st->t_st_y = st->t_st_x = pe->timestamp;
+              st->line_st.x = pe_local.x;
+              st->line_st.y = pe_local.y;
+              st->t_st_y = st->t_st_x = pe_local.timestamp;
               st->xdir = st->ydir = 0;
            }
 
-         st->info.x2 = pe->x;
-         st->info.y2 = pe->y;
-         st->line_end.x = pe->x;
-         st->line_end.y = pe->y;
-         st->t_end = pe->timestamp;
+         st->info.x2 = pe_local.x;
+         st->info.y2 = pe_local.y;
+         st->line_end.x = pe_local.x;
+         st->line_end.y = pe_local.y;
+         st->t_end = pe_local.timestamp;
 
-         _set_momentum(&st->info, st->line_st.x, st->line_st.y, pe->x, pe->y,
-               st->t_st_x, st->t_st_y, pe->timestamp);
+         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;
-
-      case EVAS_CALLBACK_MULTI_UP:
-         ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT, &st->info,
-               EINA_FALSE);
-         consume_event(wd, event_info, event_type, ev_flag);
          return;
 
       default:
@@ -1944,7 +2002,7 @@ _single_line_process(Elm_Gesture_Line_Info *info, Line_Data *st,
  */
 static void
 _n_line_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
-      Evas_Callback_Type event_type, Elm_Gesture_Types g_type)
+      Evas_Callback_Type event_type, Elm_Gesture_Type g_type)
 {
    if (!pe)
      return;
@@ -1953,6 +2011,15 @@ _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 */
+
    Line_Type *st = gesture->data;
    if (!st)
      {
@@ -2008,9 +2075,9 @@ _n_line_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
           {  /* if line direction was set, we test if broke tolerance */
              double a = fabs(angle - line->line_angle);
 
-             double d = (tan(a)) * line->line_length; /* Distance from line */
+             double d = (tan(DEG2RAD(a))) * line->line_length; /* Distance from line */
 #if defined(DEBUG_GESTURE_LAYER)
-             printf("%s a=<%f> d=<%f>\n", __func__, (a * 57.295779513), d);
+             printf("%s a=<%f> d=<%f>\n", __func__, a, d);
 #endif
              if ((d > wd->line_distance_tolerance) || (a > wd->line_angular_tolerance))
                {  /* Broke tolerance: abort line and start a new one */
@@ -2097,7 +2164,7 @@ _n_line_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
           }
      }
 
-   st->info.n = started;
+   st->info.momentum.n = started;
 
 
    if (ended &&
@@ -2120,7 +2187,7 @@ _n_line_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
 
 
    /* We report ABORT if lines length are NOT matching when fingers are up */
-   if ((longest_line_len - shortest_line_len) > (elm_finger_size_get()*2))
+   if ((longest_line_len - shortest_line_len) > (_elm_config->finger_size * 2))
      {
         ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT, &st->info,
               EINA_FALSE);
@@ -2211,24 +2278,24 @@ rotation_broke_tolerance(Rotate_Type *st)
 
    if (low < 0)
      {
-        low += RAD_180DEG;
-        high += RAD_180DEG;
+        low += 180;
+        high += 180;
 
-        if (t < RAD_180DEG)
-          t += RAD_180DEG;
+        if (t < 180)
+          t += 180;
         else
-          t -= RAD_180DEG;
+          t -= 180;
      }
 
-   if (high > RAD_360DEG)
+   if (high > 360)
      {
-        low -= RAD_180DEG;
-        high -= RAD_180DEG;
+        low -= 180;
+        high -= 180;
 
-        if (t < RAD_180DEG)
-          t += RAD_180DEG;
+        if (t < 180)
+          t += 180;
         else
-          t -= RAD_180DEG;
+          t -= 180;
      }
 
 #if defined(DEBUG_GESTURE_LAYER)
@@ -2262,13 +2329,14 @@ rotation_broke_tolerance(Rotate_Type *st)
  * @ingroup Elm_Gesture_Layer
  */
 static Evas_Coord
-get_finger_gap_length(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2,
-      Evas_Coord y2, Evas_Coord *x, Evas_Coord *y)
+get_finger_gap_length(Evas_Coord xx1, Evas_Coord yy1,
+                      Evas_Coord xx2, Evas_Coord yy2,
+                      Evas_Coord *x, Evas_Coord *y)
 {
    double a, b, xx, yy, gap;
-   xx = fabs(x2 - x1);
-   yy = fabs(y2 - y1);
-   gap = sqrt(xx*xx + yy*yy);
+   xx = fabs(xx2 - xx1);
+   yy = fabs(yy2 - yy1);
+   gap = sqrt((xx * xx) + (yy * yy));
 
    /* START - Compute zoom center point */
    /* The triangle defined as follows:
@@ -2281,7 +2349,7 @@ get_finger_gap_length(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2,
     *          b
     * http://en.wikipedia.org/wiki/Trigonometric_functions
     *************************************/
-   if (((int) xx) && ((int) yy))
+   if (((int)xx) && ((int)yy))
      {
         double A = atan((yy / xx));
 #if defined(DEBUG_GESTURE_LAYER)
@@ -2289,27 +2357,27 @@ get_finger_gap_length(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2,
 #endif
         a = (Evas_Coord) ((gap / 2) * sin(A));
         b = (Evas_Coord) ((gap / 2) * cos(A));
-        *x = (Evas_Coord) ((x2 > x1) ? (x1 + b) : (x2 + b));
-        *y = (Evas_Coord) ((y2 > y1) ? (y1 + a) : (y2 + a));
+        *x = (Evas_Coord) ((xx2 > xx1) ? (xx1 + b) : (xx2 + b));
+        *y = (Evas_Coord) ((yy2 > yy1) ? (yy1 + a) : (yy2 + a));
      }
    else
      {
-        if ((int) xx)
+        if ((int)xx)
           {  /* horiz line, take half width */
 #if defined(DEBUG_GESTURE_LAYER)
              printf("==== HORIZ ====\n");
 #endif
-             *x = (Evas_Coord) (xx / 2);
-             *y = (Evas_Coord) (y1);
+             *x = (Evas_Coord) ((xx1 + xx2) / 2);
+             *y = (Evas_Coord) (yy1);
           }
 
-        if ((int) yy)
+        if ((int)yy)
           {  /* vert line, take half width */
 #if defined(DEBUG_GESTURE_LAYER)
              printf("==== VERT ====\n");
 #endif
-             *x = (Evas_Coord) (x1);
-             *y = (Evas_Coord) (yy / 2);
+             *x = (Evas_Coord) (xx1);
+             *y = (Evas_Coord) ((yy1 + yy2) / 2);
           }
      }
    /* END   - Compute zoom center point */
@@ -2323,6 +2391,61 @@ get_finger_gap_length(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2,
  * This function is used for computing zoom value.
  *
  * @param st Pointer to zoom data based on user input.
+ * @param tm_end Recent input event timestamp.
+ * @param zoom_val Current computed zoom value.
+ *
+ * @return zoom momentum
+ *
+ * @ingroup Elm_Gesture_Layer
+ */
+static double
+_zoom_momentum_get(Zoom_Type *st, unsigned int tm_end, double zoom_val)
+{
+   unsigned int tm_total;
+   if (!st->m_st_tm)
+     {  /* Init, and we don't start computing momentum yet */
+        st->m_st_tm = st->m_prev_tm = tm_end;
+        st->m_base = zoom_val;
+        return 0.0;
+     }
+
+   if ((tm_end - ELM_GESTURE_MOMENTUM_DELAY) < st->m_st_tm)
+     return 0.0; /* we don't start to compute momentum yet */
+
+   if (st->dir)
+     {  /* if direction was already defined, check if changed */
+        if (((st->dir < 0) && (zoom_val > st->info.zoom)) ||
+              ((st->dir > 0) && (zoom_val < st->info.zoom)))
+          {  /* Direction changed, reset momentum */
+             st->m_st_tm = 0;
+             st->dir = (-st->dir);
+             return 0.0;
+          }
+     }
+   else
+     st->dir = (zoom_val > st->info.zoom) ? 1 : -1;  /* init */
+
+   if ((tm_end - ELM_GESTURE_MOMENTUM_TIMEOUT) > st->m_prev_tm)
+     {
+        st->m_st_tm = 0; /* Rest momentum when waiting too long */
+        return 0.0;
+     }
+
+   st->m_prev_tm = tm_end;
+   tm_total = tm_end - st->m_st_tm;
+
+   if (tm_total)
+     return ((zoom_val - st->m_base)  * 1000) / tm_total;
+   else
+     return 0.0;
+}
+
+/**
+ * @internal
+ *
+ * This function is used for computing zoom value.
+ *
+ * @param st Pointer to zoom data based on user input.
  * @param x1 first finger x location.
  * @param y1 first finger y location.
  * @param x2 second finger x location.
@@ -2333,14 +2456,18 @@ get_finger_gap_length(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2,
  *
  * @ingroup Elm_Gesture_Layer
  */
-/* FIXME change float to double */
 static double
-compute_zoom(Zoom_Type *st, Evas_Coord x1, Evas_Coord y1, unsigned int tm1,
-      Evas_Coord x2, Evas_Coord y2, unsigned int tm2, double zoom_finger_factor)
+compute_zoom(Zoom_Type *st,
+             Evas_Coord xx1, Evas_Coord yy1,
+             Evas_Coord xx2, Evas_Coord yy2,
+             double zoom_finger_factor)
 {
    double rt = 1.0;
-   Evas_Coord diam = get_finger_gap_length(x1, y1, x2, y2,
-         &st->info.x, &st->info.y);
+   unsigned int tm_end = (st->zoom_mv.timestamp > st->zoom_mv1.timestamp) ?
+     st->zoom_mv.timestamp : st->zoom_mv1.timestamp;
+
+   Evas_Coord diam = get_finger_gap_length(xx1, yy1, xx2, yy2,
+                                           &st->info.x, &st->info.y);
 
    st->info.radius = diam / 2;
 
@@ -2370,15 +2497,11 @@ compute_zoom(Zoom_Type *st, Evas_Coord x1, Evas_Coord y1, unsigned int tm1,
    /* We use factor only on the difference between gap-base   */
    /* if gap=120, base=100, we get ((120-100)/100)=0.2*factor */
    rt = ((1.0) + ((((float) diam - (float) st->zoom_base) /
-               (float) st->zoom_base) * zoom_finger_factor));
-
-#if 0
-   /* Momentum: zoom per second: (NOT YET SUPPORTED) */
-   st->info.momentum = (((rt - 1.0) * 1000) / (tm2 - tm1));
-#else
-   (void) tm1;
-   (void) tm2;
-#endif
+                   (float) st->zoom_base) * zoom_finger_factor));
+
+   /* Momentum: zoom per second: */
+   st->info.momentum = _zoom_momentum_get(st, tm_end, rt);
+
    return rt;
 }
 
@@ -2396,7 +2519,7 @@ compute_zoom(Zoom_Type *st, Evas_Coord x1, Evas_Coord y1, unsigned int tm1,
  */
 static void
 _zoom_with_wheel_test(Evas_Object *obj, void *event_info,
-      Evas_Callback_Type event_type, Elm_Gesture_Types g_type)
+      Evas_Callback_Type event_type, Elm_Gesture_Type g_type)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
@@ -2424,6 +2547,9 @@ _zoom_with_wheel_test(Evas_Object *obj, void *event_info,
                          ((gesture_zoom->state == ELM_GESTURE_STATE_START) ||
                           (gesture_zoom->state == ELM_GESTURE_STATE_MOVE)))
                      {  /* User released CTRL after zooming */
+                        st->info.momentum = _zoom_momentum_get(st,
+                              p->timestamp, st->info.zoom);
+
                         ev_flag = _set_state(gesture_zoom,
                               ELM_GESTURE_STATE_END, &st->info, EINA_FALSE);
                         consume_event(wd, event_info, event_type, ev_flag);
@@ -2458,7 +2584,7 @@ _zoom_with_wheel_test(Evas_Object *obj, void *event_info,
 
               /* Using mouse wheel with CTRL for zoom */
               if (st->zoom_wheel || (st->zoom_distance_tolerance == 0))
-                {  /* when (zoom_wheel == NULL) and (zoom_distance_tolerance == 0)
+                {  /* (zoom_wheel == NULL) and (zoom_distance_tolerance == 0)
                       we continue a zoom gesture */
                    force = EINA_TRUE;
                    s = ELM_GESTURE_STATE_MOVE;
@@ -2489,6 +2615,9 @@ _zoom_with_wheel_test(Evas_Object *obj, void *event_info,
               if (st->info.zoom < 0.0)
                 st->info.zoom = 0.0;
 
+              st->info.momentum = _zoom_momentum_get(st,
+                    st->zoom_wheel->timestamp, st->info.zoom);
+
               ev_flag = _set_state(gesture_zoom, s, &st->info, force);
               consume_event(wd, event_info, event_type, ev_flag);
               break;
@@ -2516,7 +2645,7 @@ _zoom_with_wheel_test(Evas_Object *obj, void *event_info,
  */
 static void
 _zoom_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
-      Evas_Callback_Type event_type, Elm_Gesture_Types g_type)
+      Evas_Callback_Type event_type, Elm_Gesture_Type g_type)
 {
    if (!pe)
      return;
@@ -2552,7 +2681,7 @@ _zoom_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
               Eina_List *l;
               Pointer_Event *p;
 
-              if(eina_list_count(wd->touched) > 2)
+              if (eina_list_count(wd->touched) > 2)
                 {  /* Process zoom only when 2 fingers on surface */
                    ev_flag = _set_state(gesture_zoom,
                          ELM_GESTURE_STATE_ABORT, &st->info, EINA_FALSE);
@@ -2612,10 +2741,10 @@ _zoom_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
                 memcpy(&st->zoom_mv1, pe, sizeof(Pointer_Event));
 
               /* Compute change in zoom as fingers move */
-                st->info.zoom = compute_zoom(st,
-                      st->zoom_mv.x, st->zoom_mv.y, st->zoom_mv.timestamp,
-                      st->zoom_mv1.x, st->zoom_mv1.y, st->zoom_mv1.timestamp,
-                      wd->zoom_finger_factor);
+              st->info.zoom = compute_zoom(st,
+                    st->zoom_mv.x, st->zoom_mv.y,
+                    st->zoom_mv1.x, st->zoom_mv1.y,
+                    wd->zoom_finger_factor);
 
               if (!st->zoom_distance_tolerance)
                 {  /* Zoom broke tolerance, report move */
@@ -2671,26 +2800,55 @@ _zoom_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
 
 static void
 _get_rotate_properties(Rotate_Type *st,
-      Evas_Coord x1, Evas_Coord y1, unsigned int tm1,
-      Evas_Coord x2, Evas_Coord y2, unsigned int tm2,
-      double *angle)
-{
-   st->info.radius = get_finger_gap_length(x1, y1, x2, y2,
-         &st->info.x, &st->info.y) / 2;
+                       Evas_Coord xx1, Evas_Coord yy1,
+                       Evas_Coord xx2, Evas_Coord yy2,
+                       double *angle)
+{  /* FIXME: Fix momentum computation, it's wrong */
+   double prev_angle = *angle;
+   st->info.radius = get_finger_gap_length(xx1, yy1, xx2, yy2,
+                                           &st->info.x, &st->info.y) / 2;
+
+   *angle = get_angle(xx1, yy1, xx2, yy2);
 
-   *angle = get_angle(x1, y1, x2, y2);
-#if 0 /* (NOT YET SUPPORTED) */
    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;
+     {  /* Fingers are moving, compute momentum */
+        unsigned int tm_start =
+           (st->rotate_st.timestamp > st->rotate_st1.timestamp)
+           ?  st->rotate_st.timestamp : st->rotate_st1.timestamp;
+        unsigned int tm_end =
+           (st->rotate_mv.timestamp > st->rotate_mv1.timestamp)
+           ? st->rotate_mv.timestamp : st->rotate_mv1.timestamp;
+
+        unsigned int tm_total = tm_end - tm_start;
+        if (tm_total)
+          {  /* Momentum computed as:
+                accumulated roation angle (deg) divided by time */
+             double m = 0;;
+             if (((prev_angle < 90) && ((*angle) > 270)) ||
+                   ((prev_angle > 270) && ((*angle) < 90)))
+               {  /* We circle passing ZERO point */
+                  prev_angle = (*angle);
+               }
+             else m = prev_angle - (*angle);
+
+             st->accum_momentum += m;
+
+             if ((tm_end - st->prev_momentum_tm) < 100)
+               st->prev_momentum += m;
+             else
+               {
+                  if (fabs(st->prev_momentum) < 0.002)
+                    st->accum_momentum = 0.0;  /* reset momentum */
+
+                  st->prev_momentum = 0.0;     /* Start again    */
+               }
+
+             st->prev_momentum_tm = tm_end;
+             st->info.momentum = (st->accum_momentum * 1000) / tm_total;
+          }
      }
    else
      st->info.momentum = 0;
-#else
-   (void) tm1;
-   (void) tm2;
-#endif
 }
 
 /**
@@ -2710,7 +2868,7 @@ _get_rotate_properties(Rotate_Type *st,
  */
 static void
 _rotate_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
-      Evas_Callback_Type event_type, Elm_Gesture_Types g_type)
+      Evas_Callback_Type event_type, Elm_Gesture_Type g_type)
 {
    if (!pe)
      return;
@@ -2720,7 +2878,7 @@ _rotate_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
    if (!wd->gesture[g_type]) return;
 
    Gesture_Info *gesture = wd->gesture[g_type];
-   Rotate_Type *st = gesture->data;
+   Rotate_Type *st;
    if (gesture)
    {
       st = gesture->data;
@@ -2748,7 +2906,7 @@ _rotate_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
               Eina_List *l;
               Pointer_Event *p;
 
-              if(eina_list_count(wd->touched) > 2)
+              if (eina_list_count(wd->touched) > 2)
                 {  /* Process rotate only when 2 fingers on surface */
                    ev_flag = _set_state(gesture,
                          ELM_GESTURE_STATE_ABORT, &st->info, EINA_FALSE);
@@ -2782,9 +2940,8 @@ _rotate_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
                    /* Compute length of line between fingers rotate start */
                    _get_rotate_properties(st,
                          st->rotate_st.x, st->rotate_st.y,
-                         st->rotate_st.timestamp,
                          st->rotate_st1.x, st->rotate_st1.y,
-                         st->rotate_st1.timestamp, &st->info.base_angle);
+                         &st->info.base_angle);
 
                    ev_flag = _set_state(gesture, ELM_GESTURE_STATE_START,
                          &st->info, EINA_FALSE);
@@ -2805,14 +2962,13 @@ _rotate_test(Evas_Object *obj, Pointer_Event *pe, void *event_info,
               /* Compute change in rotate as fingers move */
               _get_rotate_properties(st,
                     st->rotate_mv.x, st->rotate_mv.y,
-                    st->rotate_mv.timestamp,
                     st->rotate_mv1.x, st->rotate_mv1.y,
-                    st->rotate_mv1.timestamp, &st->info.angle);
+                    &st->info.angle);
 
               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)
                      d = (-d);
 
                    if (d >= wd->rotate_step)
@@ -2877,6 +3033,7 @@ _make_pointer_event(void *data, void *event_info,
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return EINA_FALSE;
 
+   memset(pe, '\0', sizeof(*pe));
    switch (event_type)
      {
       case EVAS_CALLBACK_MOUSE_DOWN:
@@ -2947,15 +3104,26 @@ _make_pointer_event(void *data, void *event_info,
  *
  * @ingroup Elm_Gesture_Layer
  */
-void continues_gestures_restart(void *data, Eina_Bool states_reset)
+static void
+continues_gestures_restart(void *data, Eina_Bool states_reset)
 {
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
 
    /* Run through events to restart gestures */
    Gesture_Info *g;
-   Eina_Bool n_lines, n_flicks, zoom, rotate;
+   Eina_Bool n_momentum, n_lines, n_flicks, zoom, rotate;
    /* We turn-on flag for finished, aborted, not-started gestures */
+   g = wd->gesture[ELM_GESTURE_MOMENTUM];
+   n_momentum = (g) ? ((states_reset) | ((g->state != ELM_GESTURE_STATE_START)
+         && (g->state != ELM_GESTURE_STATE_MOVE))) : EINA_FALSE;
+   if (n_momentum)
+     {
+        _momentum_test_reset(wd->gesture[ELM_GESTURE_MOMENTUM]);
+        _set_state(g, ELM_GESTURE_STATE_UNDEFINED, NULL, EINA_FALSE);
+        SET_TEST_BIT(g);
+     }
+
    g = wd->gesture[ELM_GESTURE_N_LINES];
    n_lines = (g) ? ((states_reset) | ((g->state != ELM_GESTURE_STATE_START)
          && (g->state != ELM_GESTURE_STATE_MOVE))) : EINA_FALSE;
@@ -3027,16 +3195,15 @@ _event_process(void *data, Evas_Object *obj __UNUSED__,
    Pointer_Event _pe;
    Pointer_Event *pe = NULL;
    Widget_Data *wd = elm_widget_data_get(data);
-   if (!wd) return;
 
 #if defined(DEBUG_GESTURE_LAYER)
    int i;
    Gesture_Info *g;
    printf("Gesture | State | is tested\n");
-   for(i = ELM_GESTURE_N_TAPS; i < ELM_GESTURE_LAST; i++)
+   for (i = ELM_GESTURE_N_TAPS; i < ELM_GESTURE_LAST; i++)
      {
         g = wd->gesture[i];
-        if(g)
+        if (g)
           printf("   %d       %d       %d\n", i, g->state, g->test);
      }
 #endif
@@ -3049,8 +3216,17 @@ _event_process(void *data, Evas_Object *obj __UNUSED__,
      _n_long_tap_test(data, pe, event_info, event_type,
            ELM_GESTURE_N_LONG_TAPS);
 
-   /* This takes care of single, double and tripple tap */
-   _tap_gestures_test(data, pe, event_info, event_type);
+   if (IS_TESTED(ELM_GESTURE_N_TAPS))
+      _tap_gesture_test(wd, pe, event_info, event_type,
+            wd->gesture[ELM_GESTURE_N_TAPS], 1);
+
+   if (IS_TESTED(ELM_GESTURE_N_DOUBLE_TAPS))
+      _tap_gesture_test(wd, pe, event_info, event_type,
+            wd->gesture[ELM_GESTURE_N_DOUBLE_TAPS], 2);
+
+   if (IS_TESTED(ELM_GESTURE_N_TRIPLE_TAPS))
+      _tap_gesture_test(wd, pe, event_info, event_type,
+            wd->gesture[ELM_GESTURE_N_TRIPLE_TAPS], 3);
 
    if (IS_TESTED(ELM_GESTURE_MOMENTUM))
      _momentum_test(data, pe, event_info, event_type,
@@ -3062,30 +3238,17 @@ _event_process(void *data, Evas_Object *obj __UNUSED__,
    if (IS_TESTED(ELM_GESTURE_N_FLICKS))
      _n_line_test(data, pe, event_info, event_type, ELM_GESTURE_N_FLICKS);
 
-   if (IS_TESTED(ELM_GESTURE_ZOOM))
+   if (_elm_config->glayer_zoom_finger_enable && IS_TESTED(ELM_GESTURE_ZOOM))
      _zoom_test(data, pe, event_info, event_type, ELM_GESTURE_ZOOM);
 
    if (IS_TESTED(ELM_GESTURE_ZOOM))
      _zoom_with_wheel_test(data, event_info, event_type, ELM_GESTURE_ZOOM);
 
-   if (IS_TESTED(ELM_GESTURE_ROTATE))
+   if (_elm_config->glayer_rotate_finger_enable && IS_TESTED(ELM_GESTURE_ROTATE))
      _rotate_test(data, pe, event_info, event_type, ELM_GESTURE_ROTATE);
 
    if (_get_event_flag(event_info, event_type) & EVAS_EVENT_FLAG_ON_HOLD)
      _event_history_add(data, event_info, event_type);
-   else if ((event_type == EVAS_CALLBACK_MOUSE_UP) ||
-         (event_type == EVAS_CALLBACK_MULTI_UP))
-     {
-        Eina_List *pending = _device_is_pending(wd->pending, event_info, event_type);
-        if (pending)
-          {
-             consume_event(wd, event_info, event_type, EVAS_EVENT_FLAG_ON_HOLD);
-             _event_history_add(data, event_info, event_type);
-          }
-     }
-
-   /* Log event to restart gestures */
-   wd->recent_device_event = _add_recent_device_event(wd->recent_device_event, &_pe);
 
    /* we maintain list of touched devices              */
    /* We also use move to track current device x.y pos */
@@ -3214,8 +3377,10 @@ _multi_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
 }
 
 EAPI Eina_Bool
-elm_gesture_layer_hold_events_get(Evas_Object *obj)
+elm_gesture_layer_hold_events_get(const Evas_Object *obj)
 {
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return EINA_FALSE;
 
@@ -3223,61 +3388,90 @@ elm_gesture_layer_hold_events_get(Evas_Object *obj)
 }
 
 EAPI void
-elm_gesture_layer_hold_events_set(Evas_Object *obj, Eina_Bool r)
+elm_gesture_layer_hold_events_set(Evas_Object *obj, Eina_Bool hold_events)
 {
+   ELM_CHECK_WIDTYPE(obj, widtype);
+
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
 
-   wd->repeat_events = !r;
+   wd->repeat_events = !(!!hold_events);
+}
+
+EAPI double
+elm_gesture_layer_zoom_step_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) 0;
+
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return 0;
+
+   return wd->zoom_step;
 }
 
 EAPI void
-elm_gesture_layer_zoom_step_set(Evas_Object *obj, double s)
+elm_gesture_layer_zoom_step_set(Evas_Object *obj, double step)
 {
+   ELM_CHECK_WIDTYPE(obj, widtype);
+
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
 
-   if (s < 0.0)
-     return;
+   if (step < 0) return;
 
-   wd->zoom_step = s;
+   wd->zoom_step = step;
+}
+
+EAPI double
+elm_gesture_layer_rotate_step_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) 0;
+
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return 0;
+
+   return wd->rotate_step;
 }
 
 EAPI void
-elm_gesture_layer_rotate_step_set(Evas_Object *obj, double s)
+elm_gesture_layer_rotate_step_set(Evas_Object *obj, double step)
 {
+   ELM_CHECK_WIDTYPE(obj, widtype);
+
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
 
-   if (s < 0.0)
-     return;
+   if (step < 0) return;
 
-   wd->rotate_step = s;
+   wd->rotate_step = step;
 }
 
 EAPI Eina_Bool
-elm_gesture_layer_attach(Evas_Object *obj, Evas_Object *t)
+elm_gesture_layer_attach(Evas_Object *obj, Evas_Object *target)
 {
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return EINA_FALSE;
 
-   if (!t)
-     return EINA_FALSE;
+   if (!target) return EINA_FALSE;
 
    /* if was attached before, unregister callbacks first */
    if (wd->target)
      _unregister_callbacks(obj);
 
-   wd->target = t;
+   wd->target = target;
 
    _register_callbacks(obj);
    return EINA_TRUE;
 }
 
 EAPI void
-elm_gesture_layer_cb_set(Evas_Object *obj, Elm_Gesture_Types idx,
+elm_gesture_layer_cb_set(Evas_Object *obj, Elm_Gesture_Type idx,
       Elm_Gesture_State cb_type, Elm_Gesture_Event_Cb cb, void *data)
 {
+   ELM_CHECK_WIDTYPE(obj, widtype);
+
    Widget_Data *wd = elm_widget_data_get(obj);
    Gesture_Info *p;
    if (!wd) return;
@@ -3311,12 +3505,8 @@ elm_gesture_layer_add(Evas_Object *parent)
    Evas *e;
    Widget_Data *wd;
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
+   ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
 
-   wd = ELM_NEW(Widget_Data);
-   e = evas_object_evas_get(parent);
-   if (!e) return NULL;
-   obj = elm_widget_add(e);
    ELM_SET_WIDTYPE(widtype, "gesture_layer");
    elm_widget_type_set(obj, "gesture_layer");
    elm_widget_sub_object_add(parent, obj);
@@ -3325,9 +3515,9 @@ elm_gesture_layer_add(Evas_Object *parent)
    elm_widget_disable_hook_set(obj, _disable_hook);
 
    wd->target = NULL;
-   wd->line_min_length =_elm_config->glayer_line_min_length * elm_finger_size_get();
-   wd->zoom_distance_tolerance = _elm_config->glayer_zoom_distance_tolerance * elm_finger_size_get();
-   wd->line_distance_tolerance = _elm_config->glayer_line_distance_tolerance * elm_finger_size_get();
+   wd->line_min_length =_elm_config->glayer_line_min_length * _elm_config->finger_size;
+   wd->zoom_distance_tolerance = _elm_config->glayer_zoom_distance_tolerance * _elm_config->finger_size;
+   wd->line_distance_tolerance = _elm_config->glayer_line_distance_tolerance * _elm_config->finger_size;
    wd->zoom_finger_factor = _elm_config->glayer_zoom_finger_factor;
    wd->zoom_wheel_factor = _elm_config->glayer_zoom_wheel_factor; /* mouse wheel zoom steps */
    wd->rotate_angular_tolerance = _elm_config->glayer_rotate_angular_tolerance;
@@ -3335,7 +3525,7 @@ elm_gesture_layer_add(Evas_Object *parent)
    wd->flick_time_limit_ms = _elm_config->glayer_flick_time_limit_ms;
    wd->long_tap_start_timeout = _elm_config->glayer_long_tap_start_timeout;
    wd->repeat_events = EINA_TRUE;
-   wd->glayer_continues_enable = EINA_FALSE;//_elm_config->glayer_continues_enable;
+   wd->glayer_continues_enable = _elm_config->glayer_continues_enable;
 
 #if defined(DEBUG_GESTURE_LAYER)
    printf("size of Gestures = <%d>\n", sizeof(wd->gesture));