remove the duplication of gesture grab/ungrab 94/277994/1
authorSooChan Lim <sc1.lim@samsung.com>
Mon, 18 Jul 2022 01:25:07 +0000 (10:25 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 18 Jul 2022 01:25:44 +0000 (10:25 +0900)
Change-Id: I3458d495837cadf9d19a21fc75c91f0c328f9b6a

src/efl_util.c

index 59f6a9b..afd50e1 100644 (file)
@@ -2433,7 +2433,7 @@ _efl_util_gesture_convert_error(int ret)
 
 /* LCOV_EXCL_START */
 static int
-_efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
+_efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data, Eina_Bool grabbed)
 {
    int ret = EFL_UTIL_ERROR_NONE;
    Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
@@ -2459,83 +2459,10 @@ _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
    start_point = edge_swipe_data->start_point;
    end_point = edge_swipe_data->end_point;
 
-   tizen_gesture_grab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
-
-   while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
-     wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
-   ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
-   _eflutil_defaultqueue.wl.gesture.request_notified = -1;
-
-   return ret;
-}
-
-static int
-_efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
-{
-   int ret = EFL_UTIL_ERROR_NONE;
-   Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
-   Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
-   unsigned int fingers = 0;
-   unsigned int edge = 0;
-   unsigned int edge_size = 0;
-   unsigned int start_point = 0;
-   unsigned int end_point = 0;
-
-   base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
-                                  EFL_UTIL_ERROR_INVALID_PARAMETER);
-
-   edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
-
-   fingers = edge_swipe_data->fingers;
-   edge = edge_swipe_data->edge;
-   edge_size = edge_swipe_data->edge_size;
-   start_point = edge_swipe_data->start_point;
-   end_point = edge_swipe_data->end_point;
-
-   tizen_gesture_ungrab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
-
-   while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
-     wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
-   ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
-   _eflutil_defaultqueue.wl.gesture.request_notified = -1;
-
-   return ret;
-}
-
-static int
-_efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
-{
-   int ret = EFL_UTIL_ERROR_NONE;
-   Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
-   Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
-   unsigned int fingers = 0;
-   unsigned int edge = 0;
-   unsigned int edge_size = 0;
-   unsigned int start_point = 0;
-   unsigned int end_point = 0;
-
-   base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
-                                  EFL_UTIL_ERROR_INVALID_PARAMETER);
-
-   edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
-
-   fingers = edge_drag_data->fingers;
-   edge = edge_drag_data->edge;
-   edge_size = edge_drag_data->edge_size;
-   start_point = edge_drag_data->start_point;
-   end_point = edge_drag_data->end_point;
-
-   tizen_gesture_grab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
+   if (grabbed)
+      tizen_gesture_grab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
+   else
+      tizen_gesture_ungrab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
 
    while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
      wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
@@ -2547,7 +2474,7 @@ _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
 }
 
 static int
-_efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
+_efl_util_gesture_grab_edge_drag(efl_util_gesture_data data, Eina_Bool grabbed)
 {
    int ret = EFL_UTIL_ERROR_NONE;
    Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
@@ -2573,40 +2500,10 @@ _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
    start_point = edge_drag_data->start_point;
    end_point = edge_drag_data->end_point;
 
-   tizen_gesture_ungrab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
-
-   while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
-     wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
-   ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
-   _eflutil_defaultqueue.wl.gesture.request_notified = -1;
-
-   return ret;
-}
-
-
-static int
-_efl_util_gesture_grab_tap(efl_util_gesture_data data)
-{
-   int ret = EFL_UTIL_ERROR_NONE;
-   Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
-   Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
-   unsigned int fingers = 0;
-   unsigned int repeats = 0;
-
-   base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
-                                  EFL_UTIL_ERROR_INVALID_PARAMETER);
-
-   tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
-
-   fingers = tap_data->fingers;
-   repeats = tap_data->repeats;
-
-   tizen_gesture_grab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
+   if (grabbed)
+      tizen_gesture_grab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
+   else
+      tizen_gesture_ungrab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
 
    while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
      wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
