pan/tap: add config 'within_distance' as limit on how far apart touches can be 01/307101/3
authorduna.oh <duna.oh@samsung.com>
Tue, 5 Mar 2024 01:47:43 +0000 (10:47 +0900)
committerduna.oh <duna.oh@samsung.com>
Tue, 5 Mar 2024 03:28:46 +0000 (12:28 +0900)
Change-Id: I35dfde1a1e26c0c4e5c9ceb9d5fd63cf157423b1

src/e_mod_gesture_conf.c
src/e_mod_gesture_events.c
src/e_mod_main.c
src/e_mod_main.h

index 6f12268..a078dc1 100644 (file)
@@ -56,6 +56,7 @@ _e_gesture_conf_value_check(E_Gesture_Config_Data* gconfig)
 
    conf = gconfig->conf;
 
+   if (!conf->within_distance) conf->within_distance = E_GESTURE_WITHIN_DISTANCE;
    _e_gesture_conf_edge_swipe_check(conf);
    _e_gesture_conf_edge_drag_check(conf);
    _e_gesture_conf_tap_check(conf);
@@ -73,6 +74,7 @@ e_gesture_conf_init(E_Gesture_Config_Data *gconfig)
 #define D gconfig->conf_edd
    E_CONFIG_VAL(D, T, key_device_name, STR);
    E_CONFIG_VAL(D, T, event_keep, CHAR);
+   E_CONFIG_VAL(D, T, within_distance, INT);
 
    E_CONFIG_VAL(D, T, edge_swipe.time_done, DOUBLE);
    E_CONFIG_VAL(D, T, edge_swipe.time_begin, DOUBLE);
index 6fe11f6..07bdd56 100644 (file)
@@ -869,6 +869,25 @@ _e_gesture_process_edge_drag_up(Ecore_Event_Mouse_Button *ev)
      _e_gesture_event_flush();
 }
 
+static Eina_Bool
+_e_gesture_process_distance_check(int id, int x, int y)
+{
+   double distance;
+   int cx = 0, cy = 0;
+   E_Gesture_Conf_Edd *conf = gesture->config->conf;
+
+   _e_gesture_util_center_axis_get(gesture->gesture_events.num_pressed, &cx, &cy);
+   distance = _e_gesture_util_distance_get(x, y, cx, cy);
+
+   // for Debugging
+   GTDBG("Touch. id:%d, (%d, %d) center(%d, %d), distance: %lf", id, x, y, cx, cy, distance);
+   if (distance > (double)conf->within_distance)
+     {
+        GTWRN("distance(%.2f) is too far. (conf.within_distance:%d) ", distance, conf->within_distance);
+        return EINA_FALSE;
+     }
+   return EINA_TRUE;
+}
 
 static void
 _e_gesture_pan_send(int mode, int fingers, int cx, int cy, struct wl_resource *res, struct wl_client *client)
@@ -951,15 +970,13 @@ _e_gesture_timer_pan_start(void *data)
    return ECORE_CALLBACK_CANCEL;
 }
 
-static void
-_e_gesture_process_pan_down(Ecore_Event_Mouse_Button *ev)
+static Eina_Bool
+_e_gesture_pan_condition_check(E_Gesture_Event_Pan *pans)
 {
-   E_Gesture_Event_Pan *pans = &gesture->gesture_events.pans;
-
    if (!pans->activation.active)
      {
         _e_gesture_pan_cancel();
-        return;
+        return EINA_FALSE;
      }
 
    if (gesture->gesture_events.recognized_gesture &&
@@ -967,6 +984,26 @@ _e_gesture_process_pan_down(Ecore_Event_Mouse_Button *ev)
        (gesture->gesture_events.recognized_gesture & E_GESTURE_TYPE_PINCH)))
      _e_gesture_pan_cancel();
 
