diff options
author | duna.oh <duna.oh@samsung.com> | 2024-05-30 22:10:48 +0900 |
---|---|---|
committer | duna.oh <duna.oh@samsung.com> | 2024-06-05 17:56:00 +0900 |
commit | 758e4ee4030161fecd0910496dfeeffc1fdfbd65 (patch) | |
tree | 1f774e6a531aa2a6bf5b080ea368829b77d5ed6a | |
parent | 434b6e136cdd81d5eba83865036d6ee8b0329a0f (diff) | |
download | efl-util-758e4ee4030161fecd0910496dfeeffc1fdfbd65.tar.gz efl-util-758e4ee4030161fecd0910496dfeeffc1fdfbd65.tar.bz2 efl-util-758e4ee4030161fecd0910496dfeeffc1fdfbd65.zip |
gesture: add APIs to register callback functions when gesture events are triggeredaccepted/tizen/7.0/unified/20240624.161737
introduce new APIs that allow application to set up a callback function which gets
executed when gesture events are detected.
Change-Id: Ic740dd1031120e379bda19386bb08bf6fdbaf646
-rw-r--r-- | include/efl_util.h | 9 | ||||
-rw-r--r-- | src/efl_util.c | 139 |
2 files changed, 148 insertions, 0 deletions
diff --git a/include/efl_util.h b/include/efl_util.h index ed8755d..e3305c1 100644 --- a/include/efl_util.h +++ b/include/efl_util.h @@ -972,6 +972,15 @@ API int efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int */ API int efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active); +typedef void (*efl_util_gesture_edge_swipe_cb)(void *data, int mode, int fingers, int sx, int sy, int edge); +typedef void (*efl_util_gesture_edge_drag_cb)(void *data, int mode, int fingers, int cx, int cy, int edge); +typedef void (*efl_util_gesture_tap_cb)(void *data, int mode, int fingers, int repeats); +typedef void (*efl_util_gesture_palm_cover_cb)(void *data, int mode, int duration, int cx, int cy, int size, double pressure); + +API int efl_util_gesture_edge_swipe_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_edge_swipe_cb cb_func, void *cb_data); +API int efl_util_gesture_edge_drag_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_edge_drag_cb cb_func, void *cb_data); +API int efl_util_gesture_tap_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_tap_cb cb_func, void *cb_data); +API int efl_util_gesture_palm_cover_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_palm_cover_cb cb_func, void *cb_data); /** * @} */ diff --git a/src/efl_util.c b/src/efl_util.c index ad3b9f4..3f92dec 100644 --- a/src/efl_util.c +++ b/src/efl_util.c @@ -185,6 +185,11 @@ typedef struct _Efl_Util_Data_Default_Queue struct tizen_gesture *proto; int request_notified; int event_init; + efl_util_gesture_edge_swipe_cb edge_swipe_cb; + efl_util_gesture_edge_drag_cb edge_drag_cb; + efl_util_gesture_tap_cb tap_cb; + efl_util_gesture_palm_cover_cb palm_cover_cb; + void *data; } gesture; } wl; } Efl_Util_Data_Default_Queue; @@ -2463,12 +2468,14 @@ API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0; static void _cb_gesture_edge_swipe_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t fingers EINA_UNUSED, uint32_t edge EINA_UNUSED, uint32_t edge_size EINA_UNUSED, uint32_t start_point EINA_UNUSED, uint32_t end_point EINA_UNUSED, uint32_t error) { + LOGD(""); _eflutil_defaultqueue.wl.gesture.request_notified = error; } static void _cb_gesture_edge_swipe(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, int sx, int sy, uint32_t edge) { + LOGD(""); efl_util_event_gesture_edge_swipe_s *ev = NULL; ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev)); @@ -2482,17 +2489,25 @@ _cb_gesture_edge_swipe(void *data EINA_UNUSED, struct tizen_gesture *tizen_gestu ev->edge = edge; ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL); + + if (_eflutil_defaultqueue.wl.gesture.edge_swipe_cb) + { + LOGD("edge_swipe_cb"); + _eflutil_defaultqueue.wl.gesture.edge_swipe_cb(_eflutil_defaultqueue.wl.gesture.data, mode, fingers, sx, sy, edge); + } } static void _cb_gesture_edge_drag_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t fingers EINA_UNUSED, uint32_t edge EINA_UNUSED, uint32_t edge_size EINA_UNUSED, uint32_t start_point EINA_UNUSED, uint32_t end_point EINA_UNUSED, uint32_t error) { + LOGD(""); _eflutil_defaultqueue.wl.gesture.request_notified = error; } static void _cb_gesture_edge_drag(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, int cx, int cy, uint32_t edge) { + LOGD(""); efl_util_event_gesture_edge_drag_s *ev = NULL; ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev)); @@ -2506,17 +2521,25 @@ _cb_gesture_edge_drag(void *data EINA_UNUSED, struct tizen_gesture *tizen_gestur ev->edge = edge; ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL); + + if (_eflutil_defaultqueue.wl.gesture.edge_drag_cb) + { + LOGD("edge_drag_cb"); + _eflutil_defaultqueue.wl.gesture.edge_drag_cb(_eflutil_defaultqueue.wl.gesture.data, mode, fingers, cx, cy, edge); + } } static void _cb_gesture_tap_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t fingers EINA_UNUSED, uint32_t repeat EINA_UNUSED, uint32_t error) { + LOGD(""); _eflutil_defaultqueue.wl.gesture.request_notified = error; } static void _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats) { + LOGD(""); efl_util_event_gesture_tap_s *ev = NULL; ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev)); @@ -2528,12 +2551,19 @@ _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA ev->repeats = repeats; ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL); + + if (_eflutil_defaultqueue.wl.gesture.tap_cb) + { + LOGD("tap_cb"); + _eflutil_defaultqueue.wl.gesture.tap_cb(_eflutil_defaultqueue.wl.gesture.data, mode, fingers, repeats); + } } /* LCOV_EXCL_STOP */ static void _cb_gesture_palm_cover_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, struct wl_surface *surface EINA_UNUSED, uint32_t error) { + LOGD(""); _eflutil_defaultqueue.wl.gesture.request_notified = error; } @@ -2541,6 +2571,7 @@ _cb_gesture_palm_cover_notify(void *data EINA_UNUSED, struct tizen_gesture *tize static void _cb_gesture_palm_cover(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, struct wl_surface *surface, uint32_t mode, uint32_t duration, int cx, int cy, uint32_t size, wl_fixed_t pressure) { + LOGD(""); efl_util_event_gesture_palm_cover_s *ev = NULL; ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev)); @@ -2555,12 +2586,19 @@ _cb_gesture_palm_cover(void *data EINA_UNUSED, struct tizen_gesture *tizen_gestu ev->pressure = wl_fixed_to_int(pressure); ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL); + + if (_eflutil_defaultqueue.wl.gesture.palm_cover_cb) + { + LOGD("palm_cover_cb"); + _eflutil_defaultqueue.wl.gesture.palm_cover_cb(_eflutil_defaultqueue.wl.gesture.data, mode, duration, cx, cy, size, pressure); + } } /* LCOV_EXCL_STOP */ static void _cb_gesture_activate_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, struct wl_surface *surface EINA_UNUSED, uint32_t type EINA_UNUSED, uint32_t active EINA_UNUSED, uint32_t error) { + LOGD(""); _eflutil_defaultqueue.wl.gesture.request_notified = error; } @@ -2604,6 +2642,7 @@ _efl_util_gesture_verify_request_notified() static int _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data, Eina_Bool grabbed) { + LOGD(""); 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; @@ -2641,6 +2680,7 @@ _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data, Eina_Bool grabbed) static int _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data, Eina_Bool grabbed) { + LOGD(""); 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; @@ -2678,6 +2718,7 @@ _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data, Eina_Bool grabbed) static int _efl_util_gesture_grab_tap(efl_util_gesture_data data, Eina_Bool grabbed) { + LOGD(""); int ret = EFL_UTIL_ERROR_NONE; Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL; @@ -2709,6 +2750,7 @@ _efl_util_gesture_grab_tap(efl_util_gesture_data data, Eina_Bool grabbed) static int _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data, Eina_Bool grabbed) { + LOGD(""); int ret = EFL_UTIL_ERROR_NONE; Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; @@ -2733,6 +2775,7 @@ _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data, Eina_Bool grabbed) API efl_util_gesture_h efl_util_gesture_initialize(void) { + LOGD(""); efl_util_gesture_h gesture_h = NULL; gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h)); @@ -2783,6 +2826,7 @@ out: API int efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h) { + LOGD(""); EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER); @@ -2807,6 +2851,7 @@ efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h) API efl_util_gesture_data efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge) { + LOGD(""); Efl_Util_Gesture_Edge_Swipe_Grab_Data *data; if (!gesture_h || gesture_h->init == EINA_FALSE) @@ -2841,6 +2886,7 @@ efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int finge API int efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); if (!gesture_h || gesture_h->init == EINA_FALSE) { return EFL_UTIL_ERROR_INVALID_PARAMETER; @@ -2860,6 +2906,7 @@ efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_ API int efl_util_gesture_edge_swipe_size_set(efl_util_gesture_data data, efl_util_gesture_edge_size_e edge_size, unsigned int start_point, unsigned int end_point) { + LOGD(""); Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data; EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER); @@ -2879,6 +2926,7 @@ efl_util_gesture_edge_swipe_size_set(efl_util_gesture_data data, efl_util_gestur API efl_util_gesture_data efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge) { + LOGD(""); Efl_Util_Gesture_Edge_Drag_Grab_Data *data; if (!gesture_h || gesture_h->init == EINA_FALSE) @@ -2913,6 +2961,7 @@ efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int finger API int efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); if (!gesture_h || gesture_h->init == EINA_FALSE) { return EFL_UTIL_ERROR_INVALID_PARAMETER; @@ -2932,6 +2981,7 @@ efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_d API int efl_util_gesture_edge_drag_size_set(efl_util_gesture_data data, efl_util_gesture_edge_size_e edge_size, unsigned int start_point, unsigned int end_point) { + LOGD(""); Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data; EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER); @@ -2951,6 +3001,7 @@ efl_util_gesture_edge_drag_size_set(efl_util_gesture_data data, efl_util_gesture API efl_util_gesture_data efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats) { + LOGD(""); Efl_Util_Gesture_Tap_Grab_Data *data; if (!gesture_h || gesture_h->init == EINA_FALSE) @@ -2984,6 +3035,7 @@ efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, uns API int efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); if (!gesture_h || gesture_h->init == EINA_FALSE) { return EFL_UTIL_ERROR_INVALID_PARAMETER; @@ -3003,6 +3055,7 @@ efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data da API efl_util_gesture_data efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h) { + LOGD(""); Efl_Util_Gesture_Palm_Cover_Grab_Data *data; if (!gesture_h || gesture_h->init == EINA_FALSE) @@ -3028,6 +3081,7 @@ efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h) API int efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); if (!gesture_h || gesture_h->init == EINA_FALSE) { return EFL_UTIL_ERROR_INVALID_PARAMETER; @@ -3048,6 +3102,7 @@ efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_ API int efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); int ret = EFL_UTIL_ERROR_NONE; Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; @@ -3081,6 +3136,7 @@ efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data) API int efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); int ret = EFL_UTIL_ERROR_NONE; Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; @@ -3115,6 +3171,7 @@ efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data API int efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data) { + LOGD(""); Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; Ecore_Wl2_Window *wlwin; struct wl_surface *surface; @@ -3147,6 +3204,7 @@ efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_u API int efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data) { + LOGD(""); Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; Ecore_Wl2_Window *wlwin; struct wl_surface *surface; @@ -3180,6 +3238,7 @@ efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl API int efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active) { + LOGD(""); int ret; EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); @@ -3197,6 +3256,7 @@ efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, E API int efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active) { + LOGD(""); Ecore_Wl2_Window *wlwin; struct wl_surface *surface; int ret; @@ -3219,3 +3279,82 @@ efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Objec return ret; } + +API int efl_util_gesture_edge_swipe_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_edge_swipe_cb cb_func, void *cb_data) +{ + LOGD(""); + 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(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, 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); + + _eflutil_defaultqueue.wl.gesture.edge_swipe_cb = cb_func; + _eflutil_defaultqueue.wl.gesture.data = cb_data; + + return ret; +} +API int efl_util_gesture_edge_drag_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_edge_drag_cb cb_func, void *cb_data) +{ + LOGD(""); + 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(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, 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); + + _eflutil_defaultqueue.wl.gesture.edge_drag_cb = cb_func; + _eflutil_defaultqueue.wl.gesture.data = cb_data; + + return ret; +} +API int efl_util_gesture_tap_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_tap_cb cb_func, void *cb_data) +{ + LOGD(""); + 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(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, 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); + + _eflutil_defaultqueue.wl.gesture.tap_cb = cb_func; + _eflutil_defaultqueue.wl.gesture.data = cb_data; + + return ret; +} + + +API int efl_util_gesture_palm_cover_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_palm_cover_cb cb_func, void *cb_data) +{ + LOGD(""); + 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(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, 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); + + _eflutil_defaultqueue.wl.gesture.palm_cover_cb = cb_func; + _eflutil_defaultqueue.wl.gesture.data = cb_data; + + return ret; +}
\ No newline at end of file |