@@ -2618,7 +2515,7 @@ _efl_util_gesture_grab_tap(efl_util_gesture_data data)
 }
 
 static int
-_efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
+_efl_util_gesture_grab_tap(efl_util_gesture_data data, Eina_Bool grabbed)
 {
    int ret = EFL_UTIL_ERROR_NONE;
    Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
@@ -2638,31 +2535,10 @@ _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
    fingers = tap_data->fingers;
    repeats = tap_data->repeats;
 
-   tizen_gesture_ungrab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
-
-   while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
-     wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
-   ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
-   _eflutil_defaultqueue.wl.gesture.request_notified = -1;
-
-   return ret;
-}
-
-static int
-_efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
-{
-   int ret = EFL_UTIL_ERROR_NONE;
-   Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
-
-   base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
-                                  EFL_UTIL_ERROR_INVALID_PARAMETER);
-
-   tizen_gesture_grab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
+   if (grabbed)
+      tizen_gesture_grab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
+   else
+      tizen_gesture_ungrab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
 
    while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
      wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
@@ -2674,7 +2550,7 @@ _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
 }
 
 static int
-_efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
+_efl_util_gesture_grab_palm_cover(efl_util_gesture_data data, Eina_Bool grabbed)
 {
    int ret = EFL_UTIL_ERROR_NONE;
    Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
@@ -2686,7 +2562,10 @@ _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
    EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
                                   EFL_UTIL_ERROR_INVALID_PARAMETER);
 
-   tizen_gesture_ungrab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
+   if (grabbed)
+      tizen_gesture_grab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
+   else
+      tizen_gesture_ungrab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
 
    while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
      wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
@@ -3028,16 +2907,16 @@ efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
    switch (base_data->type)
      {
         case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
-           ret = _efl_util_gesture_grab_edge_swipe(data);
+           ret = _efl_util_gesture_grab_edge_swipe(data, EINA_TRUE);
            break;
         case TIZEN_GESTURE_TYPE_EDGE_DRAG:
-           ret = _efl_util_gesture_grab_edge_drag(data);
+           ret = _efl_util_gesture_grab_edge_drag(data, EINA_TRUE);
            break;
         case TIZEN_GESTURE_TYPE_TAP:
-           ret = _efl_util_gesture_grab_tap(data);
+           ret = _efl_util_gesture_grab_tap(data, EINA_TRUE);
            break;
         case TIZEN_GESTURE_TYPE_PALM_COVER:
-           ret = _efl_util_gesture_grab_palm_cover(data);
+           ret = _efl_util_gesture_grab_palm_cover(data, EINA_TRUE);
            break;
         default:
            return EFL_UTIL_ERROR_INVALID_PARAMETER;
@@ -3061,16 +2940,16 @@ efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data
    switch (base_data->type)
      {
         case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
-           ret = _efl_util_gesture_ungrab_edge_swipe(data);
+           ret = _efl_util_gesture_grab_edge_swipe(data, EINA_FALSE);
            break;
         case TIZEN_GESTURE_TYPE_EDGE_DRAG:
-           ret = _efl_util_gesture_ungrab_edge_drag(data);
+           ret = _efl_util_gesture_grab_edge_drag(data, EINA_FALSE);
            break;
         case TIZEN_GESTURE_TYPE_TAP:
-           ret = _efl_util_gesture_ungrab_tap(data);
+           ret = _efl_util_gesture_grab_tap(data, EINA_FALSE);
            break;
         case TIZEN_GESTURE_TYPE_PALM_COVER:
-           ret = _efl_util_gesture_ungrab_palm_cover(data);
+           ret = _efl_util_gesture_grab_palm_cover(data, EINA_FALSE);
            break;
         default:
            return EFL_UTIL_ERROR_INVALID_PARAMETER;