+   return EINA_TRUE;
+}
+
+static void
+_e_gesture_process_pan_down(Ecore_Event_Mouse_Button *ev)
+{
+   E_Gesture_Event_Pan *pans = &gesture->gesture_events.pans;
+
+   if (!_e_gesture_pan_condition_check(pans))
+     {
+        return;
+     }
+
+   if (gesture->gesture_events.num_pressed > 0)
+     {
+        if (!_e_gesture_process_distance_check(ev->multi.device,
+                                               ev->x, ev->y))
+          _e_gesture_pan_cancel();
+     }
+
    if (gesture->gesture_events.num_pressed == 1)
      {
         pans->state = E_GESTURE_PANPINCH_STATE_READY;
@@ -982,16 +1019,17 @@ _e_gesture_process_pan_move(Ecore_Event_Mouse_Move *ev)
    Coords cur_point = {0,};
    int idx, diff_x, diff_y, mode;
 
-   if (!pans->activation.active)
+   if (!_e_gesture_pan_condition_check(pans))
      {
-        _e_gesture_pan_cancel();
         return;
      }
 
-   if (gesture->gesture_events.recognized_gesture &&
-       !((gesture->gesture_events.recognized_gesture & E_GESTURE_TYPE_PAN) ||
-       (gesture->gesture_events.recognized_gesture & E_GESTURE_TYPE_PINCH)))
-     _e_gesture_pan_cancel();
+   if (gesture->gesture_events.num_pressed > 0)
+     {
+        if (!_e_gesture_process_distance_check(ev->multi.device,
+                                               ev->x, ev->y))
+          _e_gesture_pan_cancel();
+     }
 
    idx = gesture->gesture_events.num_pressed;
    if (idx <= 0) return;
@@ -1432,6 +1470,13 @@ _e_gesture_process_tap_down(Ecore_Event_Mouse_Button *ev)
         return;
      }
 
+   if (gesture->gesture_events.num_pressed > 0)
+     {
+        if (!_e_gesture_process_distance_check(ev->multi.device,
+                                               ev->x, ev->y))
+          _e_gesture_tap_cancel();
+     }
+
    if (taps->enabled_finger < gesture->gesture_events.num_pressed)
        taps->enabled_finger = gesture->gesture_events.num_pressed;
 
@@ -1493,6 +1538,13 @@ _e_gesture_process_tap_move(Ecore_Event_Mouse_Move *ev)
         return;
      }
 
+   if (gesture->gesture_events.num_pressed > 0)
+     {
+        if (!_e_gesture_process_distance_check(ev->multi.device,
+                                               ev->x, ev->y))
+          _e_gesture_tap_cancel();
+     }
+
    _e_gesture_util_rect_get(taps->enabled_finger, &current_rect.x1, &current_rect.y1, &current_rect.x2, &current_rect.y2);
 
    xx1 = taps->base_rect.x1 - current_rect.x1;
@@ -1505,7 +1557,7 @@ _e_gesture_process_tap_move(Ecore_Event_Mouse_Move *ev)
        ABS(xx2) > conf->tap.moving_range ||
        ABS(yy2) > conf->tap.moving_range)
      {
-        GTDBG("%d finger moving too large diff: (%d, %d)(%d, %d)\n", ev->multi.device, xx1, yy1, xx2, yy2);
+        GTWRN("%d finger moving too large diff: (%d, %d)(%d, %d)\n", ev->multi.device, xx1, yy1, xx2, yy2);
         _e_gesture_tap_cancel();
      }
 }
index 6b24a89..f31458c 100644 (file)
@@ -1951,7 +1951,7 @@ _e_gesture_init(E_Module *m)
    gesture->config = gconfig;
 
    GTDBG("gesture config value\n");
-   GTDBG("key_device_name: %s, event_keep: %d\n", gconfig->conf->key_device_name, gconfig->conf->event_keep);
+   GTDBG("key_device_name: %s, event_keep: %d, within_distance: %d\n", gconfig->conf->key_device_name, gconfig->conf->event_keep, gconfig->conf->within_distance);
    GTDBG("edge_swipe\n");
    GTDBG("\ttime_done: %lf, time_begin: %lf, area_offset: %d\n", gconfig->conf->edge_swipe.time_done,
                                                                  gconfig->conf->edge_swipe.time_begin,
index 1078c6d..7d275fc 100644 (file)
@@ -28,6 +28,7 @@
 
 /* FIX ME: Set values in contiguration file, do not use definition */
 #define E_GESTURE_KEYBOARD_DEVICE "Any"
+#define E_GESTURE_WITHIN_DISTANCE 200
 
 #define E_GESTURE_EDGE_SWIPE_DONE_TIME 0.5
 #define E_GESTURE_EDGE_SWIPE_START_TIME 0.01
@@ -160,6 +161,7 @@ struct _E_Gesture_Conf_Edd
    char *key_device_name;              // The name of keyboard device to generate key events
    Eina_Bool event_keep;               // 1: Do not propagate events to client immediatly until recognizing gestures
                                        // 0: Propagate events immediatly but send a cancel event after recognizing gestures (default)
+   int within_distance;                // The limit on how far apart touch coordinates can be
    struct
    {
       double time_done;                // The duration to recognize a edge swipe